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

Commit 4b79e98a authored by Jaewoong Jung's avatar Jaewoong Jung
Browse files

Soong package structure refactoring

Give prebuilt_etc and sh_binary their own packages and split the
gigantic main Android.bp up to small, per-package ones.

Test: m nothing, TreeHugger
Bug: 156980228
Change-Id: I7b00cd344b9f16861f1ff39edf0029f016b853d0
parent a91b64d3
Loading
Loading
Loading
Loading
+0 −548
Original line number Diff line number Diff line
@@ -10,14 +10,6 @@ subdirs = [
    "ui/*",
]

bootstrap_go_package {
    name: "soong-env",
    pkgPath: "android/soong/env",
    srcs: [
        "env/env.go",
    ],
}

bootstrap_go_package {
    name: "soong",
    pkgPath: "android/soong",
@@ -29,546 +21,6 @@ bootstrap_go_package {
    ],
}

bootstrap_go_package {
    name: "soong-android",
    pkgPath: "android/soong/android",
    deps: [
        "blueprint",
        "blueprint-bootstrap",
        "soong",
        "soong-android-soongconfig",
        "soong-env",
        "soong-shared",
        "soong-ui-metrics_proto",
    ],
    srcs: [
        "android/androidmk.go",
        "android/apex.go",
        "android/api_levels.go",
        "android/arch.go",
        "android/config.go",
        "android/csuite_config.go",
        "android/defaults.go",
        "android/defs.go",
        "android/expand.go",
        "android/filegroup.go",
        "android/hooks.go",
        "android/image.go",
        "android/makevars.go",
        "android/metrics.go",
        "android/module.go",
        "android/mutator.go",
        "android/namespace.go",
        "android/neverallow.go",
        "android/notices.go",
        "android/onceper.go",
        "android/override_module.go",
        "android/package.go",
        "android/package_ctx.go",
        "android/path_properties.go",
        "android/paths.go",
        "android/prebuilt.go",
        "android/prebuilt_etc.go",
        "android/proto.go",
        "android/register.go",
        "android/rule_builder.go",
        "android/sandbox.go",
        "android/sdk.go",
        "android/sh_binary.go",
        "android/singleton.go",
        "android/soong_config_modules.go",
        "android/testing.go",
        "android/util.go",
        "android/variable.go",
        "android/visibility.go",
        "android/vts_config.go",
        "android/writedocs.go",

        // Lock down environment access last
        "android/env.go",
    ],
    testSrcs: [
        "android/android_test.go",
        "android/androidmk_test.go",
        "android/arch_test.go",
        "android/config_test.go",
        "android/csuite_config_test.go",
        "android/expand_test.go",
        "android/module_test.go",
        "android/mutator_test.go",
        "android/namespace_test.go",
        "android/neverallow_test.go",
        "android/onceper_test.go",
        "android/package_test.go",
        "android/path_properties_test.go",
        "android/paths_test.go",
        "android/prebuilt_test.go",
        "android/prebuilt_etc_test.go",
        "android/rule_builder_test.go",
        "android/soong_config_modules_test.go",
        "android/util_test.go",
        "android/variable_test.go",
        "android/visibility_test.go",
        "android/vts_config_test.go",
    ],
}

bootstrap_go_package {
    name: "soong-android-soongconfig",
    pkgPath: "android/soong/android/soongconfig",
    deps: [
        "blueprint",
        "blueprint-parser",
        "blueprint-proptools",
    ],
    srcs: [
        "android/soongconfig/config.go",
        "android/soongconfig/modules.go",
    ],
}

bootstrap_go_package {
    name: "soong-cc-config",
    pkgPath: "android/soong/cc/config",
    deps: [
        "soong-android",
        "soong-remoteexec",
    ],
    srcs: [
        "cc/config/clang.go",
        "cc/config/global.go",
        "cc/config/tidy.go",
        "cc/config/toolchain.go",
        "cc/config/vndk.go",

        "cc/config/arm_device.go",
        "cc/config/arm64_device.go",
        "cc/config/arm64_fuchsia_device.go",
        "cc/config/x86_device.go",
        "cc/config/x86_64_device.go",
        "cc/config/x86_64_fuchsia_device.go",

        "cc/config/x86_darwin_host.go",
        "cc/config/x86_linux_host.go",
        "cc/config/x86_linux_bionic_host.go",
        "cc/config/x86_windows_host.go",
    ],
    testSrcs: [
        "cc/config/tidy_test.go",
    ],
}

