summaryrefslogtreecommitdiff
path: root/cc
diff options
context:
space:
mode:
Diffstat (limited to 'cc')
-rw-r--r--cc/androidmk.go13
-rw-r--r--cc/sdk.go6
-rw-r--r--cc/sdk_test.go92
3 files changed, 8 insertions, 103 deletions
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 980dd0762..ce35b5c44 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -124,17 +124,14 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
}
}
}
- if c.Properties.IsSdkVariant {
+ if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake {
// Make the SDK variant uninstallable so that there are not two rules to install
// to the same location.
entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
-
- if c.Properties.SdkAndPlatformVariantVisibleToMake {
- // Add the unsuffixed name to SOONG_SDK_VARIANT_MODULES so that Make can rewrite
- // dependencies to the .sdk suffix when building a module that uses the SDK.
- entries.SetString("SOONG_SDK_VARIANT_MODULES",
- "$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
- }
+ // Add the unsuffixed name to SOONG_SDK_VARIANT_MODULES so that Make can rewrite
+ // dependencies to the .sdk suffix when building a module that uses the SDK.
+ entries.SetString("SOONG_SDK_VARIANT_MODULES",
+ "$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
}
},
},
diff --git a/cc/sdk.go b/cc/sdk.go
index 4f361eb16..6341926ff 100644
--- a/cc/sdk.go
+++ b/cc/sdk.go
@@ -47,16 +47,16 @@ func sdkMutator(ctx android.BottomUpMutatorContext) {
// Mark the SDK variant.
modules[1].(*Module).Properties.IsSdkVariant = true
- // SDK variant is not supposed to be installed
- modules[1].(*Module).Properties.PreventInstall = true
if ctx.Config().UnbundledBuildApps() {
// For an unbundled apps build, hide the platform variant from Make.
modules[0].(*Module).Properties.HideFromMake = true
+ modules[0].(*Module).Properties.PreventInstall = true
} else {
// For a platform build, mark the SDK variant so that it gets a ".sdk" suffix when
// exposed to Make.
modules[1].(*Module).Properties.SdkAndPlatformVariantVisibleToMake = true
+ modules[1].(*Module).Properties.PreventInstall = true
}
ctx.AliasVariation("")
} else if isCcModule && ccModule.isImportedApiLibrary() {
@@ -74,8 +74,8 @@ func sdkMutator(ctx android.BottomUpMutatorContext) {
if apiLibrary.hasApexStubs() {
// For an unbundled apps build, hide the platform variant from Make.
modules[1].(*Module).Properties.HideFromMake = true
- modules[1].(*Module).Properties.PreventInstall = true
}
+ modules[1].(*Module).Properties.PreventInstall = true
} else {
// For a platform build, mark the SDK variant so that it gets a ".sdk" suffix when
// exposed to Make.
diff --git a/cc/sdk_test.go b/cc/sdk_test.go
index 790440cb9..61925e30c 100644
--- a/cc/sdk_test.go
+++ b/cc/sdk_test.go
@@ -101,95 +101,3 @@ func TestSdkMutator(t *testing.T) {
assertDep(t, libsdkNDK, libcxxNDK)
assertDep(t, libsdkPlatform, libcxxPlatform)
}
-
-func TestMakeModuleNameForSdkVariant(t *testing.T) {
- bp := `
- cc_library {
- name: "libfoo",
- srcs: ["main_test.cpp"],
- sdk_version: "current",
- stl: "none",
- }
- `
- platformVariant := "android_arm64_armv8-a_shared"
- sdkVariant := "android_arm64_armv8-a_sdk_shared"
- testCases := []struct {
- name string
- unbundledApps []string
- variant string
- skipInstall bool // soong skips install
- hideFromMake bool // no make entry
- makeUninstallable bool // make skips install
- makeModuleName string
- }{
- {
- name: "platform variant in normal builds",
- unbundledApps: nil,
- variant: platformVariant,
- // installable in soong
- skipInstall: false,
- // visiable in Make as "libfoo"
- hideFromMake: false,
- makeModuleName: "libfoo",
- // installable in Make
- makeUninstallable: false,
- },
- {
- name: "sdk variant in normal builds",
- unbundledApps: nil,
- variant: sdkVariant,
- // soong doesn't install
- skipInstall: true,
- // visible in Make as "libfoo.sdk"
- hideFromMake: false,
- makeModuleName: "libfoo.sdk",
- // but not installed
- makeUninstallable: true,
- },
- {
- name: "platform variant in unbunded builds",
- unbundledApps: []string{"bar"},
- variant: platformVariant,
- // installable in soong
- skipInstall: false,
- // hidden from make
- hideFromMake: true,
- },
- {
- name: "sdk variant in unbunded builds",
- unbundledApps: []string{"bar"},
- variant: sdkVariant,
- // soong doesn't install
- skipInstall: true,
- // visible in Make as "libfoo"
- hideFromMake: false,
- makeModuleName: "libfoo",
- // but not installed
- makeUninstallable: true,
- },
- }
- for _, tc := range testCases {
- t.Run(tc.name, func(t *testing.T) {
- fixture := android.GroupFixturePreparers(prepareForCcTest,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.Unbundled_build_apps = tc.unbundledApps
- }),
- )
- ctx := fixture.RunTestWithBp(t, bp).TestContext
- module := ctx.ModuleForTests("libfoo", tc.variant).Module().(*Module)
- android.AssertBoolEquals(t, "IsSkipInstall", tc.skipInstall, module.IsSkipInstall())
- android.AssertBoolEquals(t, "HideFromMake", tc.hideFromMake, module.HiddenFromMake())
- if !tc.hideFromMake {
- entries := android.AndroidMkEntriesForTest(t, ctx, module)[0]
- android.AssertStringEquals(t, "LOCAL_MODULE",
- tc.makeModuleName, entries.EntryMap["LOCAL_MODULE"][0])
- actualUninstallable := false
- if actual, ok := entries.EntryMap["LOCAL_UNINSTALLABLE_MODULE"]; ok {
- actualUninstallable = "true" == actual[0]
- }
- android.AssertBoolEquals(t, "LOCAL_UNINSTALLABLE_MODULE",
- tc.makeUninstallable, actualUninstallable)
- }
- })
- }
-}