Skip to content

Commit

Permalink
Soong package structure refactoring
Browse files Browse the repository at this point in the history
Give prebuilt_etc and sh_binary their own packages and split the
gigantic main Android.bp up to small, per-package ones.

(This is a cherry-pick change.)

Test: m nothing, TreeHugger
Bug: 156980228
Change-Id: I7b00cd344b9f16861f1ff39edf0029f016b853d0
Merged-In: I7b00cd344b9f16861f1ff39edf0029f016b853d0
  • Loading branch information
gyias committed Jun 2, 2020
1 parent c344620 commit fccad6b
Show file tree
Hide file tree
Showing 31 changed files with 784 additions and 688 deletions.
546 changes: 0 additions & 546 deletions Android.bp

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions android/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
bootstrap_go_package {
name: "soong-android",
pkgPath: "android/soong/android",
deps: [
"blueprint",
"blueprint-bootstrap",
"soong",
"soong-android-soongconfig",
"soong-env",
"soong-shared",
],
srcs: [
"androidmk.go",
"apex.go",
"api_levels.go",
"arch.go",
"config.go",
"csuite_config.go",
"defaults.go",
"defs.go",
"expand.go",
"filegroup.go",
"hooks.go",
"image.go",
"makevars.go",
"module.go",
"mutator.go",
"namespace.go",
"neverallow.go",
"notices.go",
"onceper.go",
"override_module.go",
"package.go",
"package_ctx.go",
"path_properties.go",
"paths.go",
"prebuilt.go",
"proto.go",
"register.go",
"rule_builder.go",
"sandbox.go",
"sdk.go",
"singleton.go",
"soong_config_modules.go",
"testing.go",
"util.go",
"variable.go",
"visibility.go",
"vts_config.go",
"writedocs.go",

// Lock down environment access last
"env.go",
],
testSrcs: [
"android_test.go",
"androidmk_test.go",
"arch_test.go",
"config_test.go",
"csuite_config_test.go",
"expand_test.go",
"module_test.go",
"mutator_test.go",
"namespace_test.go",
"neverallow_test.go",
"onceper_test.go",
"package_test.go",
"path_properties_test.go",
"paths_test.go",
"prebuilt_test.go",
"rule_builder_test.go",
"soong_config_modules_test.go",
"util_test.go",
"variable_test.go",
"visibility_test.go",
"vts_config_test.go",
],
}
13 changes: 13 additions & 0 deletions android/soongconfig/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bootstrap_go_package {
name: "soong-android-soongconfig",
pkgPath: "android/soong/android/soongconfig",
deps: [
"blueprint",
"blueprint-parser",
"blueprint-proptools",
],
srcs: [
"config.go",
"modules.go",
],
}
27 changes: 27 additions & 0 deletions apex/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
bootstrap_go_package {
name: "soong-apex",
pkgPath: "android/soong/apex",
deps: [
"blueprint",
"soong",
"soong-android",
"soong-cc",
"soong-java",
"soong-python",
"soong-sh",
],
srcs: [
"androidmk.go",
"apex.go",
"apex_singleton.go",
"builder.go",
"key.go",
"prebuilt.go",
"vndk.go",
],
testSrcs: [
"apex_test.go",
"vndk_test.go",
],
pluginFor: ["soong_build"],
}
20 changes: 11 additions & 9 deletions apex/apex.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ import (
"strings"
"sync"

"github.com/google/blueprint"
"github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/proptools"

"android/soong/android"
"android/soong/cc"
prebuilt_etc "android/soong/etc"
"android/soong/java"
"android/soong/python"

"github.com/google/blueprint"
"github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/proptools"
"android/soong/sh"
)

const (
Expand Down Expand Up @@ -1661,7 +1663,7 @@ func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb boots
return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
}

func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) apexFile {
func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile {
dirInApex := filepath.Join("bin", sh.SubDir())
fileToCopy := sh.OutputFile()
af := newApexFile(ctx, fileToCopy, sh.Name(), dirInApex, shBinary, sh)
Expand All @@ -1683,7 +1685,7 @@ func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaDependency, m
return af
}

func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt android.PrebuiltEtcModule, depName string) apexFile {
func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile {
dirInApex := filepath.Join("etc", prebuilt.SubDir())
fileToCopy := prebuilt.OutputFile()
return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
Expand Down Expand Up @@ -1944,7 +1946,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if cc, ok := child.(*cc.Module); ok {
filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
return true // track transitive dependencies
} else if sh, ok := child.(*android.ShBinary); ok {
} else if sh, ok := child.(*sh.ShBinary); ok {
filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
} else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
Expand Down Expand Up @@ -1985,7 +1987,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
}
case prebuiltTag:
if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
} else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok {
filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName))
Expand Down Expand Up @@ -2082,7 +2084,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
return false
} else if java.IsXmlPermissionsFileDepTag(depTag) {
if prebuilt, ok := child.(android.PrebuiltEtcModule); ok {
if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
}
} else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
Expand Down
6 changes: 4 additions & 2 deletions apex/apex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import (
"android/soong/android"
"android/soong/cc"
"android/soong/dexpreopt"
prebuilt_etc "android/soong/etc"
"android/soong/java"
"android/soong/sh"
)

