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 (
|
2015-05-01 01:36:18 +02:00
|
|
|
"fmt"
|
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"
|
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"
|
|
|
|
)
|
|
|
|
|
2017-11-01 19:12:15 +01:00
|
|
|
var (
|
|
|
|
abiCheckAllowFlags = []string{
|
|
|
|
"-allow-unreferenced-changes",
|
|
|
|
"-allow-unreferenced-elf-symbol-changes",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
var (
|
2016-05-19 00:37:25 +02:00
|
|
|
pctx = android.NewPackageContext("android/soong/cc")
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-08-30 01:14:13 +02:00
|
|
|
cc = pctx.AndroidGomaStaticRule("cc",
|
2015-01-31 02:27:36 +01:00
|
|
|
blueprint.RuleParams{
|
|
|
|
Depfile: "${out}.d",
|
|
|
|
Deps: blueprint.DepsGCC,
|
2016-08-26 21:55: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
|
|
|
|
2019-01-04 08:25:11 +01:00
|
|
|
ccNoDeps = pctx.AndroidGomaStaticRule("ccNoDeps",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: "$relPwd ${config.CcWrapper}$ccCmd -c $cFlags -o $out $in",
|
|
|
|
CommandDeps: []string{"$ccCmd"},
|
|
|
|
},
|
|
|
|
"ccCmd", "cFlags")
|
|
|
|
|
2016-08-30 01:14:13 +02:00
|
|
|
ld = pctx.AndroidStaticRule("ld",
|
2015-01-31 02:27:36 +01:00
|
|
|
blueprint.RuleParams{
|
2016-07-21 22:16:49 +02:00
|
|
|
Command: "$ldCmd ${crtBegin} @${out}.rsp " +
|
2015-04-22 22:07:53 +02:00
|
|
|
"${libFlags} ${crtEnd} -o ${out} ${ldFlags}",
|
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
|
|
|
},
|
2016-07-21 22:16:49 +02:00
|
|
|
"ldCmd", "crtBegin", "libFlags", "crtEnd", "ldFlags")
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-08-30 01:14:13 +02:00
|
|
|
partialLd = pctx.AndroidStaticRule("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.
|
2019-07-16 23:08:45 +02:00
|
|
|
Command: "$ldCmd -fuse-ld=lld -nostdlib -no-pie -Wl,-r ${in} -o ${out} ${ldFlags}",
|
2015-11-18 00:27:28 +01:00
|
|
|
CommandDeps: []string{"$ldCmd"},
|
2015-01-31 02:27:36 +01:00
|
|
|
},
|
2015-11-23 23:01:42 +01:00
|
|
|
"ldCmd", "ldFlags")
|
2015-01-31 02:27:36 +01:00
|
|
|
|
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")
|
|
|
|
|
2016-08-30 01:14:13 +02:00
|
|
|
darwinStrip = pctx.AndroidStaticRule("darwinStrip",
|
2016-05-04 00:10:29 +02:00
|
|
|
blueprint.RuleParams{
|
2016-08-02 00:42:38 +02:00
|
|
|
Command: "${config.MacStripPath} -u -r -o $out $in",
|
|
|
|
CommandDeps: []string{"${config.MacStripPath}"},
|
2016-05-04 00:10:29 +02:00
|
|
|
})
|
2015-05-01 01:36:18 +02:00
|
|
|
|
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
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2016-08-30 01:14:13 +02:00
|
|
|
strip = pctx.AndroidStaticRule("strip",
|
2016-04-28 23:50:03 +02:00
|
|
|
blueprint.RuleParams{
|
|
|
|
Depfile: "${out}.d",
|
|
|
|
Deps: blueprint.DepsGCC,
|
2018-06-04 19:37:43 +02:00
|
|
|
Command: "CROSS_COMPILE=$crossCompile XZ=$xzCmd CLANG_BIN=${config.ClangBin} $stripPath ${args} -i ${in} -o ${out} -d ${out}.d",
|
2018-03-09 19:47:52 +01:00
|
|
|
CommandDeps: []string{"$stripPath", "$xzCmd"},
|
2019-05-18 00:36:46 +02:00
|
|
|
Pool: darwinStripPool,
|
2016-04-28 23:50:03 +02:00
|
|
|
},
|
|
|
|
"args", "crossCompile")
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
clangTidy = pctx.AndroidStaticRule("clangTidy",
|
|
|
|
blueprint.RuleParams{
|
2019-04-05 01:22:37 +02:00
|
|
|
Command: "rm -f $out && ${config.ClangBin}/clang-tidy $tidyFlags $in -- $cFlags && touch $out",
|
|
|
|
CommandDeps: []string{"${config.ClangBin}/clang-tidy"},
|
2016-09-27 00:45:04 +02:00
|
|
|
},
|
|
|
|
"cFlags", "tidyFlags")
|
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
|
|
|
|
|
|
|
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
|
|
|
|
2017-09-09 10:15:26 +02:00
|
|
|
windres = pctx.AndroidStaticRule("windres",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: "$windresCmd $flags -I$$(dirname $in) -i $in -o $out",
|
|
|
|
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.
|
2017-02-08 22:45:53 +01:00
|
|
|
sAbiDump = pctx.AndroidStaticRule("sAbiDump",
|
|
|
|
blueprint.RuleParams{
|
2018-10-08 05:49:32 +02:00
|
|
|
Command: "rm -f $out && $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"},
|
|
|
|
},
|
|
|
|
"cFlags", "exportDirs")
|
|
|
|
|
2018-02-20 21:36:51 +01:00
|
|
|
_ = pctx.SourcePathVariable("sAbiLinker", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/header-abi-linker")
|
2017-02-08 22:45:53 +01:00
|
|
|
|
|
|
|
sAbiLink = pctx.AndroidStaticRule("sAbiLink",
|
|
|
|
blueprint.RuleParams{
|
2018-01-17 20:11:42 +01:00
|
|
|
Command: "$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}",
|
|
|
|
},
|
2018-01-17 20:11:42 +01:00
|
|
|
"symbolFilter", "arch", "exportedHeaderFlags")
|
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
|
|
|
|
2017-11-27 23:52:21 +01:00
|
|
|
sAbiDiff = pctx.AndroidRuleFunc("sAbiDiff",
|
2018-03-12 21:24:09 +01:00
|
|
|
func(ctx android.PackageRuleContext) blueprint.RuleParams {
|
2018-05-18 01:45:51 +02:00
|
|
|
// TODO(b/78139997): Add -check-all-apis back
|
2019-02-18 06:12:21 +01:00
|
|
|
commandStr := "($sAbiDiffer ${allowFlags} -lib ${libName} -arch ${arch} -o ${out} -new ${in} -old ${referenceDump})"
|
|
|
|
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-02-18 06:12:21 +01:00
|
|
|
"allowFlags", "referenceDump", "libName", "arch", "createReferenceDumpFlags")
|
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
|
|
|
|
|
|
|
zip = pctx.AndroidStaticRule("zip",
|
|
|
|
blueprint.RuleParams{
|
|
|
|
Command: "cat $out.rsp | tr ' ' '\\n' | tr -d \\' | sort -u > ${out}.tmp && ${SoongZipCmd} -o ${out} -C $$OUT_DIR -l ${out}.tmp",
|
|
|
|
CommandDeps: []string{"${SoongZipCmd}"},
|
|
|
|
Rspfile: "$out.rsp",
|
|
|
|
RspfileContent: "$in",
|
|
|
|
})
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
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.
|
|
|
|
if runtime.GOOS != "darwin" {
|
|
|
|
pctx.StaticVariable("relPwd", "PWD=/proc/self/cwd")
|
|
|
|
} else {
|
|
|
|
// Darwin doesn't have /proc
|
|
|
|
pctx.StaticVariable("relPwd", "")
|
|
|
|
}
|
2019-04-24 23:22:25 +02:00
|
|
|
|
|
|
|
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
|
2015-11-18 00:19:46 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
type builderFlags struct {
|
2018-08-22 23:18:04 +02:00
|
|
|
globalFlags string
|
|
|
|
arFlags string
|
|
|
|
asFlags string
|
|
|
|
cFlags string
|
|
|
|
toolingCFlags string // A separate set of cFlags for clang LibTooling tools
|
|
|
|
toolingCppFlags string // A separate set of cppFlags for clang LibTooling tools
|
|
|
|
conlyFlags string
|
|
|
|
cppFlags string
|
|
|
|
ldFlags string
|
|
|
|
libFlags string
|
|
|
|
tidyFlags string
|
|
|
|
sAbiFlags string
|
|
|
|
yasmFlags string
|
|
|
|
aidlFlags string
|
|
|
|
rsFlags string
|
|
|
|
toolchain config.Toolchain
|
|
|
|
tidy bool
|
|
|
|
coverage bool
|
|
|
|
sAbiDump bool
|
2016-04-28 23:50:03 +02:00
|
|
|
|
2017-03-31 00:03:04 +02:00
|
|
|
systemIncludeFlags string
|
|
|
|
|
2016-12-01 23:45:23 +01:00
|
|
|
groupStaticLibs bool
|
|
|
|
|
2019-05-18 01:39:54 +02:00
|
|
|
stripKeepSymbols bool
|
|
|
|
stripKeepSymbolsList string
|
|
|
|
stripKeepSymbolsAndDebugFrame bool
|
|
|
|
stripKeepMiniDebugInfo bool
|
|
|
|
stripAddGnuDebuglink bool
|
|
|
|
stripUseGnuStrip bool
|
2018-11-17 06:05:32 +01:00
|
|
|
|
2019-03-28 22:45:07 +01:00
|
|
|
proto android.ProtoFlags
|
2018-11-17 06:05:32 +01:00
|
|
|
protoC bool
|
|
|
|
protoOptionsFile bool
|
2019-04-11 07:59:54 +02:00
|
|
|
|
|
|
|
yacc *YaccProperties
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
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
|
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...),
|
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...),
|
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
|
2016-05-19 00:37:25 +02: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
|
|
|
|
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
|
|
|
|
if flags.coverage {
|
|
|
|
coverageFiles = make(android.Paths, 0, len(srcFiles))
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2017-06-15 23:45:18 +02:00
|
|
|
commonFlags := strings.Join([]string{
|
2017-03-31 00:03:04 +02:00
|
|
|
flags.globalFlags,
|
|
|
|
flags.systemIncludeFlags,
|
2017-06-15 23:45:18 +02:00
|
|
|
}, " ")
|
|
|
|
|
|
|
|
toolingCflags := strings.Join([]string{
|
|
|
|
commonFlags,
|
|
|
|
flags.toolingCFlags,
|
|
|
|
flags.conlyFlags,
|
|
|
|
}, " ")
|
|
|
|
|
|
|
|
cflags := strings.Join([]string{
|
|
|
|
commonFlags,
|
2017-03-31 00:03:04 +02:00
|
|
|
flags.cFlags,
|
|
|
|
flags.conlyFlags,
|
|
|
|
}, " ")
|
|
|
|
|
2017-06-15 23:45:18 +02:00
|
|
|
toolingCppflags := strings.Join([]string{
|
|
|
|
commonFlags,
|
|
|
|
flags.toolingCFlags,
|
2018-08-22 23:18:04 +02:00
|
|
|
flags.toolingCppFlags,
|
2017-06-15 23:45:18 +02:00
|
|
|
}, " ")
|
|
|
|
|
2017-03-31 00:03:04 +02:00
|
|
|
cppflags := strings.Join([]string{
|
2017-06-15 23:45:18 +02:00
|
|
|
commonFlags,
|
2017-03-31 00:03:04 +02:00
|
|
|
flags.cFlags,
|
|
|
|
flags.cppFlags,
|
|
|
|
}, " ")
|
|
|
|
|
|
|
|
asflags := strings.Join([]string{
|
2017-06-15 23:45:18 +02:00
|
|
|
commonFlags,
|
2017-03-31 00:03:04 +02:00
|
|
|
flags.asFlags,
|
|
|
|
}, " ")
|
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
|
|
|
|
|
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{
|
|
|
|
"asFlags": flags.yasmFlags,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
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
|
2016-12-03 02:13:24 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
var moduleCflags string
|
2017-06-15 23:45:18 +02:00
|
|
|
var moduleToolingCflags string
|
2015-01-31 02:27:36 +01:00
|
|
|
var ccCmd string
|
2018-10-08 05:54:34 +02:00
|
|
|
tidy := flags.tidy
|
2017-02-10 01:16:31 +01:00
|
|
|
coverage := flags.coverage
|
2018-10-08 05:54:34 +02:00
|
|
|
dump := flags.sAbiDump
|
2019-01-04 08:25:11 +01:00
|
|
|
rule := cc
|
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":
|
|
|
|
rule = ccNoDeps
|
|
|
|
fallthrough
|
|
|
|
case ".S":
|
2018-10-08 05:54:34 +02:00
|
|
|
ccCmd = "clang"
|
2015-01-31 02:27:36 +01:00
|
|
|
moduleCflags = 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
|
2015-01-31 02:27:36 +01:00
|
|
|
case ".c":
|
2018-10-08 05:54:34 +02:00
|
|
|
ccCmd = "clang"
|
2015-01-31 02:27:36 +01:00
|
|
|
moduleCflags = cflags
|
2017-06-15 23:45:18 +02:00
|
|
|
moduleToolingCflags = toolingCflags
|
2019-06-27 23:46:10 +02:00
|
|
|
case ".cpp", ".cc", ".cxx", ".mm":
|
2018-10-08 05:54:34 +02:00
|
|
|
ccCmd = "clang++"
|
2015-01-31 02:27:36 +01:00
|
|
|
moduleCflags = cppflags
|
2017-06-15 23:45:18 +02:00
|
|
|
moduleToolingCflags = toolingCppflags
|
2015-01-31 02:27:36 +01:00
|
|
|
default:
|
|
|
|
ctx.ModuleErrorf("File %s has unknown extension", srcFile)
|
|
|
|
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{
|
2015-04-22 22:07:53 +02:00
|
|
|
"cFlags": moduleCflags,
|
|
|
|
"ccCmd": ccCmd,
|
2015-01-31 02:27:36 +01:00
|
|
|
},
|
|
|
|
})
|
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)
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: clangTidy,
|
|
|
|
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.
|
|
|
|
Implicit: objFile,
|
|
|
|
Args: map[string]string{
|
2017-06-15 23:45:18 +02:00
|
|
|
"cFlags": moduleToolingCflags,
|
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)
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: sAbiDump,
|
|
|
|
Description: "header-abi-dumper " + srcFile.Rel(),
|
|
|
|
Output: sAbiDumpFile,
|
|
|
|
Input: srcFile,
|
|
|
|
Implicit: objFile,
|
2017-02-08 22:45:53 +01:00
|
|
|
Args: map[string]string{
|
2017-06-15 23:45:18 +02:00
|
|
|
"cFlags": moduleToolingCflags,
|
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,
|
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)
|
2016-05-19 00:37:25 +02:00
|
|
|
func TransformObjToStaticLib(ctx android.ModuleContext, objFiles 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"
|
|
|
|
arFlags := "crsD"
|
|
|
|
if !ctx.Darwin() {
|
|
|
|
arFlags += " -format=gnu"
|
|
|
|
}
|
2017-03-16 19:01:23 +01:00
|
|
|
if flags.arFlags != "" {
|
|
|
|
arFlags += " " + flags.arFlags
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: ar,
|
|
|
|
Description: "static link " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Inputs: objFiles,
|
|
|
|
Implicits: deps,
|
2015-01-31 02:27:36 +01:00
|
|
|
Args: map[string]string{
|
|
|
|
"arFlags": arFlags,
|
|
|
|
"arCmd": arCmd,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2016-05-19 00:37:25 +02:00
|
|
|
func TransformObjToDynamicBinary(ctx android.ModuleContext,
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2019-06-08 02:58:59 +02:00
|
|
|
Rule: ld,
|
|
|
|
Description: "link " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
ImplicitOutputs: implicitOutputs,
|
|
|
|
Inputs: objFiles,
|
|
|
|
Implicits: deps,
|
2015-01-31 02:27:36 +01:00
|
|
|
Args: map[string]string{
|
2016-07-21 22:16:49 +02:00
|
|
|
"ldCmd": ldCmd,
|
|
|
|
"crtBegin": crtBegin.String(),
|
|
|
|
"libFlags": strings.Join(libFlagsList, " "),
|
|
|
|
"ldFlags": flags.ldFlags,
|
|
|
|
"crtEnd": crtEnd.String(),
|
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
|
2017-06-26 21:52:58 +02: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")
|
2018-02-24 01:43:23 +01:00
|
|
|
sabiLock.Lock()
|
|
|
|
lsdumpPaths = append(lsdumpPaths, outputFile.String())
|
|
|
|
sabiLock.Unlock()
|
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
|
|
|
|
}
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: sAbiLink,
|
|
|
|
Description: "header-abi-linker " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Inputs: sAbiDumps,
|
2019-01-16 17:18:02 +01:00
|
|
|
Implicits: implicits,
|
2017-02-08 22:45:53 +01:00
|
|
|
Args: map[string]string{
|
2018-01-17 20:11:42 +01:00
|
|
|
"symbolFilter": symbolFilterStr,
|
|
|
|
"arch": ctx.Arch().ArchType.Name,
|
2017-02-08 22:45:53 +01:00
|
|
|
"exportedHeaderFlags": exportedHeaderFlags,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
return android.OptionalPathForPath(outputFile)
|
|
|
|
}
|
|
|
|
|
2017-04-20 15:53:59 +02:00
|
|
|
func UnzipRefDump(ctx android.ModuleContext, zippedRefDump android.Path, baseName string) android.Path {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-02-08 22:45:53 +01:00
|
|
|
func SourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceDump android.Path,
|
2019-02-18 08:40:42 +01:00
|
|
|
baseName, exportedHeaderFlags string, 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 := ""
|
|
|
|
|
2018-01-17 22:13:33 +01:00
|
|
|
localAbiCheckAllowFlags := append([]string(nil), abiCheckAllowFlags...)
|
|
|
|
if exportedHeaderFlags == "" {
|
|
|
|
localAbiCheckAllowFlags = append(localAbiCheckAllowFlags, "-advice-only")
|
|
|
|
}
|
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.
|
|
|
|
localAbiCheckAllowFlags = append(localAbiCheckAllowFlags, "-consider-opaque-types-different")
|
|
|
|
}
|
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 {
|
|
|
|
localAbiCheckAllowFlags = append(localAbiCheckAllowFlags, "-allow-extensions")
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
"allowFlags": strings.Join(localAbiCheckAllowFlags, " "),
|
|
|
|
"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)
|
|
|
|
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
|
2016-05-19 00:37:25 +02:00
|
|
|
func TransformObjsToObj(ctx android.ModuleContext, objFiles android.Paths,
|
|
|
|
flags builderFlags, outputFile android.WritablePath) {
|
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
|
|
|
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-05-09 22:45:28 +02:00
|
|
|
Rule: partialLd,
|
|
|
|
Description: "link " + outputFile.Base(),
|
|
|
|
Output: outputFile,
|
|
|
|
Inputs: objFiles,
|
2015-01-31 02:27:36 +01:00
|
|
|
Args: map[string]string{
|
2015-09-24 00:26:20 +02:00
|
|
|
"ldCmd": ldCmd,
|
2015-11-23 23:01:42 +01:00
|
|
|
"ldFlags": flags.ldFlags,
|
2015-01-31 02:27:36 +01:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-03-26 22:44:11 +01:00
|
|
|
// Generate a rule for runing objcopy --prefix-symbols on a binary
|
2016-05-19 00:37:25 +02:00
|
|
|
func TransformBinaryPrefixSymbols(ctx android.ModuleContext, prefix string, inputFile android.Path,
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func TransformStrip(ctx android.ModuleContext, inputFile android.Path,
|
|
|
|
outputFile android.WritablePath, flags builderFlags) {
|
2016-04-28 23:50:03 +02:00
|
|
|
|
|
|
|
crossCompile := gccCmd(flags.toolchain, "")
|
|
|
|
args := ""
|
|
|
|
if flags.stripAddGnuDebuglink {
|
|
|
|
args += " --add-gnu-debuglink"
|
|
|
|
}
|
|
|
|
if flags.stripKeepMiniDebugInfo {
|
|
|
|
args += " --keep-mini-debug-info"
|
|
|
|
}
|
|
|
|
if flags.stripKeepSymbols {
|
|
|
|
args += " --keep-symbols"
|
|
|
|
}
|
2019-03-30 04:05:14 +01:00
|
|
|
if flags.stripKeepSymbolsList != "" {
|
|
|
|
args += " -k" + flags.stripKeepSymbolsList
|
|
|
|
}
|
2019-05-18 01:39:54 +02:00
|
|
|
if flags.stripKeepSymbolsAndDebugFrame {
|
|
|
|
args += " --keep-symbols-and-debug-frame"
|
|
|
|
}
|
2018-11-08 01:28:49 +01:00
|
|
|
if flags.stripUseGnuStrip {
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func TransformDarwinStrip(ctx android.ModuleContext, inputFile android.Path,
|
|
|
|
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
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-04-24 23:22:25 +02:00
|
|
|
func TransformCoverageFilesToZip(ctx android.ModuleContext,
|
|
|
|
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{}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
}
|
2015-05-01 01:36:18 +02:00
|
|
|
|
2017-05-09 22:34:34 +02:00
|
|
|
func splitListForSize(list android.Paths, limit int) (lists []android.Paths, err error) {
|
2015-05-01 01:36:18 +02:00
|
|
|
var i int
|
|
|
|
|
|
|
|
start := 0
|
|
|
|
bytes := 0
|
|
|
|
for i = range list {
|
2017-05-09 22:34:34 +02:00
|
|
|
l := len(list[i].String())
|
2015-05-01 01:36:18 +02:00
|
|
|
if l > limit {
|
|
|
|
return nil, fmt.Errorf("list element greater than size limit (%d)", limit)
|
|
|
|
}
|
|
|
|
if bytes+l > limit {
|
|
|
|
lists = append(lists, list[start:i])
|
|
|
|
start = i
|
|
|
|
bytes = 0
|
|
|
|
}
|
|
|
|
bytes += l + 1 // count a space between each list element
|
|
|
|
}
|
|
|
|
|
|
|
|
lists = append(lists, list[start:])
|
|
|
|
|
|
|
|
totalLen := 0
|
|
|
|
for _, l := range lists {
|
|
|
|
totalLen += len(l)
|
|
|
|
}
|
|
|
|
if totalLen != len(list) {
|
|
|
|
panic(fmt.Errorf("Failed breaking up list, %d != %d", len(list), totalLen))
|
|
|
|
}
|
|
|
|
return lists, nil
|
|
|
|
}
|