bootstrap_go_package {
    name: "soong-cc",
    pkgPath: "android/soong/cc",
    deps: [
        "blueprint",
        "blueprint-pathtools",
        "soong",
        "soong-android",
        "soong-cc-config",
        "soong-genrule",
        "soong-tradefed",
    ],
    srcs: [
        "cc/androidmk.go",
        "cc/builder.go",
        "cc/cc.go",
        "cc/ccdeps.go",
        "cc/check.go",
        "cc/coverage.go",
        "cc/gen.go",
        "cc/linkable.go",
        "cc/lto.go",
        "cc/makevars.go",
        "cc/pgo.go",
        "cc/prebuilt.go",
        "cc/proto.go",
        "cc/rs.go",
        "cc/sanitize.go",
        "cc/sabi.go",
        "cc/sdk.go",
        "cc/snapshot_utils.go",
        "cc/stl.go",
        "cc/strip.go",
        "cc/sysprop.go",
        "cc/tidy.go",
        "cc/util.go",
        "cc/vendor_snapshot.go",
        "cc/vndk.go",
        "cc/vndk_prebuilt.go",

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

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

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

        "cc/llndk_library.go",

        "cc/kernel_headers.go",

        "cc/genrule.go",

        "cc/vendor_public_library.go",

        "cc/testing.go",
    ],
    testSrcs: [
        "cc/cc_test.go",
        "cc/compiler_test.go",
        "cc/gen_test.go",
        "cc/genrule_test.go",
        "cc/library_headers_test.go",
        "cc/library_test.go",
        "cc/object_test.go",
        "cc/prebuilt_test.go",
        "cc/proto_test.go",
        "cc/test_data_test.go",
    ],
    pluginFor: ["soong_build"],
}

bootstrap_go_package {
    name: "soong-genrule",
    pkgPath: "android/soong/genrule",
    deps: [
        "blueprint",
        "blueprint-pathtools",
        "soong",
        "soong-android",
        "soong-shared",
    ],
    srcs: [
        "genrule/genrule.go",
    ],
    testSrcs: [
        "genrule/genrule_test.go",
    ],
    pluginFor: ["soong_build"],
}

bootstrap_go_package {
    name: "soong-phony",
    pkgPath: "android/soong/phony",
    deps: [
        "blueprint",
        "soong-android",
    ],
    srcs: [
        "phony/phony.go",
    ],
    pluginFor: ["soong_build"],
}

bootstrap_go_package {
    name: "soong-java",
    pkgPath: "android/soong/java",
    deps: [
        "blueprint",
        "blueprint-pathtools",
        "soong",
        "soong-android",
        "soong-cc",
        "soong-dexpreopt",
        "soong-genrule",
        "soong-java-config",
        "soong-remoteexec",
        "soong-tradefed",
    ],
    srcs: [
        "java/aapt2.go",
        "java/aar.go",
        "java/android_manifest.go",
        "java/android_resources.go",
        "java/androidmk.go",
        "java/app_builder.go",
        "java/app.go",
        "java/builder.go",
        "java/device_host_converter.go",
        "java/dex.go",
        "java/dexpreopt.go",
        "java/dexpreopt_bootjars.go",
        "java/dexpreopt_config.go",
        "java/droiddoc.go",
        "java/gen.go",
        "java/genrule.go",
        "java/hiddenapi.go",
        "java/hiddenapi_singleton.go",
        "java/jacoco.go",
        "java/java.go",
        "java/jdeps.go",
        "java/java_resources.go",
        "java/kotlin.go",
        "java/platform_compat_config.go",
        "java/plugin.go",
        "java/prebuilt_apis.go",
        "java/proto.go",
        "java/robolectric.go",
        "java/sdk.go",
        "java/sdk_library.go",
        "java/support_libraries.go",
        "java/sysprop.go",
        "java/system_modules.go",
        "java/testing.go",
        "java/tradefed.go",
    ],
    testSrcs: [
        "java/androidmk_test.go",
        "java/app_test.go",
        "java/device_host_converter_test.go",
        "java/dexpreopt_test.go",
        "java/dexpreopt_bootjars_test.go",
        "java/java_test.go",
        "java/jdeps_test.go",
        "java/kotlin_test.go",
        "java/plugin_test.go",
        "java/sdk_test.go",
    ],
    pluginFor: ["soong_build"],
}

bootstrap_go_package {
    name: "soong-java-config",
    pkgPath: "android/soong/java/config",
    deps: [
        "blueprint-proptools",
        "soong-android",
        "soong-remoteexec",
    ],
    srcs: [
        "java/config/config.go",
        "java/config/error_prone.go",
        "java/config/kotlin.go",
        "java/config/makevars.go",
    ],
}

bootstrap_go_package {
    name: "soong-rust-config",
    pkgPath: "android/soong/rust/config",
    deps: [
        "soong-android",
        "soong-cc-config",
    ],
    srcs: [
        "rust/config/arm_device.go",
        "rust/config/arm64_device.go",
        "rust/config/global.go",
        "rust/config/toolchain.go",
        "rust/config/whitelist.go",
        "rust/config/x86_darwin_host.go",
        "rust/config/x86_linux_host.go",
        "rust/config/x86_device.go",
        "rust/config/x86_64_device.go",
    ],
}

bootstrap_go_package {
    name: "soong-rust",
    pkgPath: "android/soong/rust",
    deps: [
        "soong",
        "soong-android",
        "soong-cc",
        "soong-rust-config",
    ],
    srcs: [
        "rust/androidmk.go",
        "rust/compiler.go",
        "rust/coverage.go",
        "rust/binary.go",
        "rust/builder.go",
        "rust/library.go",
        "rust/prebuilt.go",
        "rust/proc_macro.go",
        "rust/rust.go",
        "rust/test.go",
        "rust/testing.go",
    ],
    testSrcs: [
        "rust/binary_test.go",
        "rust/compiler_test.go",
        "rust/coverage_test.go",
        "rust/library_test.go",
        "rust/rust_test.go",
        "rust/test_test.go",
    ],
    pluginFor: ["soong_build"],
}

