Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1b3352b authored by Logan Chien's avatar Logan Chien Committed by Gerrit Code Review
Browse files

Merge "Add prebuilt ABI checker support to soong"

parents 65fd8ba2 4fcea3d9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -195,6 +195,8 @@ type productVariables struct {
	Arc                              *bool `json:",omitempty"`
	MinimizeJavaDebugInfo            *bool `json:",omitempty"`

	Check_elf_files *bool `json:",omitempty"`

	UncompressPrivAppDex             *bool    `json:",omitempty"`
	ModulesLoadedByPrivilegedModules []string `json:",omitempty"`

+37 −0
Original line number Diff line number Diff line
@@ -362,3 +362,40 @@ func (c *vendorPublicLibraryStubDecorator) AndroidMk(ctx AndroidMkContext, ret *
		fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
	})
}

func (p *prebuiltLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
	ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
		if p.properties.Check_elf_files != nil {
			fmt.Fprintln(w, "LOCAL_CHECK_ELF_FILES :=", *p.properties.Check_elf_files)
		} else {
			// soong_cc_prebuilt.mk does not include check_elf_file.mk by default
			// because cc_library_shared and cc_binary use soong_cc_prebuilt.mk as well.
			// In order to turn on prebuilt ABI checker, set `LOCAL_CHECK_ELF_FILES` to
			// true if `p.properties.Check_elf_files` is not specified.
			fmt.Fprintln(w, "LOCAL_CHECK_ELF_FILES := true")
		}
	})
}

func (p *prebuiltLibraryLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
	ctx.subAndroidMk(ret, p.libraryDecorator)
	if p.shared() {
		ctx.subAndroidMk(ret, &p.prebuiltLinker)
		androidMkWriteAllowUndefinedSymbols(p.baseLinker, ret)
	}
}

func (p *prebuiltBinaryLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
	ctx.subAndroidMk(ret, p.binaryDecorator)
	ctx.subAndroidMk(ret, &p.prebuiltLinker)
	androidMkWriteAllowUndefinedSymbols(p.baseLinker, ret)
}

func androidMkWriteAllowUndefinedSymbols(linker *baseLinker, ret *android.AndroidMkData) {
	ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
		allow := linker.Properties.Allow_undefined_symbols
		if allow != nil {
			fmt.Fprintln(w, "LOCAL_ALLOW_UNDEFINED_SYMBOLS :=", *allow)
		}
	})
}
+5 −0
Original line number Diff line number Diff line
@@ -31,8 +31,13 @@ type prebuiltLinkerInterface interface {

type prebuiltLinker struct {
	android.Prebuilt

	properties struct {
		Srcs []string `android:"arch_variant"`

		// Check the prebuilt ELF files (e.g. DT_SONAME, DT_NEEDED, resolution of undefined
		// symbols, etc), default true.
		Check_elf_files *bool
	}
}

+6 −0
Original line number Diff line number Diff line
@@ -60,6 +60,10 @@ type vndkPrebuiltProperties struct {

	// Prebuilt files for each arch.
	Srcs []string `android:"arch_variant"`

	// Check the prebuilt ELF files (e.g. DT_SONAME, DT_NEEDED, resolution of undefined symbols,
	// etc).
	Check_elf_files *bool
}

type vndkPrebuiltLibraryDecorator struct {
@@ -155,6 +159,8 @@ func vndkPrebuiltSharedLibrary() *Module {
		libraryDecorator: library,
	}

	prebuilt.properties.Check_elf_files = BoolPtr(false)

	module.compiler = nil
	module.linker = prebuilt
	module.installer = prebuilt