21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 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 |
22 # or visit www.oracle.com if you need additional information or have any |
23 # questions. |
23 # questions. |
24 # |
24 # |
25 |
25 |
26 # This file is responsible for extracting the x11 native struct offsets to |
26 # Generate java sources using the X11 offsets that are precalculated in files |
27 # the xawt Java library. The tool needs to be run on the os/arch that |
27 # make/data/x11wrappergen/sizes-<address size>.txt. |
28 # will host the final jvm, thus the tool cannot be used when cross compiling. |
|
29 |
28 |
30 # To enable cross compiling, the two versions of the generated offset file, |
29 GENSRC_X11WRAPPERS_OUTPUT_TOP := $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop |
31 # sizes.32 and sizes.64 are committed into the source code repository. |
|
32 # These are the ones used. |
|
33 |
30 |
34 # However when not cross compiling, the offset generator tool is built and |
31 GENSRC_X11WRAPPERS_MARKER := $(GENSRC_X11WRAPPERS_OUTPUT_TOP)/_x11wrappers.marker |
35 # run, to verify that it still generates the same sizes.32 and sizes.64. |
|
36 |
32 |
37 GENSRC_X11WRAPPERS := |
|
38 # Put temporary c-code and executable to calculate offsets here. |
|
39 # Also put verification offset file here as well. |
|
40 GENSRC_X11WRAPPERS_TMP := $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/_x11wrappers |
|
41 # Put the generated Java classes used to interface X11 from awt here. |
33 # Put the generated Java classes used to interface X11 from awt here. |
42 GENSRC_X11WRAPPERS_DST := $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/sun/awt/X11 |
34 GENSRC_X11WRAPPERS_OUTPUTDIR := $(GENSRC_X11WRAPPERS_OUTPUT_TOP)/sun/awt/X11 |
43 |
35 |
44 # The pre-calculated offset file are stored here: |
36 # The pre-calculated offset file are stored here: |
45 GENSRC_SIZER_DIR := $(TOPDIR)/make/data/x11wrappergen |
37 GENSRC_X11WRAPPERS_DATADIR := $(TOPDIR)/make/data/x11wrappergen |
|
38 GENSRC_X11WRAPPERS_DATA := $(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(OPENJDK_TARGET_CPU_BITS).txt |
46 |
39 |
47 # Normal case is to generate only according to target bits |
40 $(info ExecuteWithLog is $(call ExecuteWithLog $(GENSRC_X11WRAPPERS_OUTPUT_TOP)/foobar, CMDLINE)) |
48 GENSRC_X11_VERSION := $(OPENJDK_TARGET_CPU_BITS) |
|
49 ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) |
|
50 ifneq ($(OPENJDK_TARGET_OS), linux) |
|
51 # On all 64-bit systems except Linux, generate both 32 and 64 bit versions |
|
52 GENSRC_X11_VERSION := 32 64 |
|
53 endif |
|
54 else |
|
55 ifeq ($(OPENJDK_TARGET_OS), solaris) |
|
56 # As a special case, solaris 32-bit also generates the 64-bit version |
|
57 GENSRC_X11_VERSION := 32 64 |
|
58 endif |
|
59 endif |
|
60 |
41 |
61 GENSRC_X11_SIZES_USED := $(addprefix $(GENSRC_X11WRAPPERS_TMP)/sizes., $(GENSRC_X11_VERSION)) |
42 # Run the tool on the offset files to generate several Java classes used in awt. |
62 |
43 $(GENSRC_X11WRAPPERS_MARKER): $(BUILD_TOOLS_JDK) $(GENSRC_X11WRAPPERS_DATA) \ |
63 # Copy only the sizes.* files that are actually needed. WrapperGenerator picks up any it finds from the |
44 $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt |
64 # file prefix it is given so those not needed need to be hidden. |
45 $(call MakeDir, $(GENSRC_X11WRAPPERS_OUTPUTDIR)) |
65 $(GENSRC_X11WRAPPERS_TMP)/sizes.%: $(GENSRC_SIZER_DIR)/sizes.% |
46 $(call LogInfo, Generating X11 wrapper source files) |
66 $(call MakeDir, $(@D)) |
47 $(call ExecuteWithLog, $@, \ |
67 $(RM) '$@' |
48 $(TOOL_WRAPPERGENERATOR) gen_java $(GENSRC_X11WRAPPERS_OUTPUTDIR) \ |
68 $(SORT) $< > $@ |
49 $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(GENSRC_X11WRAPPERS_DATA) \ |
69 |
50 $(OPENJDK_TARGET_CPU_BITS)) |
70 # Run the tool on the offset files copied from the source repository to generate several Java classes |
|
71 # used in awt. |
|
72 $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/_the.generated.x11: $(GENSRC_X11_SIZES_USED) $(BUILD_TOOLS_JDK) |
|
73 $(call MakeDir, $(GENSRC_X11WRAPPERS_DST)) |
|
74 $(TOOL_WRAPPERGENERATOR) $(GENSRC_X11WRAPPERS_DST) $(GENSRC_SIZER_DIR)/xlibtypes.txt "gen" $(GENSRC_X11WRAPPERS_TMP)/sizes |
|
75 $(TOUCH) $@ |
51 $(TOUCH) $@ |
76 |
52 |
77 GENSRC_X11WRAPPERS += $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/_the.generated.x11 |
|
78 |
53 |
79 ifneq ($(COMPILE_TYPE), cross) |
54 GENSRC_JAVA_DESKTOP += $(GENSRC_X11WRAPPERS_MARKER) |
80 # This is not a cross compile, regenerate the offset file, so that we |
|
81 # can compare it with the version in the source code repository. |
|
82 |
|
83 # Generate the C code for the program that will output the offset file. |
|
84 $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c: $(GENSRC_SIZER_DIR)/xlibtypes.txt $(BUILD_TOOLS_JDK) |
|
85 $(call LogInfo, Generating X11 wrapper ($*-bit version)) |
|
86 $(call MakeDir, $(@D)) |
|
87 $(TOOL_WRAPPERGENERATOR) $(@D) $(GENSRC_SIZER_DIR)/xlibtypes.txt "sizer" $* |
|
88 |
|
89 # use -m32/-m64 only if the compiler supports it |
|
90 ifeq ($(COMPILER_SUPPORTS_TARGET_BITS_FLAG), true) |
|
91 MEMORY_MODEL_FLAG="$(COMPILER_TARGET_BITS_FLAG)$*" |
|
92 endif |
|
93 |
|
94 SIZER_CFLAGS := \ |
|
95 -I$(TOPDIR)/src/hotspot/share/include \ |
|
96 -I$(TOPDIR)/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include \ |
|
97 -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ |
|
98 -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \ |
|
99 -I$(TOPDIR)/src/java.base/share/native/libjava \ |
|
100 -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \ |
|
101 -I$(TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \ |
|
102 -I$(TOPDIR)/src/java.desktop/share/native/common/awt/debug \ |
|
103 -I$(TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \ |
|
104 # |
|
105 |
|
106 # Compile the C code into an executable. |
|
107 $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe: $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c |
|
108 $(call MakeDir, $(@D)) |
|
109 (cd $(@D) && $(CC) $(MEMORY_MODEL_FLAG) -o $@ $< \ |
|
110 $(X_CFLAGS) \ |
|
111 $(X_LIBS) \ |
|
112 $(SIZER_CFLAGS) -lc) |
|
113 |
|
114 .PRECIOUS: $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c |
|
115 |
|
116 # Run the executable create the offset file and check that it is identical |
|
117 # to the offset file in the source code repository. |
|
118 $(GENSRC_X11WRAPPERS_TMP)/sizes.%.verification: $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe |
|
119 $(call LogInfo, Verifying X11 wrapper sizes) |
|
120 $(call MakeDir, $(@D)) |
|
121 $(GENSRC_X11WRAPPERS_TMP)/sizer.$*.exe | $(SORT) > $@.tmp |
|
122 $(DIFF) $(GENSRC_X11WRAPPERS_TMP)/sizes.$*.verification.tmp $(GENSRC_X11WRAPPERS_TMP)/sizes.$* |
|
123 mv $@.tmp $@ |
|
124 |
|
125 GENSRC_X11WRAPPERS += $(GENSRC_X11WRAPPERS_TMP)/sizes.$(OPENJDK_TARGET_CPU_BITS).verification |
|
126 endif |
|
127 |
|
128 GENSRC_JAVA_DESKTOP += $(GENSRC_X11WRAPPERS) |
|