Fix stripping on Darwin

am: b8ecdfe039

* commit 'b8ecdfe0398c4d43178b433bea2d6c9d0c4fd509':
  Fix stripping on Darwin

Change-Id: I6b555d65c968ed338abea406540ed992771da983
This commit is contained in:
Colin Cross
2016-05-04 02:40:04 +00:00
committed by android-build-merger
3 changed files with 36 additions and 13 deletions

View File

@@ -79,19 +79,26 @@ var (
darwinAr = pctx.StaticRule("darwinAr",
blueprint.RuleParams{
Command: "rm -f ${out} && $arCmd $arFlags $out $in",
CommandDeps: []string{"$arCmd"},
Command: "rm -f ${out} && ${macArPath} $arFlags $out $in",
CommandDeps: []string{"${macArPath}"},
Description: "ar $out",
},
"arCmd", "arFlags")
"arFlags")
darwinAppendAr = pctx.StaticRule("darwinAppendAr",
blueprint.RuleParams{
Command: "cp -f ${inAr} ${out}.tmp && $arCmd $arFlags ${out}.tmp $in && mv ${out}.tmp ${out}",
CommandDeps: []string{"$arCmd"},
Command: "cp -f ${inAr} ${out}.tmp && ${macArPath} $arFlags ${out}.tmp $in && mv ${out}.tmp ${out}",
CommandDeps: []string{"${macArPath}"},
Description: "ar $out",
},
"arCmd", "arFlags", "inAr")
"arFlags", "inAr")
darwinStrip = pctx.StaticRule("darwinStrip",
blueprint.RuleParams{
Command: "${macStripPath} -u -r -o $out $in",
CommandDeps: []string{"${macStripPath}"},
Description: "strip $out",
})
prefixSymbols = pctx.StaticRule("prefixSymbols",
blueprint.RuleParams{
@@ -252,7 +259,6 @@ func TransformObjToStaticLib(ctx common.AndroidModuleContext, objFiles common.Pa
func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles common.Paths,
flags builderFlags, outputPath common.ModuleOutPath) {
arCmd := "${macArPath}"
arFlags := "cqs"
// ARG_MAX on darwin is 262144, use half that to be safe
@@ -278,7 +284,6 @@ func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles com
Inputs: l,
Args: map[string]string{
"arFlags": arFlags,
"arCmd": arCmd,
},
})
} else {
@@ -289,7 +294,6 @@ func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles com
Implicits: []string{in},
Args: map[string]string{
"arFlags": arFlags,
"arCmd": arCmd,
"inAr": in,
},
})
@@ -439,6 +443,16 @@ func TransformStrip(ctx common.AndroidModuleContext, inputFile common.Path,
})
}
func TransformDarwinStrip(ctx common.AndroidModuleContext, inputFile common.Path,
outputFile common.WritablePath) {
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
Rule: darwinStrip,
Output: outputFile,
Input: inputFile,
})
}
func CopyGccLib(ctx common.AndroidModuleContext, libName string,
flags builderFlags, outputFile common.WritablePath) {

View File

@@ -1979,10 +1979,14 @@ func (stripper *stripper) needsStrip(ctx ModuleContext) bool {
func (stripper *stripper) strip(ctx ModuleContext, in, out common.ModuleOutPath,
flags builderFlags) {
flags.stripKeepSymbols = stripper.StripProperties.Strip.Keep_symbols
// TODO(ccross): don't add gnu debuglink for user builds
flags.stripAddGnuDebuglink = true
TransformStrip(ctx, in, out, flags)
if ctx.Darwin() {
TransformDarwinStrip(ctx, in, out)
} else {
flags.stripKeepSymbols = stripper.StripProperties.Strip.Keep_symbols
// TODO(ccross): don't add gnu debuglink for user builds
flags.stripAddGnuDebuglink = true
TransformStrip(ctx, in, out, flags)
}
}
func testPerSrcMutator(mctx common.AndroidBottomUpMutatorContext) {

View File

@@ -105,6 +105,11 @@ func init() {
return strings.TrimSpace(string(bytes)), err
})
pctx.VariableFunc("macStripPath", func(config interface{}) (string, error) {
bytes, err := exec.Command("xcrun", "--find", "strip").Output()
return strings.TrimSpace(string(bytes)), err
})
pctx.StaticVariable("darwinGccVersion", darwinGccVersion)
pctx.SourcePathVariable("darwinGccRoot",
"prebuilts/gcc/${HostPrebuiltTag}/host/i686-apple-darwin-${darwinGccVersion}")