comparison make/jvmci.make @ 21937:3a292e8b9e51

replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers META-INF/services/ files for Options provider are now generated directly from files in META-INF/jvmci.options/
author Doug Simon <doug.simon@oracle.com>
date Fri, 12 Jun 2015 01:19:57 +0200
parents 35961ae3486f
children 95956bc1b1a3
comparison
equal deleted inserted replaced
21936:11f241f26c61 21937:3a292e8b9e51
6 ABS_BOOTDIR= 6 ABS_BOOTDIR=
7 7
8 JAVAC=$(ABS_BOOTDIR)/bin/javac -g -target 1.8 8 JAVAC=$(ABS_BOOTDIR)/bin/javac -g -target 1.8
9 JAR=$(ABS_BOOTDIR)/bin/jar 9 JAR=$(ABS_BOOTDIR)/bin/jar
10 10
11 EXPORTED_FILES_ADDITIONAL=$(TARGET)/options $(TARGET)/services
12 HS_COMMON_SRC=. 11 HS_COMMON_SRC=.
13 12
14 # Directories, where the generated property-files reside within the JAR files 13 # Directories, where the generated property-files reside within the JAR files
15 PROVIDERS_INF=/META-INF/providers 14 PROVIDERS_INF=/META-INF/jvmci.providers
16 SERVICES_INF=/META-INF/services 15 SERVICES_INF=/META-INF/jvmci.services
17 OPTIONS_INF=/META-INF/options 16 OPTIONS_INF=/META-INF/jvmci.options
18 17
19 ifeq ($(ABS_BOOTDIR),) 18 ifeq ($(ABS_BOOTDIR),)
20 $(error Variable ABS_BOOTDIR must be set to a JDK installation.) 19 $(error Variable ABS_BOOTDIR must be set to a JDK installation.)
21 endif 20 endif
22 ifeq ($(MAKE_VERBOSE),) 21 ifeq ($(MAKE_VERBOSE),)
25 24
26 # Required to construct a whitespace for use with subst 25 # Required to construct a whitespace for use with subst
27 space := 26 space :=
28 space += 27 space +=
29 28
30 # Takes the option files of the options annotation processor and merges them into a single file 29 # Takes the provider files created by ServiceProviderProcessor (the processor
30 # for the @ServiceProvider annotation) and merges them into a single file.
31 # Arguments: 31 # Arguments:
32 # 1: directory with contents of the JAR file 32 # 1: directory with contents of the JAR file
33 define process_options 33 define process_providers
34 $(eval providers=$(1)/$(PROVIDERS_INF)) 34 $(eval providers=$(1)/$(PROVIDERS_INF))
35 $(eval services=$(1)/$(SERVICES_INF)) 35 $(eval services=$(1)/$(SERVICES_INF))
36 $(eval options=$(1)/$(OPTIONS_INF))
37 $(QUIETLY) test -d $(services) || mkdir -p $(services) 36 $(QUIETLY) test -d $(services) || mkdir -p $(services)
38 $(QUIETLY) test ! -d $(providers) || (cd $(providers) && for i in $$(ls); do c=$$(cat $$i); echo $$i >> $(abspath $(services))/$$c; rm $$i; done) 37 $(QUIETLY) test ! -d $(providers) || (cd $(providers) && for i in $$(ls); do c=$$(cat $$i); echo $$i >> $(abspath $(services))/$$c; rm $$i; done)
39 38
40 @# Since all projects are built together with one javac call we cannot determine 39 @# Since all projects are built together with one javac call we cannot determine
41 @# which project contains HotSpotVMConfig.inline.hpp so we hardcode it. 40 @# which project contains HotSpotVMConfig.inline.hpp so we hardcode it.
42 $(eval vmconfig=$(1)/hotspot/HotSpotVMConfig.inline.hpp) 41 $(eval vmconfig=$(1)/hotspot/HotSpotVMConfig.inline.hpp)
43 $(eval vmconfigDest=$(HS_COMMON_SRC)/../jvmci/com.oracle.jvmci.hotspot/src_gen/hotspot) 42 $(eval vmconfigDest=$(HS_COMMON_SRC)/../jvmci/com.oracle.jvmci.hotspot/src_gen/hotspot)
44 $(QUIETLY) test ! -f $(vmconfig) || (mkdir -p $(vmconfigDest) && cp $(vmconfig) $(vmconfigDest)) 43 $(QUIETLY) test ! -f $(vmconfig) || (mkdir -p $(vmconfigDest) && cp $(vmconfig) $(vmconfigDest))
45 endef 44 endef
46 45
47 # Extracts META-INF/services and META-INF/options of a JAR file into a given directory 46 # Reads the files in jvmci.options/ created by OptionProcessor (the processor for the @Option annotation)
47 # and appends to services/com.oracle.jvmci.options.Options entries for the providers
48 # also created by the same processor.
49 # Arguments:
50 # 1: directory with contents of the JAR file
51 define process_options
52 $(eval options=$(1)/$(OPTIONS_INF))
53 $(eval services=$(1)/META-INF/services)
54 $(QUIETLY) test -d $(services) || mkdir -p $(services)
55 $(QUIETLY) test ! -d $(options) || (cd $(options) && for i in $$(ls); do echo $${i}_Options >> $(abspath $(services))/com.oracle.jvmci.options.Options; done)
56 endef
57
58 # Extracts META-INF/jvmci.services and META-INF/jvmci.options of a JAR file into a given directory
48 # Arguments: 59 # Arguments:
49 # 1: JAR file to extract 60 # 1: JAR file to extract
50 # 2: target directory 61 # 2: target directory
51 define extract 62 define extract
52 $(eval TMP := $(shell mktemp -d $(TARGET)/tmp_XXXXX)) 63 $(eval TMP := $(shell mktemp -d $(TARGET)/tmp_XXXXX))
53 $(QUIETLY) mkdir -p $(2); 64 $(QUIETLY) mkdir -p $(2)
54 $(QUIETLY) cd $(TMP) && $(JAR) xf $(abspath $(1)) && \ 65 $(QUIETLY) cd $(TMP) && $(JAR) xf $(abspath $(1)) && \
55 ((test ! -d .$(SERVICES_INF) || cp -r .$(SERVICES_INF) $(abspath $(2))) && (test ! -d .$(OPTIONS_INF) || cp -r .$(OPTIONS_INF) $(abspath $(2)))); 66 ((test ! -d .$(SERVICES_INF) || cp -r .$(SERVICES_INF) $(abspath $(2))) && \
56 $(QUIETLY) rm -r $(TMP); 67 (test ! -d .$(OPTIONS_INF) || cp -r .$(OPTIONS_INF) $(abspath $(2))))
57 $(QUIETLY) cp $(1) $(2); 68 $(QUIETLY) rm -r $(TMP)
69 $(QUIETLY) cp $(1) $(2)
58 endef 70 endef
59 71
60 # Calls $(JAVAC) with the bootclasspath $(JDK_BOOTCLASSPATH); sources are taken from the automatic variable $^ 72 # Calls $(JAVAC) with the boot class path $(JDK_BOOTCLASSPATH) and sources taken from the automatic variable $^
61 # Arguments: 73 # Arguments:
62 # 1: processorpath 74 # 1: processorpath
63 # 2: classpath 75 # 2: classpath
64 # 3: resources to copy 76 # 3: resources to copy
65 # 4: target JAR file 77 # 4: target JAR file
66 define build_and_jar 78 define build_and_jar
67 $(info Building $(4)) 79 $(info Building $(4))
68 $(eval TMP := $(shell mkdir -p $(TARGET) && mktemp -d $(TARGET)/tmp_XXXXX)) 80 $(eval TMP := $(shell mkdir -p $(TARGET) && mktemp -d $(TARGET)/tmp_XXXXX))
69 $(QUIETLY) $(JAVAC) -d $(TMP) -processorpath :$(1) -bootclasspath $(JDK_BOOTCLASSPATH) -cp :$(2) $(filter %.java,$^); 81 $(QUIETLY) $(JAVAC) -d $(TMP) -processorpath :$(1) -bootclasspath $(JDK_BOOTCLASSPATH) -cp :$(2) $(filter %.java,$^)
70 $(QUIETLY) test "$(3)" = "" || cp -r $(3) $(TMP); 82 $(QUIETLY) test "$(3)" = "" || cp -r $(3) $(TMP)
71 $(QUIETLY) $(call process_options,$(TMP)); 83 $(QUIETLY) $(call process_options,$(TMP))
84 $(QUIETLY) $(call process_providers,$(TMP))
72 $(QUIETLY) mkdir -p $(shell dirname $(4)) 85 $(QUIETLY) mkdir -p $(shell dirname $(4))
73 $(QUIETLY) $(JAR) cf $(4) -C $(TMP) . 86 $(QUIETLY) $(JAR) cf $(4) -C $(TMP) .
74 $(QUIETLY) rm -r $(TMP); 87 $(QUIETLY) rm -r $(TMP)
75 endef 88 endef
76 89
77 # Verifies if the defs.make contain the exported files of services/ 90 # Verifies that make/defs.make contains a line for each file in a list of files.
78 define verify_export_def_make 91 # Arguments:
79 $(foreach file,$(1),$(if $(shell grep '$(2)$(file)' $(3) > /dev/null && echo found), , $(error "Pattern '$(2)$(file)' not found in $(3)"))) 92 # 1: list of files
93 # 2: prefix to apply to each file to create match pattern
94 define verify_defs_make
95 $(eval defs=make/defs.make)
96 $(foreach file,$(1),$(if $(shell grep '$(2)$(file)' $(defs) > /dev/null && echo found), , $(error "Pattern '$(2)$(file)' not found in $(defs)")))
80 endef 97 endef
81 98
82 all: default 99 all: default
83 100
84 export: all 101 export: all
85 $(info Put $(EXPORTED_FILES) into SHARED_DIR $(SHARED_DIR)) 102 $(info Put $(EXPORTED_FILES) into SHARED_DIR $(SHARED_DIR))
86 $(QUIETLY) mkdir -p $(SHARED_DIR) 103 $(QUIETLY) mkdir -p $(SHARED_DIR)
87 $(foreach export,$(EXPORTED_FILES),$(call extract,$(export),$(SHARED_DIR))) 104 $(foreach export,$(EXPORTED_FILES),$(call extract,$(export),$(SHARED_DIR)))
88 $(call verify_export_def_make,$(notdir $(wildcard $(SHARED_DIR)/services/*)),EXPORT_LIST += $$(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/,make/defs.make) 105 $(call verify_defs_make,$(notdir $(wildcard $(SHARED_DIR)/jvmci.services/*)),EXPORT_LIST += $$(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/)
89 $(call verify_export_def_make,$(notdir $(wildcard $(SHARED_DIR)/options/*)),EXPORT_LIST += $$(EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)/,make/defs.make) 106 $(call verify_defs_make,$(notdir $(wildcard $(SHARED_DIR)/jvmci.options/*)),EXPORT_LIST += $$(EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)/)
90 .PHONY: export 107 .PHONY: export
91 108
92 109
93 110
94 JDK_BOOTCLASSPATH = $(ABS_BOOTDIR)/jre/lib/resources.jar:$(ABS_BOOTDIR)/jre/lib/rt.jar:$(ABS_BOOTDIR)/jre/lib/jsse.jar:$(ABS_BOOTDIR)/jre/lib/jce.jar:$(ABS_BOOTDIR)/jre/lib/charsets.jar:$(ABS_BOOTDIR)/jre/lib/jfr.jar 111 JDK_BOOTCLASSPATH = $(ABS_BOOTDIR)/jre/lib/resources.jar:$(ABS_BOOTDIR)/jre/lib/rt.jar:$(ABS_BOOTDIR)/jre/lib/jsse.jar:$(ABS_BOOTDIR)/jre/lib/jce.jar:$(ABS_BOOTDIR)/jre/lib/charsets.jar:$(ABS_BOOTDIR)/jre/lib/jfr.jar