changeset 1290:e2a76dfcf308

Reworked strip binaries to eliminate touch files and not try stripping sym link
author erikj
date Fri, 14 Nov 2014 12:32:19 +0100
parents 5e90096ee2b2
children e347139b6cc3
files make/StripBinaries.gmk
diffstat 1 files changed, 49 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/make/StripBinaries.gmk	Thu Nov 13 13:25:14 2014 -0800
+++ b/make/StripBinaries.gmk	Fri Nov 14 12:32:19 2014 +0100
@@ -35,46 +35,65 @@
 MODULES_CMDS_STRIPPED := $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped
 MODULES_LIBS_STRIPPED := $(SUPPORT_OUTPUTDIR)/modules_libs-stripped
 
-# We don't include debug info for executables.
-ALL_CMDS_SRC := $(filter-out %.debuginfo %.diz, \
-    $(call CacheFind, $(SUPPORT_OUTPUTDIR)/modules_cmds))
-ALL_LIBS_SRC := $(call CacheFind, $(SUPPORT_OUTPUTDIR)/modules_libs)
-# On Windows, we don't include it for libs either.
+ifneq ($(POST_STRIP_CMD), )
+  define StripRecipe
+	$(ECHO) Stripping $(LOG_INFO) $(patsubst $(OUTPUT_ROOT)/%,%,$<)
+	$(MKDIR) -p $(@D)
+	$(CP) $< $@.tmp
+	$(CHMOD) u+w $@.tmp
+	$(POST_STRIP_CMD) $@.tmp
+	$(if $(POST_MCS_CMD), $(POST_MCS_CMD) $@.tmp)
+	$(CHMOD) go-w $@.tmp
+	$(MV) $@.tmp $@
+  endef
+else
+  define StripRecipe
+    $(call install-file)
+  endef
+endif
+
+# Don't include debug info for executables.
+ALL_CMDS_SRC := $(filter-out %.debuginfo %.diz %.map %.pdb, \
+    $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_cmds -type f -o -type l))
+COPY_CMDS_SRC := $(filter %.cgi, $(ALL_CMDS_SRC))
+STRIP_CMDS_SRC := $(filter-out $(COPY_CMDS_SRC), $(ALL_CMDS_SRC))
+
+# Make sure symbolic links are copied and not stripped
+COPY_LIBS_SRC := \
+    $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs \
+        \( ! -name '*$(SHARED_LIBRARY_SUFFIX)' -type f \) -o -type l)
+STRIP_LIBS_SRC := \
+    $(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs \
+        -name '*$(SHARED_LIBRARY_SUFFIX)' -type f)
+
+# On Windows, don't include debug info for libs either.
 ifeq ($(OPENJDK_TARGET_OS), windows)
-  ALL_LIBS_SRC := $(filter-out %.diz, $(ALL_LIBS_SRC))
+  COPY_LIBS_SRC := $(filter-out %.diz %.map %.pdb, $(COPY_LIBS_SRC))
 endif
 
+$(eval $(call SetupCopyFiles,STRIP_MODULES_CMDS, \
+    SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds, \
+    DEST := $(MODULES_CMDS_STRIPPED), \
+    FILES := $(STRIP_CMDS_SRC), \
+    MACRO := StripRecipe))
+
 $(eval $(call SetupCopyFiles,COPY_MODULES_CMDS, \
     SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds, \
     DEST := $(MODULES_CMDS_STRIPPED), \
-    FILES := $(ALL_CMDS_SRC)))
+    FILES := $(COPY_CMDS_SRC)))
+
+$(eval $(call SetupCopyFiles,STRIP_MODULES_LIBS, \
+    SRC := $(SUPPORT_OUTPUTDIR)/modules_libs, \
+    DEST := $(MODULES_LIBS_STRIPPED), \
+    FILES := $(STRIP_LIBS_SRC), \
+    MACRO := StripRecipe))
 
 $(eval $(call SetupCopyFiles,COPY_MODULES_LIBS, \
     SRC := $(SUPPORT_OUTPUTDIR)/modules_libs, \
     DEST := $(MODULES_LIBS_STRIPPED), \
-    FILES := $(ALL_LIBS_SRC)))
+    FILES := $(COPY_LIBS_SRC)))
 
-TARGETS += $(COPY_MODULES_CMDS) $(COPY_MODULES_LIBS)
-
-ifneq ($(POST_STRIP_CMD), )
-
-  FILES_TO_STRIP := $(filter-out %.debuginfo %.diz %.cgi, $(COPY_MODULES_CMDS)) \
-      $(filter %$(SHARED_LIBRARY_SUFFIX), $(COPY_MODULES_LIBS))
-
-  STRIP_TOUCH_TARGETS := $(patsubst $(SUPPORT_OUTPUTDIR)/%, \
-      $(SUPPORT_OUTPUTDIR)/_strip/%.stripped, $(FILES_TO_STRIP))
-
-  # Setup a rule for stripping files based on touch files
-  $(SUPPORT_OUTPUTDIR)/_strip/%.stripped: $(SUPPORT_OUTPUTDIR)/%
-	$(ECHO) Stripping $(LOG_INFO) $(patsubst $(OUTPUT_ROOT)/%,%,$<)
-	$(CHMOD) u+w $<
-	$(POST_STRIP_CMD) $<
-	$(if $(POST_MCS_CMD), $(POST_MCS_CMD) $<)
-	$(CHMOD) go-w $<
-	$(MKDIR) -p $(@D)
-	$(TOUCH) $@
-
-  TARGETS += $(STRIP_TOUCH_TARGETS)
-endif
+TARGETS += $(STRIP_MODULES_CMDS) $(COPY_MODULES_CMDS) \
+    $(STRIP_MODULES_LIBS) $(COPY_MODULES_LIBS)
 
 all: $(TARGETS)