2
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
26
################################################################################
27
# Build demos for the JDK into $(SUPPORT_OUTPUTDIR)/demos/image.
28
################################################################################
36
include JavaCompilation.gmk
37
include TextFileProcessing.gmk
40
# Hook to include the corresponding custom file, if present.
41
$(eval $(call IncludeCustomExtension, CompileDemos-pre.gmk))
43
# Prepare the find cache.
44
DEMO_SRC_DIRS += $(TOPDIR)/src/demo
46
$(call FillFindCache, $(DEMO_SRC_DIRS))
48
# Append demo goals to this variable.
51
# The demo structure and contents should really be cleaned up.
52
# Now every other demo has its own quirks where to put the
53
# READMEs and other files.
55
DEMO_SHARE_SRC := $(TOPDIR)/src/demo/share
57
DEMO_MANIFEST := $(SUPPORT_OUTPUTDIR)/demos/java-main-manifest.mf
59
# This rule will be depended on due to the MANIFEST line in SetupBuildDemo
60
# and SetupBuildJvmtiDemo.
61
$(eval $(call SetupTextFileProcessing, BUILD_JAVA_MANIFEST, \
62
SOURCE_FILES := $(TOPDIR)/make/data/mainmanifest/manifest.mf.template, \
63
OUTPUT_FILE := $(DEMO_MANIFEST), \
65
@@VERSION_SPECIFICATION@@ => $(VERSION_SPECIFICATION) ; \
66
@@VERSION_SHORT@@ => $(VERSION_SHORT) ; \
67
@@COMPANY_NAME@@ => $(COMPANY_NAME) , \
70
################################################################################
73
COPY_TO_JAR := .html .txt .properties .js .gif .jpg .theme .data .opt .c .h \
74
.png .ttf .xyz .obj README COPYRIGHT
76
COPY_TO_IMAGE := *.html *.txt *.png *.xml README*
78
# Setup make rules for building a demo.
80
# Parameter 1 is the name of the rule. This name is used as variable prefix,
81
# and the targets generated are listed in a variable by that name.
83
# Remaining parameters are named arguments. These include:
84
# DEMO_SUBDIR The name of the subdir of the demo, below the demo top dir.
85
# EXTRA_SRC_DIR Additional source directory.
86
# SRC_SUB_DIR Optional subdir to locate source code in
87
# SRC_DIR Alternative source directory to use for the demos.
88
# EXCLUDE_FILES Exclude file list
89
# JAR_NAME Base name of jar file. Defaults to $1.
90
# MAIN_CLASS The main class for the jar. Defaults to $1.
91
# EXTRA_COPY_TO_JAR Additional files to copy to jar (as patterns)
92
# EXTRA_COPY_TO_IMAGE Additional files to copy to images (as wildcards)
93
# EXTRA_MANIFEST_ATTR Extra manifest attribute
94
# SKIP_COMPILATION Skip Java compilation iff true
95
# DISABLED_WARNINGS Additional disabled warnings
96
SetupBuildDemo = $(NamedParamsMacroTemplate)
97
define SetupBuildDemoBody
98
ifeq ($$($1_SRC_DIR), )
99
$1_SRC_DIR := $(DEMO_SHARE_SRC)
102
$1_SRC_BASE := $$($1_SRC_DIR)/$$($1_DEMO_SUBDIR)/$1
104
# In some demos the source is found in a subdir
105
ifneq ($$($1_SRC_SUB_DIR), )
106
$1_MAIN_SRC := $$($1_SRC_BASE)/$$($1_SRC_SUB_DIR)
109
$1_MAIN_SRC := $$($1_SRC_BASE)
112
# Default is to use demo name as jar file name.
113
ifeq ($$($1_JAR_NAME), )
117
# Default is to use demo name as jar main class.
118
ifeq ($$($1_MAIN_CLASS), )
120
else ifeq ($$($1_MAIN_CLASS), NONE)
122
$1_EXTRA_MANIFEST_ATTR += Main-Class: \n
125
ifneq ($$($1_SKIP_COMPILATION), true)
126
$$(eval $$(call SetupJavaCompilation, BUILD_DEMO_$1, \
127
TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \
128
SRC := $$($1_MAIN_SRC) $$($1_EXTRA_SRC_DIR), \
129
BIN := $(SUPPORT_OUTPUTDIR)/demos/classes/$$($1_DEMO_SUBDIR)/$1, \
130
COPY := $(COPY_TO_JAR) $$($1_EXTRA_COPY_TO_JAR), \
131
JAR := $(SUPPORT_OUTPUTDIR)/demos/image/$$($1_DEMO_SUBDIR)/$1/$$($1_JAR_NAME).jar, \
132
JARMAIN := $$($1_MAIN_CLASS), \
133
MANIFEST := $(DEMO_MANIFEST), \
134
EXTRA_MANIFEST_ATTR := $$($1_EXTRA_MANIFEST_ATTR), \
135
SRCZIP := $(SUPPORT_OUTPUTDIR)/demos/image/$$($1_DEMO_SUBDIR)/$1/src.zip, \
136
EXCLUDE_FILES := $$($1_EXCLUDE_FILES), \
137
DISABLED_WARNINGS := $$($1_DISABLED_WARNINGS), \
140
$1 += $$(BUILD_DEMO_$1)
143
# Copy files. Sort is needed to remove duplicates.
144
$1_COPY_FILES := $$(sort $$(wildcard $$(addprefix $$($1_SRC_BASE)/, \
145
$(COPY_TO_IMAGE) $$($1_EXTRA_COPY_TO_IMAGE))))
146
$$(eval $$(call SetupCopyFiles, COPY_DEMO_$1, \
147
SRC := $$($1_SRC_BASE), \
148
DEST := $(SUPPORT_OUTPUTDIR)/demos/image/$$($1_DEMO_SUBDIR)/$1, \
149
FILES := $$($1_COPY_FILES), \
152
$1 += $$(COPY_DEMO_$1)
157
CODEPOINT_SERVICE := java.awt.im.spi.InputMethodDescriptor
158
CODEPOINT_METAINF_SERVICE_FILE := \
159
$(SUPPORT_OUTPUTDIR)/demos/classes/jfc/CodePointIM/META-INF/services/$(CODEPOINT_SERVICE)
161
$(eval $(call SetupBuildDemo, CodePointIM, \
162
DEMO_SUBDIR := jfc, \
163
EXTRA_COPY_TO_JAR := $(CODEPOINT_SERVICE), \
166
# We also need to copy the CODEPOINT_SERVICE file to the META-INF/services
167
# location, and make sure the jar depends on that file to get it included.
168
$(CODEPOINT_METAINF_SERVICE_FILE): $(DEMO_SHARE_SRC)/jfc/CodePointIM/$(CODEPOINT_SERVICE)
171
$(BUILD_DEMO_CodePointIM_JAR): $(CODEPOINT_METAINF_SERVICE_FILE)
173
$(eval $(call SetupBuildDemo, FileChooserDemo, \
174
DEMO_SUBDIR := jfc, \
175
DISABLED_WARNINGS := rawtypes deprecation unchecked this-escape, \
178
$(eval $(call SetupBuildDemo, SwingSet2, \
179
DEMO_SUBDIR := jfc, \
180
EXTRA_COPY_TO_JAR := .java, \
181
EXTRA_MANIFEST_ATTR := SplashScreen-Image: resources/images/splash.png, \
182
DISABLED_WARNINGS := rawtypes deprecation unchecked static serial cast this-escape, \
185
$(eval $(call SetupBuildDemo, Font2DTest, \
186
DISABLED_WARNINGS := rawtypes deprecation unchecked serial cast this-escape dangling-doc-comments, \
187
DEMO_SUBDIR := jfc, \
190
$(eval $(call SetupBuildDemo, J2Ddemo, \
191
DEMO_SUBDIR := jfc, \
192
MAIN_CLASS := java2d.J2Ddemo, \
193
DISABLED_WARNINGS := rawtypes deprecation unchecked cast lossy-conversions this-escape, \
194
JAR_NAME := J2Ddemo, \
197
$(eval $(call SetupBuildDemo, Metalworks, \
198
DISABLED_WARNINGS := rawtypes unchecked this-escape, \
199
DEMO_SUBDIR := jfc, \
202
$(eval $(call SetupBuildDemo, Notepad, \
203
DISABLED_WARNINGS := rawtypes this-escape, \
204
DEMO_SUBDIR := jfc, \
207
$(eval $(call SetupBuildDemo, Stylepad, \
208
DEMO_SUBDIR := jfc, \
209
DISABLED_WARNINGS := rawtypes unchecked this-escape, \
210
EXTRA_SRC_DIR := $(DEMO_SHARE_SRC)/jfc/Notepad, \
211
EXCLUDE_FILES := $(DEMO_SHARE_SRC)/jfc/Notepad/README.txt, \
214
$(eval $(call SetupBuildDemo, SampleTree, \
215
DEMO_SUBDIR := jfc, \
218
$(eval $(call SetupBuildDemo, TableExample, \
219
DISABLED_WARNINGS := rawtypes unchecked deprecation this-escape dangling-doc-comments, \
220
DEMO_SUBDIR := jfc, \
223
$(eval $(call SetupBuildDemo, TransparentRuler, \
224
DISABLED_WARNINGS := this-escape, \
225
DEMO_SUBDIR := jfc, \
226
MAIN_CLASS := transparentruler.Ruler, \
229
################################################################################
230
# Copy html and README files.
232
$(SUPPORT_OUTPUTDIR)/demos/image/README: $(DEMO_SHARE_SRC)/README
235
TARGETS += $(SUPPORT_OUTPUTDIR)/demos/image/README
237
################################################################################
238
# Copy netbeans project files.
240
$(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%: $(DEMO_SHARE_SRC)/nbproject/%
244
TARGETS += $(patsubst $(DEMO_SHARE_SRC)/nbproject/%, \
245
$(SUPPORT_OUTPUTDIR)/demos/image/nbproject/%, \
246
$(call FindFiles, $(DEMO_SHARE_SRC)/nbproject))
248
################################################################################
250
ifneq ($(filter images, $(MAKECMDGOALS)), )
251
$(eval $(call SetupCopyFiles, COPY_TO_TEST_IMAGE, \
252
SRC := $(SUPPORT_OUTPUTDIR)/demos/image, \
253
DEST := $(TEST_IMAGE_DIR)/jdk/demos, \
254
FILES := $(call FindFiles, $(SUPPORT_OUTPUTDIR)/demos/image), \
257
IMAGES_TARGETS := $(COPY_TO_TEST_IMAGE)
260
################################################################################
261
# Hook to include the corresponding custom file, if present.
262
$(eval $(call IncludeCustomExtension, CompileDemos-post.gmk))
265
images: $(IMAGES_TARGETS)