2015-01-31 02:27:36 +01:00
|
|
|
// Copyright 2015 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package cc
|
|
|
|
|
|
|
|
// This file generates the final rules for compiling all C/C++. All properties related to
|
|
|
|
// compiling should have been translated into builderFlags or another argument to the Transform*
|
|
|
|
// functions.
|
|
|
|
|
|
|
|
import (
|
2016-07-29 22:44:28 +02:00
|
|
|
"path/filepath"
|
2015-05-01 01:36:18 +02:00
|
|
|
"runtime"
|
2015-01-31 02:27:36 +01:00
|
|
|
"strings"
|
2015-03-26 22:43:45 +01:00
|
|
|
|
|
|
|
"github.com/google/blueprint"
|
2019-06-08 02:58:59 +02:00
|
|
|
"github.com/google/blueprint/pathtools"
|
2016-07-29 22:44:28 +02:00
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/cc/config"
|
2020-04-13 19:21:23 +02:00
|
|
|
"android/soong/remoteexec"
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2015-04-29 03:17:56 +02:00
|
|
|
objectExtension = ".o"
|
2015-01-31 02:27:36 +01:00
|
|
|
staticLibraryExtension = ".a"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2016-05-19 00:37:25 +02:00
|
|
|
pctx = android.NewPackageContext("android/soong/cc")
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to invoke gcc with given command, flags, and dependencies. Outputs a .d depfile.
|
2020-01-27 20:19:44 +01:00
|
|
|
cc = pctx.AndroidRemoteStaticRule("cc", android.RemoteRuleSupports{Goma: true, RBE: true},
|
2015-01-31 02:27:36 +01:00
|
|
|
blueprint.RuleParams{
|
|
|
|
Depfile: "${out}.d",
|
|
|
|
Deps: blueprint.DepsGCC,
|
2020-10-20 07:52:49 +02:00
|
|
|
Command: "$relPwd ${config.CcWrapper}$ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in",
|
2015-11-18 00:27:28 +01:00
|
|
|
CommandDeps: []string{"$ccCmd"},
|
2015-01-31 02:27:36 +01:00
|
|
|
},
|
2015-11-18 00:19:46 +01:00
|
|
|
"ccCmd", "cFlags")
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to invoke gcc with given command and flags, but no dependencies.
|
2020-02-17 09:26:55 +01:00
|
|
|
ccNoDeps = pctx.AndroidStaticRule("ccNoDeps",
|
2019-01-04 08:25:11 +01:00
|
|
|
blueprint.RuleParams{
|
2020-10-20 07:52:49 +02:00
|
|
|
Command: "$relPwd $ccCmd -c $cFlags -o $out $in",
|
2019-01-04 08:25:11 +01:00
|
|
|
CommandDeps: []string{"$ccCmd"},
|
|
|
|
},
|
|
|
|
"ccCmd", "cFlags")
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rules to invoke ld to link binaries. Uses a .rsp file to list dependencies, as there may
|
|
|
|
// be many.
|
2020-04-13 19:21:23 +02:00
|
|
|
ld, ldRE = remoteexec.StaticRules(pctx, "ld",
|
2015-01-31 02:27:36 +01:00
|
|
|
blueprint.RuleParams{
|
2020-04-17 21:03:58 +02:00
|
|
|
Command: "$reTemplate$ldCmd ${crtBegin} @${out}.rsp " +
|
2019-08-02 15:02:20 +02:00
|
|
|
"${libFlags} ${crtEnd} -o ${out} ${ldFlags} ${extraLibFlags}",
|
2015-11-18 00:27:28 +01:00
|
|
|
CommandDeps: []string{"$ldCmd"},
|
2015-03-31 02:47:53 +02:00
|
|
|
Rspfile: "${out}.rsp",
|
|
|
|
RspfileContent: "${in}",
|
2019-03-29 23:55:30 +01:00
|
|
|
// clang -Wl,--out-implib doesn't update its output file if it hasn't changed.
|
|
|
|
Restat: true,
|
2015-01-31 02:27:36 +01:00
|
|
|
},
|
2020-04-17 21:03:58 +02:00
|
|
|
&remoteexec.REParams{
|
|
|
|
Labels: map[string]string{"type": "link", "tool": "clang"},
|
2020-04-13 19:21:23 +02:00
|
|
|
ExecStrategy: "${config.RECXXLinksExecStrategy}",
|
2020-08-28 20:21:55 +02:00
|
|
|
Inputs: []string{"${out}.rsp", "$implicitInputs"},
|
2020-04-13 19:21:23 +02:00
|
|
|
RSPFile: "${out}.rsp",
|
2020-04-22 22:31:09 +02:00
|
|
|
OutputFiles: []string{"${out}", "$implicitOutputs"},
|
2020-04-13 19:21:23 +02:00
|
|
|
ToolchainInputs: []string{"$ldCmd"},
|
|
|
|
Platform: map[string]string{remoteexec.PoolKey: "${config.RECXXLinksPool}"},
|
2020-08-28 20:21:55 +02:00
|
|
|
}, []string{"ldCmd", "crtBegin", "libFlags", "crtEnd", "ldFlags", "extraLibFlags"}, []string{"implicitInputs", "implicitOutputs"})
|
2020-04-13 19:21:23 +02:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rules for .o files to combine to other .o files, using ld partial linking.
|
2020-04-13 19:21:23 +02:00
|
|
|
partialLd, partialLdRE = remoteexec.StaticRules(pctx, "partialLd",
|
2015-01-31 02:27:36 +01:00
|
|
|
blueprint.RuleParams{
|
2018-01-10 23:30:44 +01:00
|
|
|
// Without -no-pie, clang 7.0 adds -pie to link Android files,
|
|
|
|
// but -r and -pie cannot be used together.
|
2020-04-17 21:03:58 +02:00
|
|
|
Command: "$reTemplate$ldCmd -fuse-ld=lld -nostdlib -no-pie -Wl,-r ${in} -o ${out} ${ldFlags}",
|
2015-11-18 00:27:28 +01:00
|
|
|
CommandDeps: []string{"$ldCmd"},
|
2020-04-13 19:21:23 +02:00
|
|
|
}, &remoteexec.REParams{
|
2020-08-28 20:21:55 +02:00
|
|
|
Labels: map[string]string{"type": "link", "tool": "clang"},
|
|
|
|
ExecStrategy: "${config.RECXXLinksExecStrategy}",
|
|
|
|
Inputs: []string{"$inCommaList", "$implicitInputs"},
|
2020-04-22 22:31:09 +02:00
|
|
|
OutputFiles: []string{"${out}", "$implicitOutputs"},
|
2020-04-13 19:21:23 +02:00
|
|
|
ToolchainInputs: []string{"$ldCmd"},
|
|
|
|
Platform: map[string]string{remoteexec.PoolKey: "${config.RECXXLinksPool}"},
|
2020-08-28 20:21:55 +02:00
|
|
|
}, []string{"ldCmd", "ldFlags"}, []string{"implicitInputs", "inCommaList", "implicitOutputs"})
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to invoke `ar` with given cmd and flags, but no static library depenencies.
|
2016-08-30 01:14:13 +02:00
|
|
|
ar = pctx.AndroidStaticRule("ar",
|
2015-01-31 02:27:36 +01:00
|
|
|
blueprint.RuleParams{
|
2015-03-31 02:47:53 +02:00
|
|
|
Command: "rm -f ${out} && $arCmd $arFlags $out @${out}.rsp",
|
2015-11-18 00:27:28 +01:00
|
|
|
CommandDeps: []string{"$arCmd"},
|
2015-03-31 02:47:53 +02:00
|
|
|
Rspfile: "${out}.rsp",
|
|
|
|
RspfileContent: "${in}",
|
2015-01-31 02:27:36 +01:00
|
|
|
},
|
|
|
|
"arCmd", "arFlags")
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to invoke `ar` with given cmd, flags, and library dependencies. Generates a .a
|
|
|
|
// (archive) file from .o files.
|
2020-04-17 18:34:31 +02:00
|
|
|
arWithLibs = pctx.AndroidStaticRule("arWithLibs",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: "rm -f ${out} && $arCmd $arObjFlags $out @${out}.rsp && $arCmd $arLibFlags $out $arLibs",
|
|
|
|
CommandDeps: []string{"$arCmd"},
|
|
|
|
Rspfile: "${out}.rsp",
|
|
|
|
RspfileContent: "${arObjs}",
|
|
|
|
},
|
|
|
|
"arCmd", "arObjFlags", "arObjs", "arLibFlags", "arLibs")
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to run objcopy --prefix-symbols (to prefix all symbols in a file with a given string).
|
2016-08-30 01:14:13 +02:00
|
|
|
prefixSymbols = pctx.AndroidStaticRule("prefixSymbols",
|
2015-03-26 22:44:11 +01:00
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: "$objcopyCmd --prefix-symbols=${prefix} ${in} ${out}",
|
2015-11-18 00:27:28 +01:00
|
|
|
CommandDeps: []string{"$objcopyCmd"},
|
2015-03-26 22:44:11 +01:00
|
|
|
},
|
|
|
|
"objcopyCmd", "prefix")
|
|
|
|
|
2017-03-27 23:27:58 +02:00
|
|
|
_ = pctx.SourcePathVariable("stripPath", "build/soong/scripts/strip.sh")
|
2018-03-09 19:47:52 +01:00
|
|
|
_ = pctx.SourcePathVariable("xzCmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/xz")
|
2016-04-28 23:50:03 +02:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to invoke `strip` (to discard symbols and data from object files).
|
|
|
|
strip = pctx.AndroidStaticRule("strip",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Depfile: "${out}.d",
|
|
|
|
Deps: blueprint.DepsGCC,
|
|
|
|
Command: "CROSS_COMPILE=$crossCompile XZ=$xzCmd CLANG_BIN=${config.ClangBin} $stripPath ${args} -i ${in} -o ${out} -d ${out}.d",
|
|
|
|
CommandDeps: []string{"$stripPath", "$xzCmd"},
|
|
|
|
Pool: darwinStripPool,
|
|
|
|
},
|
|
|
|
"args", "crossCompile")
|
|
|
|
|
|
|
|
// Rule to invoke `strip` (to discard symbols and data from object files) on darwin architecture.
|
|
|
|
darwinStrip = pctx.AndroidStaticRule("darwinStrip",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: "${config.MacStripPath} -u -r -o $out $in",
|
|
|
|
CommandDeps: []string{"${config.MacStripPath}"},
|
|
|
|
})
|
|
|
|
|
2019-05-18 00:36:46 +02:00
|
|
|
// b/132822437: objcopy uses a file descriptor per .o file when called on .a files, which runs the system out of
|
2019-05-22 22:25:50 +02:00
|
|
|
// file descriptors on darwin. Limit concurrent calls to 5 on darwin.
|
2019-05-18 00:36:46 +02:00
|
|
|
darwinStripPool = func() blueprint.Pool {
|
|
|
|
if runtime.GOOS == "darwin" {
|
|
|
|
return pctx.StaticPool("darwinStripPool", blueprint.PoolParams{
|
2019-05-22 22:25:50 +02:00
|
|
|
Depth: 5,
|
2019-05-18 00:36:46 +02:00
|
|
|
})
|
|
|
|
} else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2019-10-15 11:01:19 +02:00
|
|
|
_ = pctx.SourcePathVariable("archiveRepackPath", "build/soong/scripts/archive_repack.sh")
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to repack an archive (.a) file with a subset of object files.
|
2019-10-15 11:01:19 +02:00
|
|
|
archiveRepack = pctx.AndroidStaticRule("archiveRepack",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Depfile: "${out}.d",
|
|
|
|
Deps: blueprint.DepsGCC,
|
|
|
|
Command: "CLANG_BIN=${config.ClangBin} $archiveRepackPath -i ${in} -o ${out} -d ${out}.d ${objects}",
|
|
|
|
CommandDeps: []string{"$archiveRepackPath"},
|
|
|
|
},
|
|
|
|
"objects")
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to create an empty file at a given path.
|
2016-08-30 01:14:13 +02:00
|
|
|
emptyFile = pctx.AndroidStaticRule("emptyFile",
|
2016-05-13 23:05:09 +02:00
|
|
|
blueprint.RuleParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Command: "rm -f $out && touch $out",
|
2016-05-13 23:05:09 +02:00
|
|
|
})
|
|
|
|
|
2017-03-27 23:27:58 +02:00
|
|
|
_ = pctx.SourcePathVariable("tocPath", "build/soong/scripts/toc.sh")
|
2016-10-01 02:10:16 +02:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// A rule for extracting a table of contents from a shared library (.so).
|
2016-10-01 02:10:16 +02:00
|
|
|
toc = pctx.AndroidStaticRule("toc",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Depfile: "${out}.d",
|
|
|
|
Deps: blueprint.DepsGCC,
|
2018-09-11 01:50:05 +02:00
|
|
|
Command: "CROSS_COMPILE=$crossCompile $tocPath $format -i ${in} -o ${out} -d ${out}.d",
|
2016-10-01 02:10:16 +02:00
|
|
|
CommandDeps: []string{"$tocPath"},
|
|
|
|
Restat: true,
|
|
|
|
},
|
2018-09-11 01:50:05 +02:00
|
|
|
"crossCompile", "format")
|
2016-09-27 00:45:04 +02:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule for invoking clang-tidy (a clang-based linter).
|
2020-06-18 18:17:51 +02:00
|
|
|
clangTidy, clangTidyRE = remoteexec.StaticRules(pctx, "clangTidy",
|
2016-09-27 00:45:04 +02:00
|
|
|
blueprint.RuleParams{
|
2020-06-18 18:17:51 +02:00
|
|
|
Command: "rm -f $out && $reTemplate${config.ClangBin}/clang-tidy $tidyFlags $in -- $cFlags && touch $out",
|
2019-04-05 01:22:37 +02:00
|
|
|
CommandDeps: []string{"${config.ClangBin}/clang-tidy"},
|
2016-09-27 00:45:04 +02:00
|
|
|
},
|
2020-06-18 18:17:51 +02:00
|
|
|
&remoteexec.REParams{
|
|
|
|
Labels: map[string]string{"type": "lint", "tool": "clang-tidy", "lang": "cpp"},
|
|
|
|
ExecStrategy: "${config.REClangTidyExecStrategy}",
|
|
|
|
Inputs: []string{"$in"},
|
|
|
|
// OutputFile here is $in for remote-execution since its possible that
|
|
|
|
// clang-tidy modifies the given input file itself and $out refers to the
|
|
|
|
// ".tidy" file generated for ninja-dependency reasons.
|
2020-08-19 22:51:47 +02:00
|
|
|
OutputFiles: []string{"$in"},
|
|
|
|
Platform: map[string]string{remoteexec.PoolKey: "${config.REClangTidyPool}"},
|
2020-06-18 18:17:51 +02:00
|
|
|
}, []string{"cFlags", "tidyFlags"}, []string{})
|
2016-12-03 02:13:24 +01:00
|
|
|
|
2017-03-27 23:27:58 +02:00
|
|
|
_ = pctx.SourcePathVariable("yasmCmd", "prebuilts/misc/${config.HostPrebuiltTag}/yasm/yasm")
|
2016-12-03 02:13:24 +01:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule for invoking yasm to compile .asm assembly files.
|
2016-12-03 02:13:24 +01:00
|
|
|
yasm = pctx.AndroidStaticRule("yasm",
|
|
|
|
blueprint.RuleParams{
|
2017-08-23 05:53:45 +02:00
|
|
|
Command: "$yasmCmd $asFlags -o $out $in && $yasmCmd $asFlags -M $in >$out.d",
|
2016-12-03 02:13:24 +01:00
|
|
|
CommandDeps: []string{"$yasmCmd"},
|
2017-08-23 05:53:45 +02:00
|
|
|
Depfile: "$out.d",
|
|
|
|
Deps: blueprint.DepsGCC,
|
2016-12-03 02:13:24 +01:00
|
|
|
},
|
|
|
|
"asFlags")
|
2017-02-08 22:45:53 +01:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to invoke windres, for interaction with Windows resources.
|
2017-09-09 10:15:26 +02:00
|
|
|
windres = pctx.AndroidStaticRule("windres",
|
|
|
|
blueprint.RuleParams{
|
2020-01-30 01:20:11 +01:00
|
|
|
Command: "$windresCmd $flags -I$$(dirname $in) -i $in -o $out --preprocessor \"${config.ClangBin}/clang -E -xc-header -DRC_INVOKED\"",
|
2017-09-09 10:15:26 +02:00
|
|
|
CommandDeps: []string{"$windresCmd"},
|
|
|
|
},
|
|
|
|
"windresCmd", "flags")
|
|
|
|
|
2018-02-20 21:36:51 +01:00
|
|
|
_ = pctx.SourcePathVariable("sAbiDumper", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/header-abi-dumper")
|
2017-02-08 22:45:53 +01:00
|
|
|
|
2017-04-20 15:53:59 +02:00
|
|
|
// -w has been added since header-abi-dumper does not need to produce any sort of diagnostic information.
|
2020-04-17 21:03:58 +02:00
|
|
|
sAbiDump, sAbiDumpRE = remoteexec.StaticRules(pctx, "sAbiDump",
|
2017-02-08 22:45:53 +01:00
|
|
|
blueprint.RuleParams{
|
2020-04-17 21:03:58 +02:00
|
|
|
Command: "rm -f $out && $reTemplate$sAbiDumper -o ${out} $in $exportDirs -- $cFlags -w -isystem prebuilts/clang-tools/${config.HostPrebuiltTag}/clang-headers",
|
2017-02-08 22:45:53 +01:00
|
|
|
CommandDeps: []string{"$sAbiDumper"},
|
2020-04-17 21:03:58 +02:00
|
|
|
}, &remoteexec.REParams{
|
|
|
|
Labels: map[string]string{"type": "abi-dump", "tool": "header-abi-dumper"},
|
|
|
|
ExecStrategy: "${config.REAbiDumperExecStrategy}",
|
2020-11-25 22:54:35 +01:00
|
|
|
Inputs: []string{"$sAbiLinkerLibs"},
|
2020-04-17 21:03:58 +02:00
|
|
|
Platform: map[string]string{
|
2020-11-23 23:02:44 +01:00
|
|
|
remoteexec.PoolKey: "${config.RECXXPool}",
|
2020-04-17 21:03:58 +02:00
|
|
|
},
|
|
|
|
}, []string{"cFlags", "exportDirs"}, nil)
|
2017-02-08 22:45:53 +01:00
|
|
|
|
2018-02-20 21:36:51 +01:00
|
|
|
_ = pctx.SourcePathVariable("sAbiLinker", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/header-abi-linker")
|
2020-05-07 12:56:47 +02:00
|
|
|
_ = pctx.SourcePathVariable("sAbiLinkerLibs", "prebuilts/clang-tools/${config.HostPrebuiltTag}/lib64")
|
2017-02-08 22:45:53 +01:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to combine .dump sAbi dump files from multiple source files into a single .ldump
|
|
|
|
// sAbi dump file.
|
2020-05-07 12:56:47 +02:00
|
|
|
sAbiLink, sAbiLinkRE = remoteexec.StaticRules(pctx, "sAbiLink",
|
2017-02-08 22:45:53 +01:00
|
|
|
blueprint.RuleParams{
|
2020-05-07 12:56:47 +02:00
|
|
|
Command: "$reTemplate$sAbiLinker -o ${out} $symbolFilter -arch $arch $exportedHeaderFlags @${out}.rsp ",
|
2017-02-08 22:45:53 +01:00
|
|
|
CommandDeps: []string{"$sAbiLinker"},
|
|
|
|
Rspfile: "${out}.rsp",
|
|
|
|
RspfileContent: "${in}",
|
2020-05-07 12:56:47 +02:00
|
|
|
}, &remoteexec.REParams{
|
|
|
|
Labels: map[string]string{"type": "tool", "name": "abi-linker"},
|
|
|
|
ExecStrategy: "${config.REAbiLinkerExecStrategy}",
|
2020-08-28 20:21:55 +02:00
|
|
|
Inputs: []string{"$sAbiLinkerLibs", "${out}.rsp", "$implicitInputs"},
|
2020-05-07 12:56:47 +02:00
|
|
|
RSPFile: "${out}.rsp",
|
|
|
|
OutputFiles: []string{"$out"},
|
|
|
|
ToolchainInputs: []string{"$sAbiLinker"},
|
|
|
|
Platform: map[string]string{remoteexec.PoolKey: "${config.RECXXPool}"},
|
2020-08-28 20:21:55 +02:00
|
|
|
}, []string{"symbolFilter", "arch", "exportedHeaderFlags"}, []string{"implicitInputs"})
|
2017-02-08 22:45:53 +01:00
|
|
|
|
2018-02-20 21:36:51 +01:00
|
|
|
_ = pctx.SourcePathVariable("sAbiDiffer", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/header-abi-diff")
|
2017-04-20 15:53:59 +02:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to compare linked sAbi dump files (.ldump).
|
2019-09-25 22:31:46 +02:00
|
|
|
sAbiDiff = pctx.RuleFunc("sAbiDiff",
|
2018-03-12 21:24:09 +01:00
|
|
|
func(ctx android.PackageRuleContext) blueprint.RuleParams {
|
2019-10-02 00:58:07 +02:00
|
|
|
commandStr := "($sAbiDiffer ${extraFlags} -lib ${libName} -arch ${arch} -o ${out} -new ${in} -old ${referenceDump})"
|
2019-02-18 06:12:21 +01:00
|
|
|
commandStr += "|| (echo 'error: Please update ABI references with: $$ANDROID_BUILD_TOP/development/vndk/tools/header-checker/utils/create_reference_dumps.py ${createReferenceDumpFlags} -l ${libName}'"
|
2019-01-28 05:14:54 +01:00
|
|
|
commandStr += " && (mkdir -p $$DIST_DIR/abidiffs && cp ${out} $$DIST_DIR/abidiffs/)"
|
2018-02-02 02:23:09 +01:00
|
|
|
commandStr += " && exit 1)"
|
2017-11-27 23:52:21 +01:00
|
|
|
return blueprint.RuleParams{
|
|
|
|
Command: commandStr,
|
|
|
|
CommandDeps: []string{"$sAbiDiffer"},
|
2018-03-12 21:24:09 +01:00
|
|
|
}
|
2017-02-08 22:45:53 +01:00
|
|
|
},
|
2019-10-02 00:58:07 +02:00
|
|
|
"extraFlags", "referenceDump", "libName", "arch", "createReferenceDumpFlags")
|
2017-04-20 15:53:59 +02:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to unzip a reference abi dump.
|
2017-04-20 15:53:59 +02:00
|
|
|
unzipRefSAbiDump = pctx.AndroidStaticRule("unzipRefSAbiDump",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: "gunzip -c $in > $out",
|
|
|
|
})
|
2019-04-24 23:22:25 +02:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to zip files.
|
2019-04-24 23:22:25 +02:00
|
|
|
zip = pctx.AndroidStaticRule("zip",
|
|
|
|
blueprint.RuleParams{
|
2020-08-19 22:51:47 +02:00
|
|
|
Command: "${SoongZipCmd} -o ${out} -C $$OUT_DIR -r ${out}.rsp",
|
2019-04-24 23:22:25 +02:00
|
|
|
CommandDeps: []string{"${SoongZipCmd}"},
|
2020-08-19 22:51:47 +02:00
|
|
|
Rspfile: "${out}.rsp",
|
2019-04-24 23:22:25 +02:00
|
|
|
RspfileContent: "$in",
|
|
|
|
})
|
2018-11-06 01:49:08 +01:00
|
|
|
|
|
|
|
_ = pctx.SourcePathVariable("cxxExtractor",
|
|
|
|
"prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/cxx_extractor")
|
2019-09-27 05:14:28 +02:00
|
|
|
_ = pctx.SourcePathVariable("kytheVnames", "build/soong/vnames.json")
|
2018-11-06 01:49:08 +01:00
|
|
|
_ = pctx.VariableFunc("kytheCorpus",
|
|
|
|
func(ctx android.PackageVarContext) string { return ctx.Config().XrefCorpusName() })
|
2020-01-10 02:34:23 +01:00
|
|
|
_ = pctx.VariableFunc("kytheCuEncoding",
|
|
|
|
func(ctx android.PackageVarContext) string { return ctx.Config().XrefCuEncoding() })
|
2020-11-23 23:02:44 +01:00
|
|
|
|
|
|
|
// Rule to use kythe extractors to generate .kzip files, used to build code cross references.
|
2018-11-06 01:49:08 +01:00
|
|
|
kytheExtract = pctx.StaticRule("kythe",
|
|
|
|
blueprint.RuleParams{
|
2020-01-10 02:34:23 +01:00
|
|
|
Command: `rm -f $out && ` +
|
2020-04-22 02:08:35 +02:00
|
|
|
`KYTHE_CORPUS=${kytheCorpus} ` +
|
|
|
|
`KYTHE_OUTPUT_FILE=$out ` +
|
|
|
|
`KYTHE_VNAMES=$kytheVnames ` +
|
|
|
|
`KYTHE_KZIP_ENCODING=${kytheCuEncoding} ` +
|
|
|
|
`KYTHE_CANONICALIZE_VNAME_PATHS=prefer-relative ` +
|
2020-01-10 02:34:23 +01:00
|
|
|
`$cxxExtractor $cFlags $in `,
|
2019-09-27 05:14:28 +02:00
|
|
|
CommandDeps: []string{"$cxxExtractor", "$kytheVnames"},
|
2018-11-06 01:49:08 +01:00
|
|
|
},
|
|
|
|
"cFlags")
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
2020-05-20 15:03:20 +02:00
|
|
|
func PwdPrefix() string {
|
|
|
|
// Darwin doesn't have /proc
|
|
|
|
if runtime.GOOS != "darwin" {
|
|
|
|
return "PWD=/proc/self/cwd"
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2015-11-18 00:19:46 +01:00
|
|
|
func init() {
|
|
|
|
// We run gcc/clang with PWD=/proc/self/cwd to remove $TOP from the
|
|
|
|
// debug output. That way two builds in two different directories will
|
|
|
|
// create the same output.
|
2020-05-20 15:03:20 +02:00
|
|
|
pctx.StaticVariable("relPwd", PwdPrefix())
|
2019-04-24 23:22:25 +02:00
|
|
|
|
|
|
|
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
|
2020-04-13 19:21:23 +02:00
|
|
|
pctx.Import("android/soong/remoteexec")
|
2015-11-18 00:19:46 +01:00
|
|
|
}
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// builderFlags contains various types of command line flags (and settings) for use in building
|
|
|
|
// build statements related to C++.
|
2015-01-31 02:27:36 +01:00
|
|
|
type builderFlags struct {
|
2020-11-23 23:02:44 +01:00
|
|
|
// Global flags (which build system or toolchain is responsible for). These are separate from
|
|
|
|
// local flags because they should appear first (so that they may be overridden by local flags).
|
2019-11-06 16:06:58 +01:00
|
|
|
globalCommonFlags string
|
|
|
|
globalAsFlags string
|
|
|
|
globalYasmFlags string
|
|
|
|
globalCFlags string
|
|
|
|
globalToolingCFlags string // A separate set of cFlags for clang LibTooling tools
|
|
|
|
globalToolingCppFlags string // A separate set of cppFlags for clang LibTooling tools
|
|
|
|
globalConlyFlags string
|
|
|
|
globalCppFlags string
|
|
|
|
globalLdFlags string
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Local flags (which individual modules are responsible for). These may override global flags.
|
2019-11-06 16:06:58 +01:00
|
|
|
localCommonFlags string
|
|
|
|
localAsFlags string
|
|
|
|
localYasmFlags string
|
|
|
|
localCFlags string
|
|
|
|
localToolingCFlags string // A separate set of cFlags for clang LibTooling tools
|
|
|
|
localToolingCppFlags string // A separate set of cppFlags for clang LibTooling tools
|
|
|
|
localConlyFlags string
|
|
|
|
localCppFlags string
|
|
|
|
localLdFlags string
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
libFlags string // Flags to add to the linker directly after specifying libraries to link.
|
|
|
|
extraLibFlags string // Flags to add to the linker last.
|
|
|
|
tidyFlags string // Flags that apply to clang-tidy
|
|
|
|
sAbiFlags string // Flags that apply to header-abi-dumps
|
|
|
|
aidlFlags string // Flags that apply to aidl source files
|
|
|
|
rsFlags string // Flags that apply to renderscript source files
|
2019-11-06 16:06:58 +01:00
|
|
|
toolchain config.Toolchain
|
2016-04-28 23:50:03 +02:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// True if these extra features are enabled.
|
|
|
|
tidy bool
|
|
|
|
gcovCoverage bool
|
|
|
|
sAbiDump bool
|
|
|
|
emitXrefs bool
|
|
|
|
|
|
|
|
assemblerWithCpp bool // True if .s files should be processed with the c preprocessor.
|
2019-08-28 06:20:40 +02:00
|
|
|
|
2017-03-31 00:03:04 +02:00
|
|
|
systemIncludeFlags string
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// True if static libraries should be grouped (using `-Wl,--start-group` and `-Wl,--end-group`).
|
2016-12-01 23:45:23 +01:00
|
|
|
groupStaticLibs bool
|
|
|
|
|
2019-03-28 22:45:07 +01:00
|
|
|
proto android.ProtoFlags
|
2020-11-23 23:02:44 +01:00
|
|
|
protoC bool // If true, compile protos as `.c` files. Otherwise, output as `.cc`.
|
|
|
|
protoOptionsFile bool // If true, output a proto options file.
|
2019-04-11 07:59:54 +02:00
|
|
|
|
|
|
|
yacc *YaccProperties
|
2020-07-15 10:58:56 +02:00
|
|
|
lex *LexProperties
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// StripFlags represents flags related to stripping. This is separate from builderFlags, as these
|
|
|
|
// flags are useful outside of this package (such as for Rust).
|
2020-08-19 14:53:01 +02:00
|
|
|
type StripFlags struct {
|
|
|
|
Toolchain config.Toolchain
|
|
|
|
StripKeepSymbols bool
|
|
|
|
StripKeepSymbolsList string
|
|
|
|
StripKeepSymbolsAndDebugFrame bool
|
|
|
|
StripKeepMiniDebugInfo bool
|
|
|
|
StripAddGnuDebuglink bool
|
|
|
|
StripUseGnuStrip bool
|
|
|
|
}
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Objects is a collection of file paths corresponding to outputs for C++ related build statements.
|
2016-09-27 02:33:01 +02:00
|
|
|
type Objects struct {
|
2017-02-10 01:16:31 +01:00
|
|
|
objFiles android.Paths
|
|
|
|
tidyFiles android.Paths
|
|
|
|
coverageFiles android.Paths
|
2017-02-08 22:45:53 +01:00
|
|
|
sAbiDumpFiles android.Paths
|
2018-11-06 01:49:08 +01:00
|
|
|
kytheFiles android.Paths
|
2016-09-27 02:33:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a Objects) Copy() Objects {
|
|
|
|
return Objects{
|
2017-02-10 01:16:31 +01:00
|
|
|
objFiles: append(android.Paths{}, a.objFiles...),
|
|
|
|
tidyFiles: append(android.Paths{}, a.tidyFiles...),
|
|
|
|
coverageFiles: append(android.Paths{}, a.coverageFiles...),
|
2017-02-08 22:45:53 +01:00
|
|
|
sAbiDumpFiles: append(android.Paths{}, a.sAbiDumpFiles...),
|
2018-11-06 01:49:08 +01:00
|
|
|
kytheFiles: append(android.Paths{}, a.kytheFiles...),
|
2016-09-27 02:33:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a Objects) Append(b Objects) Objects {
|
|
|
|
return Objects{
|
2017-02-10 01:16:31 +01:00
|
|
|
objFiles: append(a.objFiles, b.objFiles...),
|
|
|
|
tidyFiles: append(a.tidyFiles, b.tidyFiles...),
|
|
|
|
coverageFiles: append(a.coverageFiles, b.coverageFiles...),
|
2017-02-08 22:45:53 +01:00
|
|
|
sAbiDumpFiles: append(a.sAbiDumpFiles, b.sAbiDumpFiles...),
|
2018-11-06 01:49:08 +01:00
|
|
|
kytheFiles: append(a.kytheFiles, b.kytheFiles...),
|
2016-09-27 02:33:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
// Generate rules for compiling multiple .c, .cpp, or .S files to individual .o files
|
2020-11-23 23:02:44 +01:00
|
|
|
func transformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles android.Paths,
|
2018-01-23 19:49:04 +01:00
|
|
|
flags builderFlags, pathDeps android.Paths, cFlagsDeps android.Paths) Objects {
|
2015-04-08 01:50:10 +02:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Source files are one-to-one with tidy, coverage, or kythe files, if enabled.
|
2016-09-27 02:33:01 +02:00
|
|
|
objFiles := make(android.Paths, len(srcFiles))
|
2016-09-27 00:45:04 +02:00
|
|
|
var tidyFiles android.Paths
|
2018-10-08 05:54:34 +02:00
|
|
|
if flags.tidy {
|
2016-09-27 00:45:04 +02:00
|
|
|
tidyFiles = make(android.Paths, 0, len(srcFiles))
|
|
|
|
}
|
2017-02-10 01:16:31 +01:00
|
|
|
var coverageFiles android.Paths
|
2020-04-21 21:40:27 +02:00
|
|
|
if flags.gcovCoverage {
|
2017-02-10 01:16:31 +01:00
|
|
|
coverageFiles = make(android.Paths, 0, len(srcFiles))
|
|
|
|
}
|
2018-11-06 01:49:08 +01:00
|
|
|
var kytheFiles android.Paths
|
|
|
|
if flags.emitXrefs {
|
|
|
|
kytheFiles = make(android.Paths, 0, len(srcFiles))
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2019-11-06 16:06:58 +01:00
|
|
|
// Produce fully expanded flags for use by C tools, C compiles, C++ tools, C++ compiles, and asm compiles
|
|
|
|
// respectively.
|
|
|
|
toolingCflags := flags.globalCommonFlags + " " +
|
|
|
|
flags.globalToolingCFlags + " " +
|
|
|
|
flags.globalConlyFlags + " " +
|
|
|
|
flags.localCommonFlags + " " +
|
|
|
|
flags.localToolingCFlags + " " +
|
|
|
|
flags.localConlyFlags + " " +
|
|
|
|
flags.systemIncludeFlags
|
|
|
|
|
|
|
|
cflags := flags.globalCommonFlags + " " +
|
|
|
|
flags.globalCFlags + " " +
|
|
|
|
flags.globalConlyFlags + " " +
|
|
|
|
flags.localCommonFlags + " " +
|
|
|
|
flags.localCFlags + " " +
|
|
|
|
flags.localConlyFlags + " " +
|
|
|
|
flags.systemIncludeFlags
|
|
|
|
|
|
|
|
toolingCppflags := flags.globalCommonFlags + " " +
|
|
|
|
flags.globalToolingCFlags + " " +
|
|
|
|
flags.globalToolingCppFlags + " " +
|
|
|
|
flags.localCommonFlags + " " +
|
|
|
|
flags.localToolingCFlags + " " +
|
|
|
|
flags.localToolingCppFlags + " " +
|
|
|
|
flags.systemIncludeFlags
|
|
|
|
|
|
|
|
cppflags := flags.globalCommonFlags + " " +
|
|
|
|
flags.globalCFlags + " " +
|
|
|
|
flags.globalCppFlags + " " +
|
|
|
|
flags.localCommonFlags + " " +
|
|
|
|
flags.localCFlags + " " +
|
|
|
|
flags.localCppFlags + " " +
|
|
|
|
flags.systemIncludeFlags
|
|
|
|
|
|
|
|
asflags := flags.globalCommonFlags + " " +
|
|
|
|
flags.globalAsFlags + " " +
|
|
|
|
flags.localCommonFlags + " " +
|
|
|
|
flags.localAsFlags + " " +
|
|
|
|
flags.systemIncludeFlags
|
2017-06-15 23:45:18 +02:00
|
|
|
|
2017-02-08 22:45:53 +01:00
|
|
|
var sAbiDumpFiles android.Paths
|
2018-10-08 05:54:34 +02:00
|
|
|
if flags.sAbiDump {
|
2017-02-08 22:45:53 +01:00
|
|
|
sAbiDumpFiles = make(android.Paths, 0, len(srcFiles))
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2018-10-08 05:54:34 +02:00
|
|
|
cflags += " ${config.NoOverrideClangGlobalCflags}"
|
|
|
|
toolingCflags += " ${config.NoOverrideClangGlobalCflags}"
|
|
|
|
cppflags += " ${config.NoOverrideClangGlobalCflags}"
|
|
|
|
toolingCppflags += " ${config.NoOverrideClangGlobalCflags}"
|
2016-03-04 02:21:04 +01:00
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
for i, srcFile := range srcFiles {
|
2016-11-03 04:43:13 +01:00
|
|
|
objFile := android.ObjPathWithExt(ctx, subdir, srcFile, "o")
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
objFiles[i] = objFile
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Register compilation build statements. The actual rule used depends on the source file type.
|
2017-09-09 10:15:26 +02:00
|
|
|
switch srcFile.Ext() {
|
|
|
|
case ".asm":
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: yasm,
|
|
|
|
Description: "yasm " + srcFile.Rel(),
|
|
|
|
Output: objFile,
|
|
|
|
Input: srcFile,
|
2018-01-23 19:49:04 +01:00
|
|
|
Implicits: cFlagsDeps,
|
|
|
|
OrderOnly: pathDeps,
|
2016-12-03 02:13:24 +01:00
|
|
|
Args: map[string]string{
|
2019-11-06 16:06:58 +01:00
|
|
|
"asFlags": flags.globalYasmFlags + " " + flags.localYasmFlags,
|
2016-12-03 02:13:24 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
continue
|
2017-09-09 10:15:26 +02:00
|
|
|
case ".rc":
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-09-09 10:15:26 +02:00
|
|
|
Rule: windres,
|
|
|
|
Description: "windres " + srcFile.Rel(),
|
|
|
|
Output: objFile,
|
|
|
|
Input: srcFile,
|
2018-01-23 19:49:04 +01:00
|
|
|
Implicits: cFlagsDeps,
|
|
|
|
OrderOnly: pathDeps,
|
2017-09-09 10:15:26 +02:00
|
|
|
Args: map[string]string{
|
|
|
|
"windresCmd": gccCmd(flags.toolchain, "windres"),
|
|
|
|
"flags": flags.toolchain.WindresFlags(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
continue
|
2019-08-16 21:14:32 +02:00
|
|
|
case ".o":
|
|
|
|
objFiles[i] = srcFile
|
|
|
|
continue
|
2016-12-03 02:13:24 +01:00
|
|
|
}
|
|
|
|
|
2019-11-06 16:06:58 +01:00
|
|
|
var moduleFlags string
|
|
|
|
var moduleToolingFlags string
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
var ccCmd string
|
2018-10-08 05:54:34 +02:00
|
|
|
tidy := flags.tidy
|
2020-04-21 21:40:27 +02:00
|
|
|
coverage := flags.gcovCoverage
|
2018-10-08 05:54:34 +02:00
|
|
|
dump := flags.sAbiDump
|
2019-01-04 08:25:11 +01:00
|
|
|
rule := cc
|
2018-11-06 01:49:08 +01:00
|
|
|
emitXref := flags.emitXrefs
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
switch srcFile.Ext() {
|
2019-01-04 08:25:11 +01:00
|
|
|
case ".s":
|
2019-08-28 06:20:40 +02:00
|
|
|
if !flags.assemblerWithCpp {
|
|
|
|
rule = ccNoDeps
|
|
|
|
}
|
2019-01-04 08:25:11 +01:00
|
|
|
fallthrough
|
|
|
|
case ".S":
|
2018-10-08 05:54:34 +02:00
|
|
|
ccCmd = "clang"
|
2019-11-06 16:06:58 +01:00
|
|
|
moduleFlags = asflags
|
2016-09-27 00:45:04 +02:00
|
|
|
tidy = false
|
2017-02-10 01:16:31 +01:00
|
|
|
coverage = false
|
2017-02-08 22:45:53 +01:00
|
|
|
dump = false
|
2018-11-06 01:49:08 +01:00
|
|
|
emitXref = false
|
2015-01-31 02:27:36 +01:00
|
|
|
case ".c":
|
2018-10-08 05:54:34 +02:00
|
|
|
ccCmd = "clang"
|
2019-11-06 16:06:58 +01:00
|
|
|
moduleFlags = cflags
|
|
|
|
moduleToolingFlags = toolingCflags
|
2019-06-27 23:46:10 +02:00
|
|
|
case ".cpp", ".cc", ".cxx", ".mm":
|
2018-10-08 05:54:34 +02:00
|
|
|
ccCmd = "clang++"
|
2019-11-06 16:06:58 +01:00
|
|
|
moduleFlags = cppflags
|
|
|
|
moduleToolingFlags = toolingCppflags
|
2020-12-03 23:12:41 +01:00
|
|
|
case ".h", ".hpp":
|
|
|
|
ctx.PropertyErrorf("srcs", "Header file %s is not supported, instead use export_include_dirs or local_include_dirs.", srcFile)
|
|
|
|
continue
|
2015-01-31 02:27:36 +01:00
|
|
|
default:
|
2020-12-03 23:12:41 +01:00
|
|
|
ctx.PropertyErrorf("srcs", "File %s has unknown extension. Supported extensions: .s, .S, .c, .cpp, .cc, .cxx, .mm", srcFile)
|
2015-01-31 02:27:36 +01:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2017-05-09 22:45:28 +02:00
|
|
|
ccDesc := ccCmd
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2018-10-08 05:54:34 +02:00
|
|
|
ccCmd = "${config.ClangBin}/" + ccCmd
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2017-02-10 01:16:31 +01:00
|
|
|
var implicitOutputs android.WritablePaths
|
|
|
|
if coverage {
|
|
|
|
gcnoFile := android.ObjPathWithExt(ctx, subdir, srcFile, "gcno")
|
|
|
|
implicitOutputs = append(implicitOutputs, gcnoFile)
|
|
|
|
coverageFiles = append(coverageFiles, gcnoFile)
|
|
|
|
}
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2019-01-04 08:25:11 +01:00
|
|
|
Rule: rule,
|
2017-05-09 22:45:28 +02:00
|
|
|
Description: ccDesc + " " + srcFile.Rel(),
|
2017-02-10 01:16:31 +01:00
|
|
|
Output: objFile,
|
|
|
|
ImplicitOutputs: implicitOutputs,
|
|
|
|
Input: srcFile,
|
2018-01-23 19:49:04 +01:00
|
|
|
Implicits: cFlagsDeps,
|
|
|
|
OrderOnly: pathDeps,
|
2015-01-31 02:27:36 +01:00
|
|
|
Args: map[string]string{
|
2019-11-06 16:06:58 +01:00
|
|
|
"cFlags": moduleFlags,
|
2015-04-22 22:07:53 +02:00
|
|
|
"ccCmd": ccCmd,
|
2015-01-31 02:27:36 +01:00
|
|
|
},
|
|
|
|
})
|
2016-09-27 00:45:04 +02:00
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Register post-process build statements (such as for tidy or kythe).
|
2018-11-06 01:49:08 +01:00
|
|
|
if emitXref {
|
|
|
|
kytheFile := android.ObjPathWithExt(ctx, subdir, srcFile, "kzip")
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: kytheExtract,
|
|
|
|
Description: "Xref C++ extractor " + srcFile.Rel(),
|
|
|
|
Output: kytheFile,
|
|
|
|
Input: srcFile,
|
|
|
|
Implicits: cFlagsDeps,
|
|
|
|
OrderOnly: pathDeps,
|
|
|
|
Args: map[string]string{
|
2019-11-06 16:06:58 +01:00
|
|
|
"cFlags": moduleFlags,
|
2018-11-06 01:49:08 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
kytheFiles = append(kytheFiles, kytheFile)
|
|
|
|
}
|
|
|
|
|
2016-09-27 00:45:04 +02:00
|
|
|
if tidy {
|
2016-11-03 04:43:13 +01:00
|
|
|
tidyFile := android.ObjPathWithExt(ctx, subdir, srcFile, "tidy")
|
2016-09-27 00:45:04 +02:00
|
|
|
tidyFiles = append(tidyFiles, tidyFile)
|
|
|
|
|
2020-06-18 18:17:51 +02:00
|
|
|
rule := clangTidy
|
2020-09-03 07:29:49 +02:00
|
|
|
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CLANG_TIDY") {
|
2020-06-18 18:17:51 +02:00
|
|
|
rule = clangTidyRE
|
|
|
|
}
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2020-06-18 18:17:51 +02:00
|
|
|
Rule: rule,
|
2017-05-09 22:45:28 +02:00
|
|
|
Description: "clang-tidy " + srcFile.Rel(),
|
|
|
|
Output: tidyFile,
|
|
|
|
Input: srcFile,
|
2016-09-27 00:45:04 +02:00
|
|
|
// We must depend on objFile, since clang-tidy doesn't
|
|
|
|
// support exporting dependencies.
|
2019-08-09 21:45:53 +02:00
|
|
|
Implicit: objFile,
|
|
|
|
Implicits: cFlagsDeps,
|
|
|
|
OrderOnly: pathDeps,
|
2016-09-27 00:45:04 +02:00
|
|
|
Args: map[string]string{
|
2019-11-06 16:06:58 +01:00
|
|
|
"cFlags": moduleToolingFlags,
|
2016-09-27 00:45:04 +02:00
|
|
|
"tidyFlags": flags.tidyFlags,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-02-08 22:45:53 +01:00
|
|
|
if dump {
|
|
|
|
sAbiDumpFile := android.ObjPathWithExt(ctx, subdir, srcFile, "sdump")
|
|
|
|
sAbiDumpFiles = append(sAbiDumpFiles, sAbiDumpFile)
|
|
|
|
|
2020-04-17 21:03:58 +02:00
|
|
|
dumpRule := sAbiDump
|
2020-09-03 07:29:49 +02:00
|
|
|
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_ABI_DUMPER") {
|
2020-04-17 21:03:58 +02:00
|
|
|
dumpRule = sAbiDumpRE
|
|
|
|
}
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2020-04-17 21:03:58 +02:00
|
|
|
Rule: dumpRule,
|
2017-05-09 22:45:28 +02:00
|
|
|
Description: "header-abi-dumper " + srcFile.Rel(),
|
|
|
|
Output: sAbiDumpFile,
|
|
|
|
Input: srcFile,
|
|
|
|
Implicit: objFile,
|
2019-08-09 21:45:53 +02:00
|
|
|
Implicits: cFlagsDeps,
|
|
|
|
OrderOnly: pathDeps,
|
2017-02-08 22:45:53 +01:00
|
|
|
Args: map[string]string{
|
2019-11-06 16:06:58 +01:00
|
|
|
"cFlags": moduleToolingFlags,
|
2017-02-08 22:45:53 +01:00
|
|
|
"exportDirs": flags.sAbiFlags,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-09-27 02:33:01 +02:00
|
|
|
return Objects{
|
2017-02-10 01:16:31 +01:00
|
|
|
objFiles: objFiles,
|
|
|
|
tidyFiles: tidyFiles,
|
|
|
|
coverageFiles: coverageFiles,
|
2017-02-08 22:45:53 +01:00
|
|
|
sAbiDumpFiles: sAbiDumpFiles,
|
2018-11-06 01:49:08 +01:00
|
|
|
kytheFiles: kytheFiles,
|
2016-09-27 02:33:01 +02:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Generate a rule for compiling multiple .o files to a static library (.a)
|
2020-11-23 23:02:44 +01:00
|
|
|
func transformObjToStaticLib(ctx android.ModuleContext,
|
2020-04-17 18:34:31 +02:00
|
|
|
objFiles android.Paths, wholeStaticLibs android.Paths,
|
2016-09-27 00:45:04 +02:00
|
|
|
flags builderFlags, outputFile android.ModuleOutPath, deps android.Paths) {
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2018-01-10 08:29:04 +01:00
|
|
|
arCmd := "${config.ClangBin}/llvm-ar"
|
2020-04-17 18:34:31 +02:00
|
|
|
arFlags := ""
|
2018-01-10 08:29:04 +01:00
|
|
|
if !ctx.Darwin() {
|
|
|
|
arFlags += " -format=gnu"
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-04-17 18:34:31 +02:00
|
|
|
if len(wholeStaticLibs) == 0 {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: ar,
|
|
|
|
Description: "static link " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Inputs: objFiles,
|
|
|
|
Implicits: deps,
|
|
|
|
Args: map[string]string{
|
|
|
|
"arFlags": "crsPD" + arFlags,
|
|
|
|
"arCmd": arCmd,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
} else {
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: arWithLibs,
|
|
|
|
Description: "static link " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Inputs: append(objFiles, wholeStaticLibs...),
|
|
|
|
Implicits: deps,
|
|
|
|
Args: map[string]string{
|
|
|
|
"arCmd": arCmd,
|
|
|
|
"arObjFlags": "crsPD" + arFlags,
|
|
|
|
"arObjs": strings.Join(objFiles.Strings(), " "),
|
|
|
|
"arLibFlags": "cqsL" + arFlags,
|
|
|
|
"arLibs": strings.Join(wholeStaticLibs.Strings(), " "),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Generate a rule for compiling multiple .o files, plus static libraries, whole static libraries,
|
2017-09-28 02:01:44 +02:00
|
|
|
// and shared libraries, to a shared library (.so) or dynamic executable
|
2020-11-23 23:02:44 +01:00
|
|
|
func transformObjToDynamicBinary(ctx android.ModuleContext,
|
2016-05-19 00:37:25 +02:00
|
|
|
objFiles, sharedLibs, staticLibs, lateStaticLibs, wholeStaticLibs, deps android.Paths,
|
2019-06-08 02:58:59 +02:00
|
|
|
crtBegin, crtEnd android.OptionalPath, groupLate bool, flags builderFlags, outputFile android.WritablePath, implicitOutputs android.WritablePaths) {
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2018-10-08 05:54:34 +02:00
|
|
|
ldCmd := "${config.ClangBin}/clang++"
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
var libFlagsList []string
|
|
|
|
|
2016-01-06 23:41:07 +01:00
|
|
|
if len(flags.libFlags) > 0 {
|
|
|
|
libFlagsList = append(libFlagsList, flags.libFlags)
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
if len(wholeStaticLibs) > 0 {
|
2015-11-25 02:53:15 +01:00
|
|
|
if ctx.Host() && ctx.Darwin() {
|
2016-05-19 00:37:25 +02:00
|
|
|
libFlagsList = append(libFlagsList, android.JoinWithPrefix(wholeStaticLibs.Strings(), "-force_load "))
|
2015-05-01 01:36:18 +02:00
|
|
|
} else {
|
|
|
|
libFlagsList = append(libFlagsList, "-Wl,--whole-archive ")
|
2015-09-24 00:26:20 +02:00
|
|
|
libFlagsList = append(libFlagsList, wholeStaticLibs.Strings()...)
|
2015-05-01 01:36:18 +02:00
|
|
|
libFlagsList = append(libFlagsList, "-Wl,--no-whole-archive ")
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-12-06 03:47:39 +01:00
|
|
|
if flags.groupStaticLibs && !ctx.Darwin() && len(staticLibs) > 0 {
|
2016-12-01 23:45:23 +01:00
|
|
|
libFlagsList = append(libFlagsList, "-Wl,--start-group")
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
libFlagsList = append(libFlagsList, staticLibs.Strings()...)
|
2016-12-06 03:47:39 +01:00
|
|
|
if flags.groupStaticLibs && !ctx.Darwin() && len(staticLibs) > 0 {
|
2016-12-01 23:45:23 +01:00
|
|
|
libFlagsList = append(libFlagsList, "-Wl,--end-group")
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-07-19 00:54:54 +02:00
|
|
|
if groupLate && !ctx.Darwin() && len(lateStaticLibs) > 0 {
|
2015-07-08 22:02:23 +02:00
|
|
|
libFlagsList = append(libFlagsList, "-Wl,--start-group")
|
|
|
|
}
|
2015-09-24 00:26:20 +02:00
|
|
|
libFlagsList = append(libFlagsList, lateStaticLibs.Strings()...)
|
2016-07-19 00:54:54 +02:00
|
|
|
if groupLate && !ctx.Darwin() && len(lateStaticLibs) > 0 {
|
2015-07-08 22:02:23 +02:00
|
|
|
libFlagsList = append(libFlagsList, "-Wl,--end-group")
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
for _, lib := range sharedLibs {
|
2019-06-08 02:58:59 +02:00
|
|
|
libFile := lib.String()
|
|
|
|
if ctx.Windows() {
|
|
|
|
libFile = pathtools.ReplaceExtension(libFile, "lib")
|
|
|
|
}
|
|
|
|
libFlagsList = append(libFlagsList, libFile)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
deps = append(deps, staticLibs...)
|
2015-03-17 18:47:08 +01:00
|
|
|
deps = append(deps, lateStaticLibs...)
|
2015-01-31 02:27:36 +01:00
|
|
|
deps = append(deps, wholeStaticLibs...)
|
2015-09-24 00:26:20 +02:00
|
|
|
if crtBegin.Valid() {
|
|
|
|
deps = append(deps, crtBegin.Path(), crtEnd.Path())
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2020-04-13 19:21:23 +02:00
|
|
|
rule := ld
|
2020-04-22 22:31:09 +02:00
|
|
|
args := map[string]string{
|
|
|
|
"ldCmd": ldCmd,
|
|
|
|
"crtBegin": crtBegin.String(),
|
|
|
|
"libFlags": strings.Join(libFlagsList, " "),
|
|
|
|
"extraLibFlags": flags.extraLibFlags,
|
|
|
|
"ldFlags": flags.globalLdFlags + " " + flags.localLdFlags,
|
|
|
|
"crtEnd": crtEnd.String(),
|
|
|
|
}
|
2020-09-03 07:29:49 +02:00
|
|
|
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CXX_LINKS") {
|
2020-04-13 19:21:23 +02:00
|
|
|
rule = ldRE
|
2020-04-22 22:31:09 +02:00
|
|
|
args["implicitOutputs"] = strings.Join(implicitOutputs.Strings(), ",")
|
2020-08-28 20:21:55 +02:00
|
|
|
args["implicitInputs"] = strings.Join(deps.Strings(), ",")
|
2020-04-13 19:21:23 +02:00
|
|
|
}
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2020-04-13 19:21:23 +02:00
|
|
|
Rule: rule,
|
2019-06-08 02:58:59 +02:00
|
|
|
Description: "link " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
ImplicitOutputs: implicitOutputs,
|
|
|
|
Inputs: objFiles,
|
|
|
|
Implicits: deps,
|
2020-04-22 22:31:09 +02:00
|
|
|
Args: args,
|
2015-01-31 02:27:36 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-02-08 22:45:53 +01:00
|
|
|
// Generate a rule to combine .dump sAbi dump files from multiple source files
|
|
|
|
// into a single .ldump sAbi dump file
|
2020-11-23 23:02:44 +01:00
|
|
|
func transformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Paths, soFile android.Path,
|
2019-01-16 17:18:02 +01:00
|
|
|
baseName, exportedHeaderFlags string, symbolFile android.OptionalPath,
|
|
|
|
excludedSymbolVersions, excludedSymbolTags []string) android.OptionalPath {
|
|
|
|
|
2017-02-08 22:45:53 +01:00
|
|
|
outputFile := android.PathForModuleOut(ctx, baseName+".lsdump")
|
2019-01-16 17:18:02 +01:00
|
|
|
|
|
|
|
implicits := android.Paths{soFile}
|
2018-01-17 20:11:42 +01:00
|
|
|
symbolFilterStr := "-so " + soFile.String()
|
2019-01-16 17:18:02 +01:00
|
|
|
|
|
|
|
if symbolFile.Valid() {
|
|
|
|
implicits = append(implicits, symbolFile.Path())
|
|
|
|
symbolFilterStr += " -v " + symbolFile.String()
|
|
|
|
}
|
|
|
|
for _, ver := range excludedSymbolVersions {
|
|
|
|
symbolFilterStr += " --exclude-symbol-version " + ver
|
|
|
|
}
|
|
|
|
for _, tag := range excludedSymbolTags {
|
|
|
|
symbolFilterStr += " --exclude-symbol-tag " + tag
|
|
|
|
}
|
2020-05-07 12:56:47 +02:00
|
|
|
rule := sAbiLink
|
|
|
|
args := map[string]string{
|
|
|
|
"symbolFilter": symbolFilterStr,
|
|
|
|
"arch": ctx.Arch().ArchType.Name,
|
|
|
|
"exportedHeaderFlags": exportedHeaderFlags,
|
|
|
|
}
|
2020-09-03 07:29:49 +02:00
|
|
|
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_ABI_LINKER") {
|
2020-05-07 12:56:47 +02:00
|
|
|
rule = sAbiLinkRE
|
|
|
|
rbeImplicits := implicits.Strings()
|
|
|
|
for _, p := range strings.Split(exportedHeaderFlags, " ") {
|
|
|
|
if len(p) > 2 {
|
|
|
|
// Exclude the -I prefix.
|
|
|
|
rbeImplicits = append(rbeImplicits, p[2:])
|
|
|
|
}
|
|
|
|
}
|
2020-08-28 20:21:55 +02:00
|
|
|
args["implicitInputs"] = strings.Join(rbeImplicits, ",")
|
2020-05-07 12:56:47 +02:00
|
|
|
}
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2020-05-07 12:56:47 +02:00
|
|
|
Rule: rule,
|
2017-05-09 22:45:28 +02:00
|
|
|
Description: "header-abi-linker " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Inputs: sAbiDumps,
|
2019-01-16 17:18:02 +01:00
|
|
|
Implicits: implicits,
|
2020-05-07 12:56:47 +02:00
|
|
|
Args: args,
|
2017-02-08 22:45:53 +01:00
|
|
|
})
|
|
|
|
return android.OptionalPathForPath(outputFile)
|
|
|
|
}
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// unzipRefDump registers a build statement to unzip a reference abi dump.
|
|
|
|
func unzipRefDump(ctx android.ModuleContext, zippedRefDump android.Path, baseName string) android.Path {
|
2017-04-20 15:53:59 +02:00
|
|
|
outputFile := android.PathForModuleOut(ctx, baseName+"_ref.lsdump")
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-04-20 15:53:59 +02:00
|
|
|
Rule: unzipRefSAbiDump,
|
|
|
|
Description: "gunzip" + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Input: zippedRefDump,
|
|
|
|
})
|
|
|
|
return outputFile
|
|
|
|
}
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// sourceAbiDiff registers a build statement to compare linked sAbi dump files (.ldump).
|
|
|
|
func sourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceDump android.Path,
|
2019-10-02 00:58:07 +02:00
|
|
|
baseName, exportedHeaderFlags string, checkAllApis, isLlndk, isNdk, isVndkExt bool) android.OptionalPath {
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
|
2017-02-08 22:45:53 +01:00
|
|
|
outputFile := android.PathForModuleOut(ctx, baseName+".abidiff")
|
2018-06-01 00:42:26 +02:00
|
|
|
libName := strings.TrimSuffix(baseName, filepath.Ext(baseName))
|
2019-02-18 06:12:21 +01:00
|
|
|
createReferenceDumpFlags := ""
|
|
|
|
|
2019-10-02 00:58:07 +02:00
|
|
|
var extraFlags []string
|
|
|
|
if checkAllApis {
|
|
|
|
extraFlags = append(extraFlags, "-check-all-apis")
|
|
|
|
} else {
|
|
|
|
extraFlags = append(extraFlags,
|
|
|
|
"-allow-unreferenced-changes",
|
|
|
|
"-allow-unreferenced-elf-symbol-changes")
|
|
|
|
}
|
|
|
|
|
2018-01-17 22:13:33 +01:00
|
|
|
if exportedHeaderFlags == "" {
|
2019-10-02 00:58:07 +02:00
|
|
|
extraFlags = append(extraFlags, "-advice-only")
|
2018-01-17 22:13:33 +01:00
|
|
|
}
|
2019-10-02 00:58:07 +02:00
|
|
|
|
2019-02-18 08:40:42 +01:00
|
|
|
if isLlndk || isNdk {
|
2019-02-18 06:12:21 +01:00
|
|
|
createReferenceDumpFlags = "--llndk"
|
2019-02-18 08:40:42 +01:00
|
|
|
if isLlndk {
|
|
|
|
// TODO(b/130324828): "-consider-opaque-types-different" should apply to
|
|
|
|
// both LLNDK and NDK shared libs. However, a known issue in header-abi-diff
|
|
|
|
// breaks libaaudio. Remove the if-guard after the issue is fixed.
|
2019-10-02 00:58:07 +02:00
|
|
|
extraFlags = append(extraFlags, "-consider-opaque-types-different")
|
2019-02-18 08:40:42 +01:00
|
|
|
}
|
2018-06-01 00:42:26 +02:00
|
|
|
}
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
if isVndkExt {
|
2019-10-02 00:58:07 +02:00
|
|
|
extraFlags = append(extraFlags, "-allow-extensions")
|
Support VNDK extensions
This commit adds `extends: "name"` property and provides basic support
to VNDK extensions. This is the simplest example:
```
cc_library {
name: "libvndk",
vendor_available: true,
vndk {
enabled: true,
},
}
cc_library {
name: "libvndk_ext",
vendor: true,
vndk: {
enabled: true,
extends: "libvndk",
},
}
```
A vndk extension library must extend an existing vndk library which has
`vendor_available: true`. These two libraries must have the same
`support_system_process` property.
VNDK-ext libraries are installed to `/vendor/lib[64]/vndk` and
VNDK-SP-ext libraries are installed to `/vendor/lib[64]/vndk-sp` by
default.
If there is a matching abi-dumps in `prebuilts/abi-dumps`,
`header-abi-diff` will be invoked to check for ABI breakages.
Bug: 38340960
Test: lunch aosp_walleye-userdebug && make -j8 # runs unit tests
Test: lunch aosp_arm-userdebug && make -j8 # build a target w/o VNDK
Test: Create a lsdump for a vndk lib, add an exported API to vndk lib,
and build fails as expected.
Test: Create a lsdump for a vndk lib, create an vndk extension lib with
extra API, and build succeeds as expected.
Test: Create libutils_ext, add an extra function to libutils_ext, and
call it from a HIDL service.
Change-Id: Iba90e08848ee99814405457f047321e6b52b2df0
2017-10-31 11:04:35 +01:00
|
|
|
}
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: sAbiDiff,
|
|
|
|
Description: "header-abi-diff " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Input: inputDump,
|
|
|
|
Implicit: referenceDump,
|
2017-02-08 22:45:53 +01:00
|
|
|
Args: map[string]string{
|
2019-02-18 06:12:21 +01:00
|
|
|
"referenceDump": referenceDump.String(),
|
|
|
|
"libName": libName,
|
|
|
|
"arch": ctx.Arch().ArchType.Name,
|
2019-10-02 00:58:07 +02:00
|
|
|
"extraFlags": strings.Join(extraFlags, " "),
|
2019-02-18 06:12:21 +01:00
|
|
|
"createReferenceDumpFlags": createReferenceDumpFlags,
|
2017-02-08 22:45:53 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
return android.OptionalPathForPath(outputFile)
|
|
|
|
}
|
|
|
|
|
2017-09-28 02:01:44 +02:00
|
|
|
// Generate a rule for extracting a table of contents from a shared library (.so)
|
2020-11-23 23:02:44 +01:00
|
|
|
func transformSharedObjectToToc(ctx android.ModuleContext, inputFile android.Path,
|
2016-10-01 02:10:16 +02:00
|
|
|
outputFile android.WritablePath, flags builderFlags) {
|
|
|
|
|
2018-09-11 01:50:05 +02:00
|
|
|
var format string
|
|
|
|
var crossCompile string
|
|
|
|
if ctx.Darwin() {
|
|
|
|
format = "--macho"
|
|
|
|
crossCompile = "${config.MacToolPath}"
|
|
|
|
} else if ctx.Windows() {
|
|
|
|
format = "--pe"
|
|
|
|
crossCompile = gccCmd(flags.toolchain, "")
|
|
|
|
} else {
|
|
|
|
format = "--elf"
|
|
|
|
crossCompile = gccCmd(flags.toolchain, "")
|
|
|
|
}
|
2016-10-01 02:10:16 +02:00
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: toc,
|
|
|
|
Description: "generate toc " + inputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Input: inputFile,
|
2016-10-01 02:10:16 +02:00
|
|
|
Args: map[string]string{
|
|
|
|
"crossCompile": crossCompile,
|
2018-09-11 01:50:05 +02:00
|
|
|
"format": format,
|
2016-10-01 02:10:16 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
// Generate a rule for compiling multiple .o files to a .o using ld partial linking
|
2020-11-23 23:02:44 +01:00
|
|
|
func transformObjsToObj(ctx android.ModuleContext, objFiles android.Paths,
|
2019-09-19 19:50:18 +02:00
|
|
|
flags builderFlags, outputFile android.WritablePath, deps android.Paths) {
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2018-10-08 05:54:34 +02:00
|
|
|
ldCmd := "${config.ClangBin}/clang++"
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-04-13 19:21:23 +02:00
|
|
|
rule := partialLd
|
|
|
|
args := map[string]string{
|
|
|
|
"ldCmd": ldCmd,
|
|
|
|
"ldFlags": flags.globalLdFlags + " " + flags.localLdFlags,
|
|
|
|
}
|
2020-09-03 07:29:49 +02:00
|
|
|
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CXX_LINKS") {
|
2020-04-13 19:21:23 +02:00
|
|
|
rule = partialLdRE
|
|
|
|
args["inCommaList"] = strings.Join(objFiles.Strings(), ",")
|
2020-08-28 20:21:55 +02:00
|
|
|
args["implicitInputs"] = strings.Join(deps.Strings(), ",")
|
2020-04-13 19:21:23 +02:00
|
|
|
}
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2020-04-13 19:21:23 +02:00
|
|
|
Rule: rule,
|
2017-05-09 22:45:28 +02:00
|
|
|
Description: "link " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Inputs: objFiles,
|
2019-09-19 19:50:18 +02:00
|
|
|
Implicits: deps,
|
2020-04-13 19:21:23 +02:00
|
|
|
Args: args,
|
2015-01-31 02:27:36 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Generate a rule for running objcopy --prefix-symbols on a binary
|
|
|
|
func transformBinaryPrefixSymbols(ctx android.ModuleContext, prefix string, inputFile android.Path,
|
2016-05-19 00:37:25 +02:00
|
|
|
flags builderFlags, outputFile android.WritablePath) {
|
2015-03-26 22:44:11 +01:00
|
|
|
|
|
|
|
objcopyCmd := gccCmd(flags.toolchain, "objcopy")
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: prefixSymbols,
|
|
|
|
Description: "prefix symbols " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Input: inputFile,
|
2015-03-26 22:44:11 +01:00
|
|
|
Args: map[string]string{
|
|
|
|
"objcopyCmd": objcopyCmd,
|
|
|
|
"prefix": prefix,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Registers a build statement to invoke `strip` (to discard symbols and data from object files).
|
|
|
|
func transformStrip(ctx android.ModuleContext, inputFile android.Path,
|
2020-08-19 14:53:01 +02:00
|
|
|
outputFile android.WritablePath, flags StripFlags) {
|
2016-04-28 23:50:03 +02:00
|
|
|
|
2020-08-19 14:53:01 +02:00
|
|
|
crossCompile := gccCmd(flags.Toolchain, "")
|
2016-04-28 23:50:03 +02:00
|
|
|
args := ""
|
2020-08-19 14:53:01 +02:00
|
|
|
if flags.StripAddGnuDebuglink {
|
2016-04-28 23:50:03 +02:00
|
|
|
args += " --add-gnu-debuglink"
|
|
|
|
}
|
2020-08-19 14:53:01 +02:00
|
|
|
if flags.StripKeepMiniDebugInfo {
|
2016-04-28 23:50:03 +02:00
|
|
|
args += " --keep-mini-debug-info"
|
|
|
|
}
|
2020-08-19 14:53:01 +02:00
|
|
|
if flags.StripKeepSymbols {
|
2016-04-28 23:50:03 +02:00
|
|
|
args += " --keep-symbols"
|
|
|
|
}
|
2020-08-19 14:53:01 +02:00
|
|
|
if flags.StripKeepSymbolsList != "" {
|
|
|
|
args += " -k" + flags.StripKeepSymbolsList
|
2019-03-30 04:05:14 +01:00
|
|
|
}
|
2020-08-19 14:53:01 +02:00
|
|
|
if flags.StripKeepSymbolsAndDebugFrame {
|
2019-05-18 01:39:54 +02:00
|
|
|
args += " --keep-symbols-and-debug-frame"
|
|
|
|
}
|
2020-08-19 14:53:01 +02:00
|
|
|
if flags.StripUseGnuStrip {
|
2018-11-08 01:28:49 +01:00
|
|
|
args += " --use-gnu-strip"
|
2018-06-04 19:37:43 +02:00
|
|
|
}
|
2016-04-28 23:50:03 +02:00
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: strip,
|
|
|
|
Description: "strip " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Input: inputFile,
|
2016-04-28 23:50:03 +02:00
|
|
|
Args: map[string]string{
|
|
|
|
"crossCompile": crossCompile,
|
|
|
|
"args": args,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Registers build statement to invoke `strip` on darwin architecture.
|
|
|
|
func transformDarwinStrip(ctx android.ModuleContext, inputFile android.Path,
|
2016-05-19 00:37:25 +02:00
|
|
|
outputFile android.WritablePath) {
|
2016-05-04 00:10:29 +02:00
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: darwinStrip,
|
|
|
|
Description: "strip " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Input: inputFile,
|
2016-05-04 00:10:29 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Registers build statement to zip one or more coverage files.
|
|
|
|
func transformCoverageFilesToZip(ctx android.ModuleContext,
|
2019-04-24 23:22:25 +02:00
|
|
|
inputs Objects, baseName string) android.OptionalPath {
|
2017-02-10 01:16:31 +01:00
|
|
|
|
|
|
|
if len(inputs.coverageFiles) > 0 {
|
2019-04-24 23:22:25 +02:00
|
|
|
outputFile := android.PathForModuleOut(ctx, baseName+".zip")
|
2017-02-10 01:16:31 +01:00
|
|
|
|
2019-04-24 23:22:25 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: zip,
|
|
|
|
Description: "zip " + outputFile.Base(),
|
|
|
|
Inputs: inputs.coverageFiles,
|
|
|
|
Output: outputFile,
|
|
|
|
})
|
2017-02-10 01:16:31 +01:00
|
|
|
|
|
|
|
return android.OptionalPathForPath(outputFile)
|
|
|
|
}
|
|
|
|
|
|
|
|
return android.OptionalPath{}
|
|
|
|
}
|
|
|
|
|
2020-11-23 23:02:44 +01:00
|
|
|
// Rule to repack an archive (.a) file with a subset of object files.
|
|
|
|
func transformArchiveRepack(ctx android.ModuleContext, inputFile android.Path,
|
2019-10-15 11:01:19 +02:00
|
|
|
outputFile android.WritablePath, objects []string) {
|
|
|
|
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: archiveRepack,
|
|
|
|
Description: "Repack archive " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Input: inputFile,
|
|
|
|
Args: map[string]string{
|
|
|
|
"objects": strings.Join(objects, " "),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-07-29 22:44:28 +02:00
|
|
|
func gccCmd(toolchain config.Toolchain, cmd string) string {
|
2015-01-31 02:27:36 +01:00
|
|
|
return filepath.Join(toolchain.GccRoot(), "bin", toolchain.GccTriple()+"-"+cmd)
|
|
|
|
}
|