Disable cc_cmake_snapshot outside of Linux
Test: cd build/soong/cc && go test Bug: 339782737 Change-Id: Ide6693123c741a39d37164a1a39841be1bd84862
This commit is contained in:
parent
cd8dc70806
commit
d848dcc9e6
2 changed files with 68 additions and 7 deletions
|
@ -494,13 +494,30 @@ func getIncludeDirs(ctx android.ModuleContext, m *Module) []string {
|
|||
return nil
|
||||
}
|
||||
|
||||
func cmakeSnapshotLoadHook(ctx android.LoadHookContext) {
|
||||
props := struct {
|
||||
Target struct {
|
||||
Darwin struct {
|
||||
Enabled *bool
|
||||
}
|
||||
Windows struct {
|
||||
Enabled *bool
|
||||
}
|
||||
}
|
||||
}{}
|
||||
props.Target.Darwin.Enabled = proptools.BoolPtr(false)
|
||||
props.Target.Windows.Enabled = proptools.BoolPtr(false)
|
||||
ctx.AppendProperties(&props)
|
||||
}
|
||||
|
||||
// cmake_snapshot allows defining source packages for release outside of Android build tree.
|
||||
// As a result of cmake_snapshot module build, a zip file is generated with CMake build definitions
|
||||
// for selected source modules, their dependencies and optionally also the source code itself.
|
||||
func CmakeSnapshotFactory() android.Module {
|
||||
module := &CmakeSnapshot{}
|
||||
module.AddProperties(&module.Properties)
|
||||
android.InitAndroidModule(module)
|
||||
android.AddLoadHook(module, cmakeSnapshotLoadHook)
|
||||
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibFirst)
|
||||
return module
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package cc
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -23,14 +24,16 @@ import (
|
|||
|
||||
func wasGenerated(t *testing.T, m *android.TestingModule, fileName string, ruleType string) {
|
||||
t.Helper()
|
||||
ruleName := m.Output(fileName).Rule.String()
|
||||
ruleName := "<nil>"
|
||||
if rule := m.MaybeOutput(fileName).Rule; rule != nil {
|
||||
ruleName = rule.String()
|
||||
}
|
||||
if !strings.HasSuffix(ruleName, ruleType) {
|
||||
t.Errorf("Main Cmake file wasn't generated, expected rule %v, found %v", ruleType, ruleName)
|
||||
t.Errorf("Main Cmake file wasn't generated properly, expected rule %v, found %v", ruleType, ruleName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEmptyCmakeSnapshot(t *testing.T) {
|
||||
t.Skip("Failing on sdk-sdk_mac target")
|
||||
t.Parallel()
|
||||
result := PrepareForIntegrationTestWithCc.RunTestWithBp(t, `
|
||||
cc_cmake_snapshot {
|
||||
|
@ -40,14 +43,17 @@ func TestEmptyCmakeSnapshot(t *testing.T) {
|
|||
include_sources: true,
|
||||
}`)
|
||||
|
||||
snapshotModule := result.ModuleForTests("foo", "")
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skip("CMake snapshots are only supported on Linux")
|
||||
}
|
||||
|
||||
snapshotModule := result.ModuleForTests("foo", "linux_glibc_x86_64")
|
||||
|
||||
wasGenerated(t, &snapshotModule, "CMakeLists.txt", "rawFileCopy")
|
||||
wasGenerated(t, &snapshotModule, "foo.zip", "")
|
||||
}
|
||||
|
||||
func TestCmakeSnapshotWithBinary(t *testing.T) {
|
||||
t.Skip("Failing on sdk-sdk_mac target")
|
||||
t.Parallel()
|
||||
xtra := android.FixtureAddTextFile("some/module/Android.bp", `
|
||||
cc_binary {
|
||||
|
@ -65,7 +71,45 @@ func TestCmakeSnapshotWithBinary(t *testing.T) {
|
|||
include_sources: true,
|
||||
}`)
|
||||
|
||||
snapshotModule := result.ModuleForTests("foo", "")
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skip("CMake snapshots are only supported on Linux")
|
||||
}
|
||||
|
||||
snapshotModule := result.ModuleForTests("foo", "linux_glibc_x86_64")
|
||||
|
||||
wasGenerated(t, &snapshotModule, "some/module/CMakeLists.txt", "rawFileCopy")
|
||||
}
|
||||
|
||||
func TestCmakeSnapshotAsTestData(t *testing.T) {
|
||||
t.Parallel()
|
||||
result := PrepareForIntegrationTestWithCc.RunTestWithBp(t, `
|
||||
cc_test {
|
||||
name: "foo_test",
|
||||
gtest: false,
|
||||
srcs: [
|
||||
"foo_test.c",
|
||||
],
|
||||
data: [
|
||||
":foo",
|
||||
],
|
||||
target: {
|
||||
android: {enabled: false},
|
||||
},
|
||||
}
|
||||
|
||||
cc_cmake_snapshot {
|
||||
name: "foo",
|
||||
modules: [],
|
||||
prebuilts: ["libc++"],
|
||||
include_sources: true,
|
||||
}`)
|
||||
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skip("CMake snapshots are only supported on Linux")
|
||||
}
|
||||
|
||||
snapshotModule := result.ModuleForTests("foo", "linux_glibc_x86_64")
|
||||
|
||||
wasGenerated(t, &snapshotModule, "CMakeLists.txt", "rawFileCopy")
|
||||
wasGenerated(t, &snapshotModule, "foo.zip", "")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue