1.1 --- a/make/common/Rules.gmk Tue Sep 01 23:44:41 2009 +0100 1.2 +++ b/make/common/Rules.gmk Wed Sep 02 09:20:17 2009 -0700 1.3 @@ -27,17 +27,9 @@ 1.4 # 1.5 # Rules shared by all Java makefiles. 1.6 # 1.7 -# Used to apply to source file $<, checks code conventions, issues warnings. 1.8 -define check-conventions 1.9 - if [ "$(CONVENTION_WATCH)" = "true" ] ; then \ 1.10 - if [ "`$(CAT) -n -v -t $< | $(EGREP) -v '\@\(\#\)' | $(EGREP) '\^[MLI]'`" != "" ] ; then \ 1.11 - $(ECHO) "WARNING: File contains tabs, ^M, or ^L characters: $<"; \ 1.12 - if [ "$(CONVENTION_DETAILS)" = "true" ] ; then \ 1.13 - $(CAT) -n -v -t $< | $(EGREP) -v '\@\(\#\)' | $(EGREP) '\^[MLI]' ; \ 1.14 - fi; \ 1.15 - fi; \ 1.16 - fi 1.17 -endef 1.18 + 1.19 +# Used with wildcard to look into a java package for files (assumes max 5 deep) 1.20 +_WC_DIRS = * */* */*/* */*/*/* */*/*/*/* 1.21 1.22 # Make sure the default rule is all 1.23 rules_default_rule: all 1.24 @@ -57,24 +49,16 @@ 1.25 # If AUTO_FILES_PROPERTIES_DIRS used, automatically find properties files 1.26 # 1.27 ifdef AUTO_FILES_PROPERTIES_DIRS 1.28 - AUTO_FILES_PROPERTIES_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' ',*' 1.29 - AUTO_FILES_PROPERTIES_FILTERS1 += $(AUTO_PROPERTIES_PRUNE) 1.30 - FILES_properties_find_filters1 = $(AUTO_FILES_PROPERTIES_FILTERS1:%=-name % -prune -o) 1.31 - FILES_properties_auto1 := \ 1.32 - $(shell \ 1.33 - for dir in $(ALL_CLASSES_SRC) ; do \ 1.34 - if [ -d $$dir ] ; then \ 1.35 - ( $(CD) $$dir; \ 1.36 - for sdir in $(AUTO_FILES_PROPERTIES_DIRS); do \ 1.37 - if [ -d $$sdir ] ; then \ 1.38 - $(FIND) $$sdir $(FILES_properties_find_filters1) \ 1.39 - -name '*.properties' -print ; \ 1.40 - fi ; \ 1.41 - done \ 1.42 - ); \ 1.43 - fi; \ 1.44 - done \ 1.45 - ) 1.46 + # Wildcard all possible properties files 1.47 + _WC_PROP_FILES = $(patsubst %, %/*.properties, $(_WC_DIRS)) 1.48 + # Wildcard package directories for this Makefile 1.49 + _AUTO_WC_PROP_FILES = $(foreach dir, $(AUTO_FILES_PROPERTIES_DIRS), \ 1.50 + $(patsubst %, $(dir)/%, $(_WC_PROP_FILES)) ) 1.51 + # Wildcard all source directories 1.52 + _AUTO_WC_ALL_PROP_FILES1 = $(foreach dir, $(ALL_CLASSES_SRC), \ 1.53 + $(patsubst %, $(dir)/%, $(_AUTO_WC_PROP_FILES)) ) 1.54 + # Find all files meeting this pattern 1.55 + FILES_properties_auto1 := $(wildcard $(_AUTO_WC_ALL_PROP_FILES1)) 1.56 else 1.57 FILES_properties_auto1 = 1.58 endif # AUTO_FILES_PROPERTIES_DIRS 1.59 @@ -104,50 +88,25 @@ 1.60 # might miss their generation. 1.61 1.62 ifdef AUTO_FILES_JAVA_DIRS 1.63 - # Filter out these files or directories 1.64 - AUTO_FILES_JAVA_SOURCE_FILTERS1 = $(SCM_DIRs) 'X-*' '*-X-*' '*-template.java' ',*' 1.65 - AUTO_FILES_JAVA_SOURCE_FILTERS2 = 1.66 - AUTO_FILES_JAVA_SOURCE_FILTERS1 += $(AUTO_JAVA_PRUNE) 1.67 - AUTO_FILES_JAVA_SOURCE_FILTERS2 += $(AUTO_JAVA_PRUNE) 1.68 + # Wildcard all possible java files 1.69 + _WC_JAVA_FILES = $(patsubst %, %/*.java, $(_WC_DIRS)) 1.70 + # Wildcard package directories for this Makefile 1.71 + _AUTO_WC_JAVA_FILES = $(foreach dir, $(AUTO_FILES_JAVA_DIRS), \ 1.72 + $(patsubst %, $(dir)/%, $(_WC_JAVA_FILES)) ) 1.73 + # Wildcard all source directories 1.74 + _AUTO_WC_ALL_JAVA_FILES1 = $(foreach dir, $(ALL_CLASSES_SRC), \ 1.75 + $(patsubst %, $(dir)/%, $(_AUTO_WC_JAVA_FILES)) ) 1.76 + # Find all files meeting this pattern 1.77 + FILES_java_auto1 := $(wildcard $(_AUTO_WC_ALL_JAVA_FILES1)) 1.78 1.79 - # First list is the normal sources that should always be there, 1.80 - # by using the ':=', which means we do this processing once. 1.81 - FILES_java_find_filters1 = $(AUTO_FILES_JAVA_SOURCE_FILTERS1:%=-name % -prune -o) 1.82 - FILES_java_auto1 := \ 1.83 - $(shell \ 1.84 - for dir in $(ALL_CLASSES_SRC) ; do \ 1.85 - if [ -d $$dir ] ; then \ 1.86 - ( $(CD) $$dir; \ 1.87 - for sdir in $(AUTO_FILES_JAVA_DIRS); do \ 1.88 - if [ -d $$sdir ] ; then \ 1.89 - $(FIND) $$sdir $(FILES_java_find_filters1) \ 1.90 - -name '*.java' -print ; \ 1.91 - fi ; \ 1.92 - done \ 1.93 - ); \ 1.94 - fi; \ 1.95 - done \ 1.96 - ) 1.97 # Second list is the generated sources that should be rare, but will likely 1.98 # show up late and we need to look for them at the last minute, so we 1.99 # cannot use the ':=' assigment here. But if this gets expanded multiple 1.100 # times, the if tests should make them relatively cheap. 1.101 - FILES_java_find_filters2 = $(AUTO_FILES_JAVA_SOURCE_FILTERS2:%=-name % -prune -o) 1.102 - FILES_java_auto2 = \ 1.103 - $(shell \ 1.104 - for dir in $(GENSRCDIR); do \ 1.105 - if [ -d $$dir ] ; then \ 1.106 - ( $(CD) $$dir; \ 1.107 - for sdir in $(AUTO_FILES_JAVA_DIRS); do \ 1.108 - if [ -d $$sdir ] ; then \ 1.109 - $(FIND) $$sdir $(FILES_java_find_filters2) \ 1.110 - -name '*.java' -print ; \ 1.111 - fi ; \ 1.112 - done \ 1.113 - ); \ 1.114 - fi; \ 1.115 - done \ 1.116 - ) 1.117 + # Wildcard the generated source directories 1.118 + _AUTO_WC_ALL_JAVA_FILES2 = $(patsubst %, $(GENSRCDIR)/%, $(_AUTO_WC_JAVA_FILES)) 1.119 + # Find all files meeting this pattern 1.120 + FILES_java_auto2 = $(wildcard $(_AUTO_WC_ALL_JAVA_FILES2)) 1.121 else 1.122 FILES_java_auto1 = 1.123 FILES_java_auto2 = 1.124 @@ -162,7 +121,6 @@ 1.125 # Add a java source to the list 1.126 define add-java-file 1.127 $(ECHO) "$?" >> $(JAVA_SOURCE_LIST) 1.128 -$(check-conventions) 1.129 endef 1.130 1.131 $(CLASSDESTDIR)/%.class: $(GENSRCDIR)/%.java 1.132 @@ -197,11 +155,7 @@ 1.133 1.134 .compile.classlist : $(JAVA_SOURCE_LIST) 1.135 @$(MKDIR) -p $(CLASSDESTDIR) 1.136 - @if [ `$(CAT) $(JAVA_SOURCE_LIST) | $(WC) -l` -ge 1 ] ; then \ 1.137 - $(ECHO) "# Java sources to be compiled: (listed in file $(JAVA_SOURCE_LIST))"; \ 1.138 - $(CAT) $(JAVA_SOURCE_LIST); \ 1.139 - $(ECHO) "# Running javac:"; \ 1.140 - $(ECHO) $(JAVAC_CMD) $(JAVAC_PREFER_SOURCE) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \ 1.141 + if [ -s $(JAVA_SOURCE_LIST) ] ; then \ 1.142 $(JAVAC_CMD) $(JAVAC_PREFER_SOURCE) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \ 1.143 fi 1.144 @$(java-vm-cleanup) 1.145 @@ -220,10 +174,7 @@ 1.146 packages.clean: 1.147 ifeq ($(DONT_CLOBBER_CLASSES),false) 1.148 ifdef AUTO_FILES_JAVA_DIRS 1.149 - @for sdir in $(AUTO_FILES_JAVA_DIRS); do \ 1.150 - $(ECHO) "$(RM) -r $(CLASSDESTDIR)/$$sdir"; \ 1.151 - $(RM) -r $(CLASSDESTDIR)/$$sdir; \ 1.152 - done 1.153 + $(RM) -r $(patsubst %, $(CLASSDESTDIR)/%, $(AUTO_FILES_JAVA_DIRS)) 1.154 else 1.155 $(RM) -r $(CLASSDESTDIR)/$(PKGDIR) 1.156 endif 1.157 @@ -259,15 +210,13 @@ 1.158 1.159 $(CLASSHDR_DOTFILE): $(CLASSES_export) 1.160 $(prep-target) 1.161 - @$(ECHO) "# Running javah:" 1.162 $(JAVAH_CMD) -d $(CLASSHDRDIR)/ \ 1.163 $(CLASSES.export) $(subst $$,\$$,$(EXPORTED_inner)) 1.164 @$(java-vm-cleanup) 1.165 @$(TOUCH) $@ 1.166 1.167 classheaders.clean: 1.168 - $(RM) $(CLASSHDR_DOTFILE) 1.169 - $(RM) -r $(CLASSHDRDIR) 1.170 + $(RM) -r $(CLASSHDRDIR) $(CLASSHDR_DOTFILE) 1.171 1.172 else # FILES_export 1.173