diff options
author | Dan Willemsen <dwillemsen@google.com> | 2016-05-13 14:05:09 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2016-05-13 15:07:37 -0700 |
commit | 9f0b550a1584dbd90fd763e99d2b87abf87395a8 (patch) | |
tree | cd1a9ffe2bb36a7ae6fbe43853e8049d235228bc | |
parent | 2630213418aa7523ffabfd79c8ac9de3dde53767 (diff) | |
download | build_soong-9f0b550a1584dbd90fd763e99d2b87abf87395a8.tar.gz build_soong-9f0b550a1584dbd90fd763e99d2b87abf87395a8.tar.bz2 build_soong-9f0b550a1584dbd90fd763e99d2b87abf87395a8.zip |
Create empty .a on Darwin when there is no obj file.
On Darwin ar would fail if there is no object file to add.
We work around by adding a dummy.o.
Port to Soong of build/ 4aaa1a1fd8e7eb23ac5557cd326d1a48efdb54cd
Change-Id: I68bbebea2726058c25863d7026a645a520d05167
-rw-r--r-- | cc/builder.go | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/cc/builder.go b/cc/builder.go index b97f29b8..cd12635a 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -88,7 +88,7 @@ var ( darwinAppendAr = pctx.StaticRule("darwinAppendAr", blueprint.RuleParams{ Command: "cp -f ${inAr} ${out}.tmp && ${macArPath} $arFlags ${out}.tmp $in && mv ${out}.tmp ${out}", - CommandDeps: []string{"${macArPath}"}, + CommandDeps: []string{"${macArPath}", "${inAr}"}, Description: "ar $out", }, "arFlags", "inAr") @@ -120,6 +120,12 @@ var ( }, "args", "crossCompile") + emptyFile = pctx.StaticRule("emptyFile", + blueprint.RuleParams{ + Command: "rm -f $out && touch $out", + Description: "empty file $out", + }) + copyGccLibPath = pctx.SourcePathVariable("copyGccLibPath", "build/soong/scripts/copygcclib.sh") copyGccLib = pctx.StaticRule("copyGccLib", @@ -261,6 +267,37 @@ func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles com arFlags := "cqs" + if len(objFiles) == 0 { + dummy := common.PathForModuleOut(ctx, "dummy" + objectExtension) + dummyAr := common.PathForModuleOut(ctx, "dummy" + staticLibraryExtension) + + ctx.ModuleBuild(pctx, common.ModuleBuildParams{ + Rule: emptyFile, + Output: dummy, + }) + + ctx.ModuleBuild(pctx, common.ModuleBuildParams{ + Rule: darwinAr, + Output: dummyAr, + Input: dummy, + Args: map[string]string{ + "arFlags": arFlags, + }, + }) + + ctx.ModuleBuild(pctx, common.ModuleBuildParams{ + Rule: darwinAppendAr, + Output: outputPath, + Input: dummy, + Args: map[string]string{ + "arFlags": "d", + "inAr": dummyAr.String(), + }, + }) + + return + } + // ARG_MAX on darwin is 262144, use half that to be safe objFilesLists, err := splitListForSize(objFiles.Strings(), 131072) if err != nil { @@ -291,7 +328,6 @@ func TransformDarwinObjToStaticLib(ctx common.AndroidModuleContext, objFiles com Rule: darwinAppendAr, Outputs: []string{out}, Inputs: l, - Implicits: []string{in}, Args: map[string]string{ "arFlags": arFlags, "inAr": in, |