Build native libraries used by layoutlib.
Bug: 303904212 Test: m layoutlib dist; CIs Change-Id: Id77cba97b2f66997431beb78ecc9d9b74b64b803
This commit is contained in:
@@ -445,6 +445,10 @@ func (binary *binaryDecorator) unstrippedOutputFilePath() android.Path {
|
|||||||
return binary.unstrippedOutputFile
|
return binary.unstrippedOutputFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (binary *binaryDecorator) strippedAllOutputFilePath() android.Path {
|
||||||
|
panic("Not implemented.")
|
||||||
|
}
|
||||||
|
|
||||||
func (binary *binaryDecorator) setSymlinkList(ctx ModuleContext) {
|
func (binary *binaryDecorator) setSymlinkList(ctx ModuleContext) {
|
||||||
for _, symlink := range binary.Properties.Symlinks {
|
for _, symlink := range binary.Properties.Symlinks {
|
||||||
binary.symlinks = append(binary.symlinks,
|
binary.symlinks = append(binary.symlinks,
|
||||||
|
@@ -1052,6 +1052,9 @@ func transformStrip(ctx android.ModuleContext, inputFile android.Path,
|
|||||||
if flags.StripKeepSymbolsAndDebugFrame {
|
if flags.StripKeepSymbolsAndDebugFrame {
|
||||||
args += " --keep-symbols-and-debug-frame"
|
args += " --keep-symbols-and-debug-frame"
|
||||||
}
|
}
|
||||||
|
if ctx.Windows() {
|
||||||
|
args += " --windows"
|
||||||
|
}
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: strip,
|
Rule: strip,
|
||||||
|
6
cc/cc.go
6
cc/cc.go
@@ -617,6 +617,7 @@ type linker interface {
|
|||||||
link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path
|
link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path
|
||||||
appendLdflags([]string)
|
appendLdflags([]string)
|
||||||
unstrippedOutputFilePath() android.Path
|
unstrippedOutputFilePath() android.Path
|
||||||
|
strippedAllOutputFilePath() android.Path
|
||||||
|
|
||||||
nativeCoverage() bool
|
nativeCoverage() bool
|
||||||
coverageOutputFilePath() android.OptionalPath
|
coverageOutputFilePath() android.OptionalPath
|
||||||
@@ -3634,6 +3635,11 @@ func (c *Module) OutputFiles(tag string) (android.Paths, error) {
|
|||||||
return android.PathsIfNonNil(c.linker.unstrippedOutputFilePath()), nil
|
return android.PathsIfNonNil(c.linker.unstrippedOutputFilePath()), nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
case "stripped_all":
|
||||||
|
if c.linker != nil {
|
||||||
|
return android.PathsIfNonNil(c.linker.strippedAllOutputFilePath()), nil
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
|
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
|
||||||
}
|
}
|
||||||
|
@@ -4758,3 +4758,29 @@ func TestCcBuildBrokenClangCFlags(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStrippedAllOutputFile(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
bp := `
|
||||||
|
cc_library {
|
||||||
|
name: "test_lib",
|
||||||
|
srcs: ["test_lib.cpp"],
|
||||||
|
dist: {
|
||||||
|
targets: [ "dist_target" ],
|
||||||
|
tag: "stripped_all",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
||||||
|
ctx := testCcWithConfig(t, config)
|
||||||
|
module := ctx.ModuleForTests("test_lib", "android_arm_armv7-a-neon_shared").Module()
|
||||||
|
outputFile, err := module.(android.OutputFileProducer).OutputFiles("stripped_all")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Expected cc_library to produce output files, error: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !strings.HasSuffix(outputFile.Strings()[0], "/stripped_all/test_lib.so") {
|
||||||
|
t.Errorf("Unexpected output file: %s", outputFile.Strings()[0])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -400,6 +400,8 @@ type libraryDecorator struct {
|
|||||||
|
|
||||||
// Location of the linked, unstripped library for shared libraries
|
// Location of the linked, unstripped library for shared libraries
|
||||||
unstrippedOutputFile android.Path
|
unstrippedOutputFile android.Path
|
||||||
|
// Location of the linked, stripped library for shared libraries, strip: "all"
|
||||||
|
strippedAllOutputFile android.Path
|
||||||
|
|
||||||
// Location of the file that should be copied to dist dir when requested
|
// Location of the file that should be copied to dist dir when requested
|
||||||
distFile android.Path
|
distFile android.Path
|
||||||
@@ -1201,6 +1203,17 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate an output file for dist as if strip: "all" is set on the module.
|
||||||
|
// Currently this is for layoutlib release process only.
|
||||||
|
for _, dist := range ctx.Module().(*Module).Dists() {
|
||||||
|
if dist.Tag != nil && *dist.Tag == "stripped_all" {
|
||||||
|
strippedAllOutputFile := android.PathForModuleOut(ctx, "stripped_all", fileName)
|
||||||
|
transformStrip(ctx, outputFile, strippedAllOutputFile, StripFlags{Toolchain: flags.Toolchain})
|
||||||
|
library.strippedAllOutputFile = strippedAllOutputFile
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sharedLibs := deps.EarlySharedLibs
|
sharedLibs := deps.EarlySharedLibs
|
||||||
sharedLibs = append(sharedLibs, deps.SharedLibs...)
|
sharedLibs = append(sharedLibs, deps.SharedLibs...)
|
||||||
sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
|
sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
|
||||||
@@ -1262,6 +1275,10 @@ func (library *libraryDecorator) unstrippedOutputFilePath() android.Path {
|
|||||||
return library.unstrippedOutputFile
|
return library.unstrippedOutputFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) strippedAllOutputFilePath() android.Path {
|
||||||
|
return library.strippedAllOutputFile
|
||||||
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) disableStripping() {
|
func (library *libraryDecorator) disableStripping() {
|
||||||
library.stripper.StripProperties.Strip.None = BoolPtr(true)
|
library.stripper.StripProperties.Strip.None = BoolPtr(true)
|
||||||
}
|
}
|
||||||
|
@@ -219,6 +219,10 @@ func (object *objectLinker) unstrippedOutputFilePath() android.Path {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (object *objectLinker) strippedAllOutputFilePath() android.Path {
|
||||||
|
panic("Not implemented.")
|
||||||
|
}
|
||||||
|
|
||||||
func (object *objectLinker) nativeCoverage() bool {
|
func (object *objectLinker) nativeCoverage() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
# --keep-symbols
|
# --keep-symbols
|
||||||
# --keep-symbols-and-debug-frame
|
# --keep-symbols-and-debug-frame
|
||||||
# --remove-build-id
|
# --remove-build-id
|
||||||
|
# --windows
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@ Options:
|
|||||||
--keep-symbols Keep symbols in out-file
|
--keep-symbols Keep symbols in out-file
|
||||||
--keep-symbols-and-debug-frame Keep symbols and .debug_frame in out-file
|
--keep-symbols-and-debug-frame Keep symbols and .debug_frame in out-file
|
||||||
--remove-build-id Remove the gnu build-id section in out-file
|
--remove-build-id Remove the gnu build-id section in out-file
|
||||||
|
--windows Input file is Windows DLL or executable
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -50,7 +52,11 @@ EOF
|
|||||||
do_strip() {
|
do_strip() {
|
||||||
# GNU strip --strip-all does not strip .ARM.attributes,
|
# GNU strip --strip-all does not strip .ARM.attributes,
|
||||||
# so we tell llvm-strip to keep it too.
|
# so we tell llvm-strip to keep it too.
|
||||||
"${CLANG_BIN}/llvm-strip" --strip-all --keep-section=.ARM.attributes "${infile}" -o "${outfile}.tmp"
|
local keep_section=--keep-section=.ARM.attributes
|
||||||
|
if [ -n "${windows}" ]; then
|
||||||
|
keep_section=
|
||||||
|
fi
|
||||||
|
"${CLANG_BIN}/llvm-strip" --strip-all ${keep_section} "${infile}" -o "${outfile}.tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
do_strip_keep_symbols_and_debug_frame() {
|
do_strip_keep_symbols_and_debug_frame() {
|
||||||
@@ -149,6 +155,7 @@ while getopts $OPTSTRING opt; do
|
|||||||
keep-symbols) keep_symbols=true ;;
|
keep-symbols) keep_symbols=true ;;
|
||||||
keep-symbols-and-debug-frame) keep_symbols_and_debug_frame=true ;;
|
keep-symbols-and-debug-frame) keep_symbols_and_debug_frame=true ;;
|
||||||
remove-build-id) remove_build_id=true ;;
|
remove-build-id) remove_build_id=true ;;
|
||||||
|
windows) windows=true ;;
|
||||||
*) echo "Unknown option --${OPTARG}"; usage ;;
|
*) echo "Unknown option --${OPTARG}"; usage ;;
|
||||||
esac;;
|
esac;;
|
||||||
?) usage ;;
|
?) usage ;;
|
||||||
|
Reference in New Issue
Block a user