make/common/Rules.gmk

changeset 118
2aa5665d86a5
parent 117
31ce3cac3cc1
child 158
91006f157c46
equal deleted inserted replaced
117:31ce3cac3cc1 118:2aa5665d86a5
26 # 26 #
27 # 27 #
28 # Rules shared by all Java makefiles. 28 # Rules shared by all Java makefiles.
29 # 29 #
30 30
31 # Used with wildcard to look into a java package for files (assumes max 5 deep)
32 _WC_DIRS = * */* */*/* */*/*/* */*/*/*/*
33
34 # Make sure the default rule is all 31 # Make sure the default rule is all
35 rules_default_rule: all 32 rules_default_rule: all
36 33
37 # 34 #
38 # Directory set up. (Needed by deploy workspace) 35 # Directory set up. (Needed by deploy workspace)
47 44
48 # 45 #
49 # If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files 46 # If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files
50 # 47 #
51 ifdef AUTO_FILES_PROPERTIES_DIRS 48 ifdef AUTO_FILES_PROPERTIES_DIRS
52 # Wildcard all possible properties files 49 AUTO_FILES_PROPERTIES_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' ',*'
53 _WC_PROP_FILES = $(patsubst %, %/*.properties, $(_WC_DIRS)) 50 AUTO_FILES_PROPERTIES_FILTERS1 += $(AUTO_PROPERTIES_PRUNE)
54 # Wildcard package directories for this Makefile 51 FILES_properties_find_filters1 = $(AUTO_FILES_PROPERTIES_FILTERS1:%=-name % -prune -o)
55 _AUTO_WC_PROP_FILES = $(foreach dir, $(AUTO_FILES_PROPERTIES_DIRS), \ 52 FILES_properties_auto1 := \
56 $(patsubst %, $(dir)/%, $(_WC_PROP_FILES)) ) 53 $(shell \
57 # Wildcard all source directories 54 for dir in $(ALL_CLASSES_SRC) ; do \
58 _AUTO_WC_ALL_PROP_FILES1 = $(foreach dir, $(ALL_CLASSES_SRC), \ 55 if [ -d $$dir ] ; then \
59 $(patsubst %, $(dir)/%, $(_AUTO_WC_PROP_FILES)) ) 56 ( $(CD) $$dir; \
60 # Find all files meeting this pattern 57 for sdir in $(AUTO_FILES_PROPERTIES_DIRS); do \
61 FILES_properties_auto1 := $(wildcard $(_AUTO_WC_ALL_PROP_FILES1)) 58 if [ -d $$sdir ] ; then \
59 $(FIND) $$sdir $(FILES_properties_find_filters1) \
60 -name '*.properties' -print ; \
61 fi ; \
62 done \
63 ); \
64 fi; \
65 done \
66 )
62 else 67 else
63 FILES_properties_auto1 = 68 FILES_properties_auto1 =
64 endif # AUTO_FILES_PROPERTIES_DIRS 69 endif # AUTO_FILES_PROPERTIES_DIRS
65 70
66 # Add any automatically found properties files to the properties file list 71 # Add any automatically found properties files to the properties file list
86 # and since they could be generated late, we need to be careful that 91 # and since they could be generated late, we need to be careful that
87 # we look for these sources late and not use the ':=' assignment which 92 # we look for these sources late and not use the ':=' assignment which
88 # might miss their generation. 93 # might miss their generation.
89 94
90 ifdef AUTO_FILES_JAVA_DIRS 95 ifdef AUTO_FILES_JAVA_DIRS
91 # Wildcard all possible java files 96 # Filter out these files or directories
92 _WC_JAVA_FILES = $(patsubst %, %/*.java, $(_WC_DIRS)) 97 AUTO_FILES_JAVA_SOURCE_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' '*-template.java' ',*'
93 # Wildcard package directories for this Makefile 98 AUTO_FILES_JAVA_SOURCE_FILTERS2 =
94 _AUTO_WC_JAVA_FILES = $(foreach dir, $(AUTO_FILES_JAVA_DIRS), \ 99 AUTO_FILES_JAVA_SOURCE_FILTERS1 += $(AUTO_JAVA_PRUNE)
95 $(patsubst %, $(dir)/%, $(_WC_JAVA_FILES)) ) 100 AUTO_FILES_JAVA_SOURCE_FILTERS2 += $(AUTO_JAVA_PRUNE)
96 # Wildcard all source directories 101
97 _AUTO_WC_ALL_JAVA_FILES1 = $(foreach dir, $(ALL_CLASSES_SRC), \ 102 # First list is the normal sources that should always be there,
98 $(patsubst %, $(dir)/%, $(_AUTO_WC_JAVA_FILES)) ) 103 # by using the ':=', which means we do this processing once.
99 # Find all files meeting this pattern 104 FILES_java_find_filters1 = $(AUTO_FILES_JAVA_SOURCE_FILTERS1:%=-name % -prune -o)
100 FILES_java_auto1 := $(wildcard $(_AUTO_WC_ALL_JAVA_FILES1)) 105 FILES_java_auto1 := \
101 106 $(shell \
107 for dir in $(ALL_CLASSES_SRC) ; do \
108 if [ -d $$dir ] ; then \
109 ( $(CD) $$dir; \
110 for sdir in $(AUTO_FILES_JAVA_DIRS); do \
111 if [ -d $$sdir ] ; then \
112 $(FIND) $$sdir $(FILES_java_find_filters1) \
113 -name '*.java' -print ; \
114 fi ; \
115 done \
116 ); \
117 fi; \
118 done \
119 )
102 # Second list is the generated sources that should be rare, but will likely 120 # Second list is the generated sources that should be rare, but will likely
103 # show up late and we need to look for them at the last minute, so we 121 # show up late and we need to look for them at the last minute, so we
104 # cannot use the ':=' assigment here. But if this gets expanded multiple 122 # cannot use the ':=' assigment here. But if this gets expanded multiple
105 # times, the if tests should make them relatively cheap. 123 # times, the if tests should make them relatively cheap.
106 # Wildcard the generated source directories 124 FILES_java_find_filters2 = $(AUTO_FILES_JAVA_SOURCE_FILTERS2:%=-name % -prune -o)
107 _AUTO_WC_ALL_JAVA_FILES2 = $(patsubst %, $(GENSRCDIR)/%, $(_AUTO_WC_JAVA_FILES)) 125 FILES_java_auto2 = \
108 # Find all files meeting this pattern 126 $(shell \
109 FILES_java_auto2 = $(wildcard $(_AUTO_WC_ALL_JAVA_FILES2)) 127 for dir in $(GENSRCDIR); do \
128 if [ -d $$dir ] ; then \
129 ( $(CD) $$dir; \
130 for sdir in $(AUTO_FILES_JAVA_DIRS); do \
131 if [ -d $$sdir ] ; then \
132 $(FIND) $$sdir $(FILES_java_find_filters2) \
133 -name '*.java' -print ; \
134 fi ; \
135 done \
136 ); \
137 fi; \
138 done \
139 )
110 else 140 else
111 FILES_java_auto1 = 141 FILES_java_auto1 =
112 FILES_java_auto2 = 142 FILES_java_auto2 =
113 endif 143 endif
114 144
154 JAVAC_PREFER_SOURCE = -Xprefer:source 184 JAVAC_PREFER_SOURCE = -Xprefer:source
155 185
156 .compile.classlist : $(JAVA_SOURCE_LIST) 186 .compile.classlist : $(JAVA_SOURCE_LIST)
157 @$(MKDIR) -p $(CLASSDESTDIR) 187 @$(MKDIR) -p $(CLASSDESTDIR)
158 if [ -s $(JAVA_SOURCE_LIST) ] ; then \ 188 if [ -s $(JAVA_SOURCE_LIST) ] ; then \
159 $(CAT) $(JAVA_SOURCE_LIST); \ 189 $(CAT) $(JAVA_SOURCE_LIST); \
160 $(JAVAC_CMD) $(JAVAC_PREFER_SOURCE) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \ 190 $(JAVAC_CMD) $(JAVAC_PREFER_SOURCE) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \
161 fi 191 fi
162 @$(java-vm-cleanup) 192 @$(java-vm-cleanup)
163 193
164 clobber clean:: 194 clobber clean::

mercurial