Rework stripping binaries when copying to containers
We now only attempt to strip binaries, by detecting the LINKFLAGS variable on the targets. CopySetHaikuRevision now also forwards LINKFLAGS to revisioned binaries. Introduce separate AppendToContainerCopyFilesScriptStripFile actions which are used for copying and stripping, and avoids many useless shell tests. When asked to strip binaries, they are detected and handled individually for simplicity. Note we still don't keep resources and attributes when stripping.
This commit is contained in:
parent
e986f5fce9
commit
e2332987bc
@ -341,6 +341,11 @@ rule CopySetHaikuRevision target : source
|
||||
|
||||
PropagateContainerUpdateTargetFlags $(target) : $(source) ;
|
||||
|
||||
if [ on $(source) return $(LINKFLAGS) ] {
|
||||
# hint the target as a (strippable) binary
|
||||
LINKFLAGS on $(target) = [ on $(source) return $(LINKFLAGS) ] ;
|
||||
}
|
||||
|
||||
local revisionFile = [ DetermineHaikuRevision ] ;
|
||||
|
||||
Depends $(target)
|
||||
|
@ -676,24 +676,32 @@ rule CreateContainerCopyFilesScript container : script
|
||||
# concurrent writes to the script file when building with multiple
|
||||
# jobs.
|
||||
|
||||
local needStrip = [ on $(container)
|
||||
return $(HAIKU_CONTAINER_STRIP_BINARIES) ] ;
|
||||
# We are asked to strip the binaries when copying them.
|
||||
|
||||
local dir ;
|
||||
for dir in [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] {
|
||||
# filter the targets that shall be renamed; they have to be copied
|
||||
# individually
|
||||
# we also handle binary separately when asked to strip them
|
||||
local destTargets = [ on $(dir) return $(TARGETS_TO_INSTALL) ] ;
|
||||
local remainingTargets ;
|
||||
local destTarget ;
|
||||
for destTarget in $(destTargets) {
|
||||
local target = [ on $(destTarget) return $(TARGET) ] ;
|
||||
local name = $(destTarget:G=) ;
|
||||
if $(name) != $(target:BS) {
|
||||
local isBinary = [ on $(target) return $(LINKFLAGS) ] ;
|
||||
local doStrip ;
|
||||
if $(needStrip) && $(isBinary) {
|
||||
doStrip = 1 ;
|
||||
}
|
||||
if $(name) != $(target:BS) || $(doStrip) {
|
||||
# use a unique dummy target for this file, on which we
|
||||
# can define the TARGET_DIR variable
|
||||
local dummyTarget = $(script)-dummy-$(dir:G=)-$(target) ;
|
||||
NotFile $(dummyTarget) ;
|
||||
TARGET_DIR on $(dummyTarget) = $(dir:G=) ;
|
||||
DO_STRIP on $(dummyTarget) = [ on $(container)
|
||||
return $(HAIKU_CONTAINER_STRIP_BINARIES) ] ;
|
||||
|
||||
local nameFunction
|
||||
= [ on $(destTarget) return $(NAME_FUNCTION) ] ;
|
||||
@ -709,8 +717,13 @@ rule CreateContainerCopyFilesScript container : script
|
||||
Depends $(script) : $(dummyTarget) ;
|
||||
serializationDependency = $(dummyTarget) ;
|
||||
|
||||
AppendToContainerCopyFilesScriptSingleFile $(dummyTarget)
|
||||
: $(initScript) $(target) ;
|
||||
if $(doStrip) {
|
||||
AppendToContainerCopyFilesScriptStripFile $(dummyTarget)
|
||||
: $(initScript) $(target) ;
|
||||
} else {
|
||||
AppendToContainerCopyFilesScriptSingleFile $(dummyTarget)
|
||||
: $(initScript) $(target) ;
|
||||
}
|
||||
} else {
|
||||
remainingTargets += $(target) ;
|
||||
}
|
||||
@ -723,8 +736,6 @@ rule CreateContainerCopyFilesScript container : script
|
||||
local dummyTarget = $(script)-dummy-$(dir:G=) ;
|
||||
NotFile $(dummyTarget) ;
|
||||
TARGET_DIR on $(dummyTarget) = $(dir:G=) ;
|
||||
DO_STRIP on $(dummyTarget) = [ on $(container)
|
||||
return $(HAIKU_CONTAINER_STRIP_BINARIES) ] ;
|
||||
|
||||
Depends $(dummyTarget) : $(initScript) $(targets)
|
||||
$(serializationDependency) ;
|
||||
@ -767,11 +778,6 @@ actions piecemeal AppendToContainerCopyFilesScript bind OUTPUT_SCRIPT
|
||||
{
|
||||
echo \$cp "\"\${sPrefix}$(2)\"" "\"\${tPrefix}$(TARGET_DIR)\"" \
|
||||
>> $(OUTPUT_SCRIPT)
|
||||
|
||||
if [ -n "$(DO_STRIP:E)" ]; then
|
||||
echo \$strip "\"\${tPrefix}$(TARGET_DIR)/$(2:BS)\"" "2>/dev/null" \
|
||||
"|| true" >> $(OUTPUT_SCRIPT)
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@ -784,11 +790,21 @@ actions AppendToContainerCopyFilesScriptSingleFile
|
||||
|
||||
echo \$cp "\"\${sPrefix}$(2[2])\"" \
|
||||
"\"\${tPrefix}$(TARGET_DIR)/$(INSTALL_TARGET_NAME)\"" >> $(2[1])
|
||||
}
|
||||
|
||||
if [ -n "$(DO_STRIP:E)" ]; then
|
||||
echo \$strip "\"\${tPrefix}$(TARGET_DIR)/$(INSTALL_TARGET_NAME)\"" \
|
||||
"2>/dev/null" "|| true" >> $(2[1])
|
||||
|
||||
actions AppendToContainerCopyFilesScriptStripFile
|
||||
{
|
||||
if [ -n "$(NAME_FUNCTION:E)" ]; then
|
||||
echo "name=\`$(NAME_FUNCTION:E) \"$(2[2])\" 2> /dev/null \` || exit 1" \
|
||||
>> $(2[1])
|
||||
fi
|
||||
|
||||
echo \$cp "\"\${sPrefix}$(2[2])\"" \
|
||||
"\"\${tPrefix}$(TARGET_DIR)/$(INSTALL_TARGET_NAME)\"" >> $(2[1])
|
||||
|
||||
echo \$strip "\"\${tPrefix}$(TARGET_DIR)/$(INSTALL_TARGET_NAME)\"" \
|
||||
"2>/dev/null" "|| true" >> $(2[1])
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user