Fix stripping on Darwin
am: b8ecdfe039
* commit 'b8ecdfe0398c4d43178b433bea2d6c9d0c4fd509':
Fix stripping on Darwin
Change-Id: I6b555d65c968ed338abea406540ed992771da983
This commit is contained in:
@@ -79,19 +79,26 @@ var (
|
|||||||
|
|
||||||
darwinAr = pctx.StaticRule("darwinAr",
|
darwinAr = pctx.StaticRule("darwinAr",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "rm -f ${out} && $arCmd $arFlags $out $in",
|
Command: "rm -f ${out} && ${macArPath} $arFlags $out $in",
|
||||||
CommandDeps: []string{"$arCmd"},
|
CommandDeps: []string{"${macArPath}"},
|
||||||
Description: "ar $out",
|
Description: "ar $out",
|
||||||
},
|
},
|
||||||
"arCmd", "arFlags")
|
"arFlags")
|
||||||
|
|
||||||
darwinAppendAr = pctx.StaticRule("darwinAppendAr",
|
darwinAppendAr = pctx.StaticRule("darwinAppendAr",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "cp -f ${inAr} ${out}.tmp && $arCmd $arFlags ${out}.tmp $in && mv ${out}.tmp ${out}",
|
Command: "cp -f ${inAr} ${out}.tmp && ${macArPath} $arFlags ${out}.tmp $in && mv ${out}.tmp ${out}",
|
||||||
CommandDeps: []string{"$arCmd"},
|
CommandDeps: []string{"${macArPath}"},
|
||||||
Description: "ar $out",
|
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",
|
prefixSymbols = pctx.StaticRule("prefixSymbols",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
@@ -252,7 +259,6 @@ func TransformObjToStaticLib(ctx common.AndroidModuleContext, objFiles common.Pa
|
|||||||
func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles common.Paths,
|
func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles common.Paths,
|
||||||
flags builderFlags, outputPath common.ModuleOutPath) {
|
flags builderFlags, outputPath common.ModuleOutPath) {
|
||||||
|
|
||||||
arCmd := "${macArPath}"
|
|
||||||
arFlags := "cqs"
|
arFlags := "cqs"
|
||||||
|
|
||||||
// ARG_MAX on darwin is 262144, use half that to be safe
|
// 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,
|
Inputs: l,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"arFlags": arFlags,
|
"arFlags": arFlags,
|
||||||
"arCmd": arCmd,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -289,7 +294,6 @@ func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles com
|
|||||||
Implicits: []string{in},
|
Implicits: []string{in},
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"arFlags": arFlags,
|
"arFlags": arFlags,
|
||||||
"arCmd": arCmd,
|
|
||||||
"inAr": in,
|
"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,
|
func CopyGccLib(ctx common.AndroidModuleContext, libName string,
|
||||||
flags builderFlags, outputFile common.WritablePath) {
|
flags builderFlags, outputFile common.WritablePath) {
|
||||||
|
|
||||||
|
12
cc/cc.go
12
cc/cc.go
@@ -1979,10 +1979,14 @@ func (stripper *stripper) needsStrip(ctx ModuleContext) bool {
|
|||||||
|
|
||||||
func (stripper *stripper) strip(ctx ModuleContext, in, out common.ModuleOutPath,
|
func (stripper *stripper) strip(ctx ModuleContext, in, out common.ModuleOutPath,
|
||||||
flags builderFlags) {
|
flags builderFlags) {
|
||||||
flags.stripKeepSymbols = stripper.StripProperties.Strip.Keep_symbols
|
if ctx.Darwin() {
|
||||||
// TODO(ccross): don't add gnu debuglink for user builds
|
TransformDarwinStrip(ctx, in, out)
|
||||||
flags.stripAddGnuDebuglink = true
|
} else {
|
||||||
TransformStrip(ctx, in, out, flags)
|
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) {
|
func testPerSrcMutator(mctx common.AndroidBottomUpMutatorContext) {
|
||||||
|
@@ -105,6 +105,11 @@ func init() {
|
|||||||
return strings.TrimSpace(string(bytes)), err
|
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.StaticVariable("darwinGccVersion", darwinGccVersion)
|
||||||
pctx.SourcePathVariable("darwinGccRoot",
|
pctx.SourcePathVariable("darwinGccRoot",
|
||||||
"prebuilts/gcc/${HostPrebuiltTag}/host/i686-apple-darwin-${darwinGccVersion}")
|
"prebuilts/gcc/${HostPrebuiltTag}/host/i686-apple-darwin-${darwinGccVersion}")
|
||||||
|
Reference in New Issue
Block a user