var buildDir string
Expand Down Expand Up @@ -209,9 +211,9 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
ctx.RegisterModuleType("cc_test", cc.TestFactory)
ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory)
ctx.RegisterModuleType("vndk_libraries_txt", cc.VndkLibrariesTxtFactory)
ctx.RegisterModuleType("prebuilt_etc", android.PrebuiltEtcFactory)
ctx.RegisterModuleType("prebuilt_etc", prebuilt_etc.PrebuiltEtcFactory)
ctx.RegisterModuleType("platform_compat_config", java.PlatformCompatConfigFactory)
ctx.RegisterModuleType("sh_binary", android.ShBinaryFactory)
ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
java.RegisterJavaBuildComponents(ctx)
java.RegisterSystemModulesBuildComponents(ctx)
Expand Down
87 changes: 87 additions & 0 deletions cc/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
bootstrap_go_package {
name: "soong-cc",
pkgPath: "android/soong/cc",
deps: [
"blueprint",
"blueprint-pathtools",
"soong",
"soong-android",
"soong-cc-config",
"soong-etc",
"soong-genrule",
"soong-tradefed",
],
srcs: [
"androidmk.go",
"builder.go",
"cc.go",
"ccdeps.go",
"check.go",
"coverage.go",
"gen.go",
"linkable.go",
"lto.go",
"makevars.go",
"pgo.go",
"prebuilt.go",
"proto.go",
"rs.go",
"sanitize.go",
"sabi.go",
"sdk.go",
"snapshot_utils.go",
"stl.go",
"strip.go",
"sysprop.go",
"tidy.go",
"util.go",
"vendor_snapshot.go",
"vndk.go",
"vndk_prebuilt.go",

"cflag_artifacts.go",
"cmakelists.go",
"compdb.go",
"compiler.go",
"installer.go",
"linker.go",

"binary.go",
"binary_sdk_member.go",
"fuzz.go",
"library.go",
"library_headers.go",
"library_sdk_member.go",
"object.go",
"test.go",
"toolchain_library.go",

"ndk_prebuilt.go",
"ndk_headers.go",
"ndk_library.go",
"ndk_sysroot.go",

"llndk_library.go",

"kernel_headers.go",

"genrule.go",

"vendor_public_library.go",

"testing.go",
],
testSrcs: [
"cc_test.go",
"compiler_test.go",
"gen_test.go",
"genrule_test.go",
"library_headers_test.go",
"library_test.go",
"object_test.go",
"prebuilt_test.go",
"proto_test.go",
"test_data_test.go",
],
pluginFor: ["soong_build"],
}
32 changes: 32 additions & 0 deletions cc/config/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
bootstrap_go_package {
name: "soong-cc-config",
pkgPath: "android/soong/cc/config",
deps: [
"soong-android",
"soong-remoteexec",
],
srcs: [
"clang.go",
"global.go",
"tidy.go",
"toolchain.go",
"vndk.go",

"arm_device.go",
"arm64_device.go",
"arm64_fuchsia_device.go",
"mips_device.go",
"mips64_device.go",
"x86_device.go",
"x86_64_device.go",
"x86_64_fuchsia_device.go",

"x86_darwin_host.go",
"x86_linux_host.go",
"x86_linux_bionic_host.go",
"x86_windows_host.go",
],
testSrcs: [
"tidy_test.go",
],
}
3 changes: 2 additions & 1 deletion cc/vndk.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"android/soong/android"
"android/soong/cc/config"
"android/soong/etc"
)

const (
Expand Down Expand Up @@ -410,7 +411,7 @@ type vndkLibrariesTxt struct {
outputFile android.OutputPath
}

var _ android.PrebuiltEtcModule = &vndkLibrariesTxt{}
var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{}
var _ android.OutputFileProducer = &vndkLibrariesTxt{}

// vndk_libraries_txt is a special kind of module type in that it name is one of
Expand Down
7 changes: 7 additions & 0 deletions env/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bootstrap_go_package {
name: "soong-env",
pkgPath: "android/soong/env",
srcs: [
"env.go",
],
}
16 changes: 16 additions & 0 deletions etc/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
bootstrap_go_package {
name: "soong-etc",
pkgPath: "android/soong/etc",
deps: [
"blueprint",
"soong",
"soong-android",
],
srcs: [
"prebuilt_etc.go",
],
testSrcs: [
"prebuilt_etc_test.go",
],
pluginFor: ["soong_build"],
}
Loading

0 comments on commit fccad6b

Please sign in to comment.