25854
|
1 |
#
|
|
2 |
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
#
|
|
5 |
# This code is free software; you can redistribute it and/or modify it
|
|
6 |
# under the terms of the GNU General Public License version 2 only, as
|
|
7 |
# published by the Free Software Foundation. Oracle designates this
|
|
8 |
# particular file as subject to the "Classpath" exception as provided
|
|
9 |
# by Oracle in the LICENSE file that accompanied this code.
|
|
10 |
#
|
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
# accompanied this code).
|
|
16 |
#
|
|
17 |
# You should have received a copy of the GNU General Public License version
|
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
#
|
|
21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
# or visit www.oracle.com if you need additional information or have any
|
|
23 |
# questions.
|
|
24 |
#
|
|
25 |
|
|
26 |
default: all
|
|
27 |
|
|
28 |
include $(SPEC)
|
|
29 |
include MakeBase.gmk
|
|
30 |
include JavaCompilation.gmk
|
|
31 |
|
|
32 |
THIS_FILE := $(SRC_ROOT)/test/make/TestJavaCompilation.gmk
|
|
33 |
DEPS := $(THIS_FILE) \
|
|
34 |
$(SRC_ROOT)/make/common/MakeBase.gmk \
|
|
35 |
$(SRC_ROOT)/make/common/JavaCompilation.gmk \
|
|
36 |
#
|
|
37 |
|
|
38 |
OUTPUT_DIR := $(TESTMAKE_OUTPUTDIR)/java-compilation
|
|
39 |
|
|
40 |
################################################################################
|
|
41 |
# Test: jar1
|
|
42 |
# Creates a simple jar file and unzips it to verify that the files have not
|
|
43 |
# changed.
|
|
44 |
|
|
45 |
JAR1_SRC_ROOT := $(OUTPUT_DIR)/jar1src
|
|
46 |
JAR1_UNZIP := $(OUTPUT_DIR)/jar1unzip
|
|
47 |
JAR1_FILE := $(OUTPUT_DIR)/jar1.jar
|
|
48 |
JAR1_MANIFEST := $(OUTPUT_DIR)/jar1_manifest
|
|
49 |
|
|
50 |
clean-jar1:
|
|
51 |
$(RM) -r $(OUTPUT_DIR)/_jar1* $(OUTPUT_DIR)/jar1*
|
|
52 |
|
|
53 |
$(OUTPUT_DIR)/_jar1_created: $(DEPS)
|
|
54 |
$(RM) -r $(JAR1_SRC_ROOT)
|
|
55 |
$(RM) $(JAR1_FILE)
|
|
56 |
$(RM) -r $(JAR1_UNZIP)
|
|
57 |
$(MKDIR) -p $(JAR1_SRC_ROOT)
|
|
58 |
$(MKDIR) -p $(JAR1_SRC_ROOT)/dir1
|
|
59 |
$(MKDIR) -p $(JAR1_SRC_ROOT)/dir2
|
|
60 |
$(MKDIR) -p $(JAR1_SRC_ROOT)/META-INF
|
|
61 |
$(TOUCH) $(JAR1_SRC_ROOT)/dir1/file1.class
|
|
62 |
$(TOUCH) $(JAR1_SRC_ROOT)/dir2/file2.class
|
|
63 |
$(TOUCH) $(JAR1_SRC_ROOT)/META-INF/metafile
|
|
64 |
$(ECHO) "Test-Attribute: value" > $(JAR1_MANIFEST)
|
|
65 |
$(TOUCH) $@
|
|
66 |
|
|
67 |
$(eval $(call SetupArchive,BUILD_JAR1, \
|
|
68 |
$(OUTPUT_DIR)/_jar1_created, \
|
|
69 |
SRCS := $(JAR1_SRC_ROOT), \
|
|
70 |
MANIFEST := $(JAR1_MANIFEST), \
|
|
71 |
JAR := $(JAR1_FILE)))
|
|
72 |
|
|
73 |
$(OUTPUT_DIR)/_jar1_verified: $(BUILD_JAR1)
|
|
74 |
$(RM) -r $(JAR1_UNZIP)
|
|
75 |
$(MKDIR) -p $(JAR1_UNZIP)
|
|
76 |
$(CD) $(JAR1_UNZIP) && $(UNZIP) $(JAR1_FILE) $(LOG_DEBUG)
|
|
77 |
$(DIFF) -r $(JAR1_SRC_ROOT)/dir1 $(JAR1_UNZIP)/dir1
|
|
78 |
$(DIFF) -r $(JAR1_SRC_ROOT)/dir2 $(JAR1_UNZIP)/dir2
|
|
79 |
$(DIFF) -r $(JAR1_SRC_ROOT)/META-INF/metafile $(JAR1_UNZIP)/META-INF/metafile
|
|
80 |
if [ "`$(GREP) 'Test-Attribute: value' $(JAR1_MANIFEST)`" = "" ]; then \
|
|
81 |
$(ECHO) "Could not find Test-Attribute in manifest of $(JAR1_FILE)"; \
|
|
82 |
exit 1; \
|
|
83 |
fi
|
|
84 |
$(TOUCH) $@
|
|
85 |
|
|
86 |
create-jar2: $(OUTPUT_DIR)/_jar1_verified
|
|
87 |
TEST_TARGETS += $(OUTPUT_DIR)/_jar1_verified
|
|
88 |
|
|
89 |
# Change a source file and call this makefile again to force the jar to be
|
|
90 |
# updated.
|
|
91 |
$(OUTPUT_DIR)_jar1_updated: $(OUTPUT_DIR)/_jar1_verified
|
|
92 |
$(ECHO) updated > $(JAR1_SRC_ROOT)/dir1/file1.class
|
|
93 |
$(ECHO) updated > $(JAR1_SRC_ROOT)/META-INF/metafile
|
|
94 |
$(TOUCH) $(OUTPUT_DIR)/_jar1_created
|
|
95 |
+$(MAKE) -f $(THIS_FILE) $(OUTPUT_DIR)/_jar1_verified
|
|
96 |
$(TOUCH) $@
|
|
97 |
|
|
98 |
update-jar1: $(OUTPUT_DIR)_jar1_updated
|
|
99 |
TEST_TARGETS += $(OUTPUT_DIR)_jar1_updated
|
|
100 |
|
|
101 |
.PHONY: clean-jar1 create-jar1 update-jar1
|
|
102 |
|
|
103 |
################################################################################
|
|
104 |
# Test: jar2
|
|
105 |
# Creates a jar file based on 2 source roots
|
|
106 |
|
|
107 |
JAR2_SRC_ROOT1 := $(OUTPUT_DIR)/jar2src1
|
|
108 |
JAR2_SRC_ROOT2 := $(OUTPUT_DIR)/jar2src2
|
|
109 |
JAR2_UNZIP := $(OUTPUT_DIR)/jar2unzip
|
|
110 |
JAR2_FILE := $(OUTPUT_DIR)/jar2.jar
|
|
111 |
|
|
112 |
clean-jar2:
|
|
113 |
$(RM) -r $(OUTPUT_DIR)/_jar2* $(OUTPUT_DIR)/jar2*
|
|
114 |
|
|
115 |
$(OUTPUT_DIR)/_jar2_created: $(DEPS)
|
|
116 |
$(RM) -r $(JAR2_SRC_ROOT1)
|
|
117 |
$(RM) -r $(JAR2_SRC_ROOT2)
|
|
118 |
$(RM) $(JAR2_FILE)
|
|
119 |
$(RM) -r $(JAR2_UNZIP)
|
|
120 |
$(MKDIR) -p $(JAR2_SRC_ROOT1)/dir1
|
|
121 |
$(MKDIR) -p $(JAR2_SRC_ROOT2)/dir2
|
|
122 |
$(TOUCH) $(JAR2_SRC_ROOT1)/dir1/file1.class
|
|
123 |
$(TOUCH) $(JAR2_SRC_ROOT2)/dir2/file2.class
|
|
124 |
$(TOUCH) $@
|
|
125 |
|
|
126 |
$(eval $(call SetupArchive,BUILD_JAR2, \
|
|
127 |
$(OUTPUT_DIR)/_jar2_created, \
|
|
128 |
SRCS := $(JAR2_SRC_ROOT1) $(JAR2_SRC_ROOT2), \
|
|
129 |
JAR := $(JAR2_FILE)))
|
|
130 |
|
|
131 |
$(OUTPUT_DIR)/_jar2_verified: $(BUILD_JAR2)
|
|
132 |
$(RM) -r $(JAR2_UNZIP)
|
|
133 |
$(MKDIR) -p $(JAR2_UNZIP)
|
|
134 |
$(CD) $(JAR2_UNZIP) && $(UNZIP) $(JAR2_FILE) $(LOG_DEBUG)
|
|
135 |
$(DIFF) -r $(JAR2_SRC_ROOT1)/dir1 $(JAR2_UNZIP)/dir1
|
|
136 |
$(DIFF) -r $(JAR2_SRC_ROOT2)/dir2 $(JAR2_UNZIP)/dir2
|
|
137 |
$(TOUCH) $@
|
|
138 |
|
|
139 |
create-jar2: $(OUTPUT_DIR)/_jar2_verified
|
|
140 |
TEST_TARGETS += $(OUTPUT_DIR)/_jar2_verified
|
|
141 |
|
|
142 |
$(OUTPUT_DIR)_jar2_updated: $(OUTPUT_DIR)/_jar2_verified
|
|
143 |
$(ECHO) updated > $(JAR2_SRC_ROOT1)/dir1/file1.class
|
|
144 |
$(TOUCH) $(OUTPUT_DIR)/_jar2_created
|
|
145 |
+$(MAKE) -f $(THIS_FILE) $(OUTPUT_DIR)/_jar2_verified
|
|
146 |
$(TOUCH) $@
|
|
147 |
|
|
148 |
update-jar2: $(OUTPUT_DIR)_jar2_updated
|
|
149 |
TEST_TARGETS += $(OUTPUT_DIR)_jar2_updated
|
|
150 |
|
|
151 |
.PHONY: clean-jar2 create-jar2 update-jar2
|
|
152 |
|
|
153 |
################################################################################
|
|
154 |
# Test: jar3
|
|
155 |
# Creates a jar file based on 2 source roots with an extra file
|
|
156 |
|
|
157 |
JAR3_SRC_ROOT1 := $(OUTPUT_DIR)/jar3src1
|
|
158 |
JAR3_SRC_ROOT2 := $(OUTPUT_DIR)/jar3src2
|
|
159 |
JAR3_UNZIP := $(OUTPUT_DIR)/jar3unzip
|
|
160 |
JAR3_FILE := $(OUTPUT_DIR)/jar3.jar
|
|
161 |
|
|
162 |
clean-jar3:
|
|
163 |
$(RM) -r $(OUTPUT_DIR)/_jar3* $(OUTPUT_DIR)/jar3*
|
|
164 |
|
|
165 |
$(OUTPUT_DIR)/_jar3_created: $(DEPS)
|
|
166 |
$(RM) -r $(JAR3_SRC_ROOT1)
|
|
167 |
$(RM) -r $(JAR3_SRC_ROOT2)
|
|
168 |
$(RM) $(JAR3_FILE)
|
|
169 |
$(RM) -r $(JAR3_UNZIP)
|
|
170 |
$(MKDIR) -p $(JAR3_SRC_ROOT1)/dir1
|
|
171 |
$(MKDIR) -p $(JAR3_SRC_ROOT2)/dir2
|
|
172 |
$(TOUCH) $(JAR3_SRC_ROOT1)/dir1/file1\$$foo.class
|
|
173 |
$(TOUCH) $(JAR3_SRC_ROOT2)/dir2/file2.class
|
|
174 |
$(TOUCH) $(JAR3_SRC_ROOT2)/extra-file
|
|
175 |
$(TOUCH) $(JAR3_SRC_ROOT2)/extra-file-abs
|
|
176 |
$(TOUCH) $(JAR3_SRC_ROOT2)/dir2/file\$$foo.dollar
|
|
177 |
$(TOUCH) $@
|
|
178 |
|
|
179 |
$(eval $(call SetupArchive,BUILD_JAR3, \
|
|
180 |
$(OUTPUT_DIR)/_jar3_created, \
|
|
181 |
SRCS := $(JAR3_SRC_ROOT1) $(JAR3_SRC_ROOT2), \
|
|
182 |
EXTRA_FILES := extra-file \
|
|
183 |
dir2/file$$$$foo.dollar \
|
|
184 |
$(JAR3_SRC_ROOT2)/extra-file-abs, \
|
|
185 |
EXCLUDE_FILES := dir1/file1$$$$foo.class, \
|
|
186 |
JAR := $(JAR3_FILE)))
|
|
187 |
|
|
188 |
$(OUTPUT_DIR)/_jar3_verified: $(BUILD_JAR3)
|
|
189 |
$(RM) -r $(JAR3_UNZIP)
|
|
190 |
$(MKDIR) -p $(JAR3_UNZIP)
|
|
191 |
$(CD) $(JAR3_UNZIP) && $(UNZIP) $(JAR3_FILE) $(LOG_DEBUG)
|
|
192 |
if [ -d "$(JAR3_UNZIP)/dir1" ]; then \
|
|
193 |
echo Should not be included $(JAR3_UNZIP)/dir1; \
|
|
194 |
exit 1; \
|
|
195 |
fi
|
|
196 |
$(DIFF) -r $(JAR3_SRC_ROOT2)/dir2 $(JAR3_UNZIP)/dir2
|
|
197 |
$(DIFF) -r $(JAR3_SRC_ROOT2)/extra-file $(JAR3_UNZIP)/extra-file
|
|
198 |
$(TOUCH) $@
|
|
199 |
|
|
200 |
create-jar3: $(OUTPUT_DIR)/_jar3_verified
|
|
201 |
TEST_TARGETS += $(OUTPUT_DIR)/_jar3_verified
|
|
202 |
|
|
203 |
$(OUTPUT_DIR)_jar3_updated: $(OUTPUT_DIR)/_jar3_verified
|
|
204 |
$(ECHO) updated > $(JAR3_SRC_ROOT2)/extra-file
|
|
205 |
$(TOUCH) $(OUTPUT_DIR)/_jar3_created
|
|
206 |
+$(MAKE) -f $(THIS_FILE) $(OUTPUT_DIR)/_jar3_verified
|
|
207 |
$(TOUCH) $@
|
|
208 |
|
|
209 |
update-jar3: $(OUTPUT_DIR)_jar3_updated
|
|
210 |
TEST_TARGETS += $(OUTPUT_DIR)_jar3_updated
|
|
211 |
|
|
212 |
.PHONY: clean-jar3 create-jar3 update-jar3
|
|
213 |
|
|
214 |
################################################################################
|
|
215 |
|
|
216 |
all: $(TEST_TARGETS)
|
|
217 |
|
|
218 |
.PHONY: default all
|