bootstrap_go_package {
    name: "soong-python",
    pkgPath: "android/soong/python",
    deps: [
        "blueprint",
        "soong-android",
        "soong-tradefed",
    ],
    srcs: [
        "python/androidmk.go",
        "python/binary.go",
        "python/builder.go",
        "python/defaults.go",
        "python/installer.go",
        "python/library.go",
        "python/proto.go",
        "python/python.go",
        "python/test.go",
    ],
    testSrcs: [
        "python/python_test.go",
    ],
    pluginFor: ["soong_build"],
}

bootstrap_go_package {
    name: "soong-shared",
    pkgPath: "android/soong/shared",
    srcs: [
        "shared/paths.go",
    ],
}

bootstrap_go_package {
    name: "soong-tradefed",
    pkgPath: "android/soong/tradefed",
    deps: [
        "blueprint",
        "soong-android",
    ],
    srcs: [
        "tradefed/autogen.go",
        "tradefed/config.go",
        "tradefed/makevars.go",
    ],
    pluginFor: ["soong_build"],
}

bootstrap_go_package {
    name: "soong-xml",
    pkgPath: "android/soong/xml",
    deps: [
        "blueprint",
        "blueprint-pathtools",
        "soong",
        "soong-android",
    ],
    srcs: [
        "xml/xml.go",
    ],
    testSrcs: [
        "xml/xml_test.go",
    ],
    pluginFor: ["soong_build"],
}

bootstrap_go_package {
    name: "soong-apex",
    pkgPath: "android/soong/apex",
    deps: [
        "blueprint",
        "soong",
        "soong-android",
        "soong-cc",
        "soong-java",
        "soong-python",
    ],
    srcs: [
        "apex/androidmk.go",
        "apex/apex.go",
        "apex/apex_singleton.go",
        "apex/builder.go",
        "apex/key.go",
        "apex/prebuilt.go",
        "apex/vndk.go",
    ],
    testSrcs: [
        "apex/apex_test.go",
        "apex/vndk_test.go",
    ],
    pluginFor: ["soong_build"],
}

bootstrap_go_package {
    name: "soong-sysprop",
    pkgPath: "android/soong/sysprop",
    deps: [
        "blueprint",
        "soong",
        "soong-android",
        "soong-cc",
        "soong-java",
    ],
    srcs: [
        "sysprop/sysprop_library.go",
    ],
    testSrcs: [
        "sysprop/sysprop_test.go",
    ],
    pluginFor: ["soong_build"],
}

bootstrap_go_package {
    name: "soong-sdk",
    pkgPath: "android/soong/sdk",
    deps: [
        "blueprint",
        "soong",
        "soong-android",
        "soong-apex",
        "soong-cc",
        "soong-java",
    ],
    srcs: [
        "sdk/bp.go",
        "sdk/exports.go",
        "sdk/sdk.go",
        "sdk/update.go",
    ],
    testSrcs: [
        "sdk/bp_test.go",
        "sdk/cc_sdk_test.go",
        "sdk/exports_test.go",
        "sdk/java_sdk_test.go",
        "sdk/sdk_test.go",
        "sdk/testing.go",
    ],
    pluginFor: ["soong_build"],
}

bootstrap_go_package {
    name: "soong-remoteexec",
    pkgPath: "android/soong/remoteexec",
    deps: [
        "blueprint",
        "soong-android",
    ],
    srcs: [
        "remoteexec/remoteexec.go",
    ],
    testSrcs: [
        "remoteexec/remoteexec_test.go",
    ],
    pluginFor: ["soong_build"],
}

//
// Defaults to enable various configurations of host bionic
//

android/Android.bp

0 → 100644
+80 −0
Original line number Diff line number Diff line
bootstrap_go_package {
    name: "soong-android",
    pkgPath: "android/soong/android",
    deps: [
        "blueprint",
        "blueprint-bootstrap",
        "soong",
        "soong-android-soongconfig",
        "soong-env",
        "soong-shared",
        "soong-ui-metrics_proto",
    ],
    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",
        "metrics.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 −0
Original line number Diff line number Diff line
bootstrap_go_package {
    name: "soong-android-soongconfig",
    pkgPath: "android/soong/android/soongconfig",
    deps: [
        "blueprint",
        "blueprint-parser",
        "blueprint-proptools",
    ],
    srcs: [
        "config.go",
        "modules.go",
    ],
}

apex/Android.bp

0 → 100644
+27 −0
Original line number Diff line number Diff line
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"],
}
+11 −9
Original line number Diff line number Diff line
@@ -22,14 +22,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 (
@@ -1639,7 +1641,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)
@@ -1661,7 +1663,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)
@@ -1965,7 +1967,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))
@@ -2012,7 +2014,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
					ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay 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))
@@ -2109,7 +2111,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() {
Loading