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

Commit 8c48fac4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Implement stubs.symbol_file and stubs.versions for cc_library_shared...

Merge "Implement stubs.symbol_file and stubs.versions for cc_library_shared bp2build." am: 9e46741e am: d3066c7d

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1940900

Change-Id: I3ab3e6ea127a7da8850974675b1813294b1a83ea
parents 4d493fdf d3066c7d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -344,7 +344,7 @@ func getFinalCodenamesMap(config Config) map[string]int {

var apiLevelsMapKey = NewOnceKey("ApiLevelsMap")

func getApiLevelsMap(config Config) map[string]int {
func GetApiLevelsMap(config Config) map[string]int {
	return config.Once(apiLevelsMapKey, func() interface{} {
		apiLevelsMap := map[string]int{
			"G":     9,
@@ -374,7 +374,7 @@ func getApiLevelsMap(config Config) map[string]int {
}

func (a *apiLevelsSingleton) GenerateBuildActions(ctx SingletonContext) {
	apiLevelsMap := getApiLevelsMap(ctx.Config())
	apiLevelsMap := GetApiLevelsMap(ctx.Config())
	apiLevelsJson := GetApiLevelsJson(ctx)
	createApiLevelsJson(ctx, apiLevelsJson, apiLevelsMap)
}
+1 −0
Original line number Diff line number Diff line
@@ -226,6 +226,7 @@ var (
		"packages/apps/WallpaperPicker":/* recursive = */ false,

		"prebuilts/gcc":/* recursive = */ true,
		"prebuilts/build-tools":/* recursive = */ false,
		"prebuilts/sdk":/* recursive = */ false,
		"prebuilts/sdk/current/extras/app-toolkit":/* recursive = */ false,
		"prebuilts/sdk/current/support":/* recursive = */ false,
+31 −0
Original line number Diff line number Diff line
@@ -1297,6 +1297,8 @@ func makeCcLibraryTargets(name string, attrs attrNameToString) []string {
		"additional_linker_inputs": true,
		"linkopts":                 true,
		"strip":                    true,
		"stubs_symbol_file":        true,
		"stubs_versions":           true,
	}
	sharedAttrs := attrNameToString{}
	staticAttrs := attrNameToString{}
@@ -2390,3 +2392,32 @@ func TestCcLibraryStaticDisabledForSomeArch(t *testing.T) {
		}),
		}})
}

func TestCcLibraryStubs(t *testing.T) {
	runCcLibraryTestCase(t, bp2buildTestCase{
		description:                "cc_library stubs",
		moduleTypeUnderTest:        "cc_library",
		moduleTypeUnderTestFactory: cc.LibraryFactory,
		dir:                        "foo/bar",
		filesystem: map[string]string{
			"foo/bar/Android.bp": `
cc_library {
    name: "a",
    stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
    bazel_module: { bp2build_available: true },
    include_build_directory: false,
}
`,
		},
		blueprint: soongCcLibraryPreamble,
		expectedBazelTargets: makeCcLibraryTargets("a", attrNameToString{
			"stubs_symbol_file": `"a.map.txt"`,
			"stubs_versions": `[
        "28",
        "29",
        "current",
    ]`,
		}),
	},
	)
}
+30 −0
Original line number Diff line number Diff line
@@ -464,3 +464,33 @@ func TestCcLibrarySharedUseVersionLib(t *testing.T) {
		},
	})
}

func TestCcLibrarySharedStubs(t *testing.T) {
	runCcLibrarySharedTestCase(t, bp2buildTestCase{
		description:                "cc_library_shared stubs",
		moduleTypeUnderTest:        "cc_library_shared",
		moduleTypeUnderTestFactory: cc.LibrarySharedFactory,
		dir:                        "foo/bar",
		filesystem: map[string]string{
			"foo/bar/Android.bp": `
cc_library_shared {
	name: "a",
	stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
	bazel_module: { bp2build_available: true },
	include_build_directory: false,
}
`,
		},
		blueprint: soongCcLibraryPreamble,
		expectedBazelTargets: []string{makeBazelTarget("cc_library_shared", "a", attrNameToString{
			"stubs_symbol_file": `"a.map.txt"`,
			"stubs_versions": `[
        "28",
        "29",
        "current",
    ]`,
		}),
		},
	},
	)
}
+8 −0
Original line number Diff line number Diff line
package bp2build

import (
	"encoding/json"
	"fmt"
	"reflect"
	"strings"
@@ -27,6 +28,13 @@ func CreateSoongInjectionFiles(cfg android.Config, metrics CodegenMetrics) []Baz

	files = append(files, newFile("product_config", "soong_config_variables.bzl", cfg.Bp2buildSoongConfigDefinitions.String()))

	apiLevelsContent, err := json.Marshal(android.GetApiLevelsMap(cfg))
	if err != nil {
		panic(err)
	}
	files = append(files, newFile("api_levels", GeneratedBuildFileName, `exports_files(["api_levels.json"])`))
	files = append(files, newFile("api_levels", "api_levels.json", string(apiLevelsContent)))

	return files
}

Loading