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
This commit is contained in:
Jaewoong Jung 2020-06-01 10:45:49 -07:00
parent a91b64d3ee
commit 4b79e98a6e
31 changed files with 787 additions and 691 deletions

View file

@ -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
//

80
android/Android.bp Normal file
View file

@ -0,0 +1,80 @@
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",
],
}

View file

@ -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
apex/Android.bp Normal file
View file

@ -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"],
}

View file

@ -22,14 +22,16 @@ import (
"strings"
"sync"
"android/soong/android"
"android/soong/cc"
"android/soong/java"
"android/soong/python"
"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"
"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() {

View file

@ -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
@ -230,9 +232,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)

87
cc/Android.bp Normal file
View file

@ -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"],
}

30
cc/config/Android.bp Normal file
View file

@ -0,0 +1,30 @@
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",
"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",
],
}

View file

@ -25,6 +25,7 @@ import (
"android/soong/android"
"android/soong/cc/config"
"android/soong/etc"
)
const (
@ -416,7 +417,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

7
env/Android.bp vendored Normal file
View file

@ -0,0 +1,7 @@
bootstrap_go_package {
name: "soong-env",
pkgPath: "android/soong/env",
srcs: [
"env.go",
],
}

16
etc/Android.bp Normal file
View file

@ -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"],
}

View file

@ -12,19 +12,29 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package android
package etc
import "strconv"
import (
"strconv"
"github.com/google/blueprint/proptools"
"android/soong/android"
)
var pctx = android.NewPackageContext("android/soong/etc")
// TODO(jungw): Now that it handles more than the ones in etc/, consider renaming this file.
func init() {
RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
pctx.Import("android/soong/android")
android.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
android.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
android.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
android.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
android.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
android.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
}
type prebuiltEtcProperties struct {
@ -55,24 +65,24 @@ type prebuiltEtcProperties struct {
}
type PrebuiltEtcModule interface {
Module
android.Module
SubDir() string
OutputFile() OutputPath
OutputFile() android.OutputPath
}
type PrebuiltEtc struct {
ModuleBase
android.ModuleBase
properties prebuiltEtcProperties
sourceFilePath Path
outputFilePath OutputPath
sourceFilePath android.Path
outputFilePath android.OutputPath
// The base install location, e.g. "etc" for prebuilt_etc, "usr/share" for prebuilt_usr_share.
installDirBase string
// The base install location when soc_specific property is set to true, e.g. "firmware" for prebuilt_firmware.
socInstallDirBase string
installDirPath InstallPath
additionalDependencies *Paths
installDirPath android.InstallPath
additionalDependencies *android.Paths
}
func (p *PrebuiltEtc) inRamdisk() bool {
@ -99,65 +109,65 @@ func (p *PrebuiltEtc) InstallInRecovery() bool {
return p.inRecovery()
}
var _ ImageInterface = (*PrebuiltEtc)(nil)
var _ android.ImageInterface = (*PrebuiltEtc)(nil)
func (p *PrebuiltEtc) ImageMutatorBegin(ctx BaseModuleContext) {}
func (p *PrebuiltEtc) ImageMutatorBegin(ctx android.BaseModuleContext) {}
func (p *PrebuiltEtc) CoreVariantNeeded(ctx BaseModuleContext) bool {
func (p *PrebuiltEtc) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
return !p.ModuleBase.InstallInRecovery() && !p.ModuleBase.InstallInRamdisk()
}
func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx BaseModuleContext) bool {
return Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
func (p *PrebuiltEtc) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(p.properties.Ramdisk_available) || p.ModuleBase.InstallInRamdisk()
}
func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx BaseModuleContext) bool {
return Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
return proptools.Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
}
func (p *PrebuiltEtc) ExtraImageVariations(ctx BaseModuleContext) []string {
func (p *PrebuiltEtc) ExtraImageVariations(ctx android.BaseModuleContext) []string {
return nil
}
func (p *PrebuiltEtc) SetImageVariation(ctx BaseModuleContext, variation string, module Module) {
func (p *PrebuiltEtc) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
}
func (p *PrebuiltEtc) DepsMutator(ctx BottomUpMutatorContext) {
func (p *PrebuiltEtc) DepsMutator(ctx android.BottomUpMutatorContext) {
if p.properties.Src == nil {
ctx.PropertyErrorf("src", "missing prebuilt source file")
}
}
func (p *PrebuiltEtc) SourceFilePath(ctx ModuleContext) Path {
return PathForModuleSrc(ctx, String(p.properties.Src))
func (p *PrebuiltEtc) SourceFilePath(ctx android.ModuleContext) android.Path {
return android.PathForModuleSrc(ctx, android.String(p.properties.Src))
}
func (p *PrebuiltEtc) InstallDirPath() InstallPath {
func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
return p.installDirPath
}
// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
// additional steps (like validating the src) before the file is installed.
func (p *PrebuiltEtc) SetAdditionalDependencies(paths Paths) {
func (p *PrebuiltEtc) SetAdditionalDependencies(paths android.Paths) {
p.additionalDependencies = &paths
}
func (p *PrebuiltEtc) OutputFile() OutputPath {
func (p *PrebuiltEtc) OutputFile() android.OutputPath {
return p.outputFilePath
}
func (p *PrebuiltEtc) SubDir() string {
return String(p.properties.Sub_dir)
return android.String(p.properties.Sub_dir)
}
func (p *PrebuiltEtc) Installable() bool {
return p.properties.Installable == nil || Bool(p.properties.Installable)
return p.properties.Installable == nil || android.Bool(p.properties.Installable)
}
func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) {
p.sourceFilePath = PathForModuleSrc(ctx, String(p.properties.Src))
filename := String(p.properties.Filename)
filename_from_src := Bool(p.properties.Filename_from_src)
func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
p.sourceFilePath = android.PathForModuleSrc(ctx, android.String(p.properties.Src))
filename := android.String(p.properties.Filename)
filename_from_src := android.Bool(p.properties.Filename_from_src)
if filename == "" {
if filename_from_src {
filename = p.sourceFilePath.Base()
@ -168,7 +178,7 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) {
ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
return
}
p.outputFilePath = PathForModuleOut(ctx, filename).OutputPath
p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
// If soc install dir was specified and SOC specific is set, set the installDirPath to the specified
// socInstallDirBase.
@ -176,18 +186,18 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) {
if ctx.SocSpecific() && p.socInstallDirBase != "" {
installBaseDir = p.socInstallDirBase
}
p.installDirPath = PathForModuleInstall(ctx, installBaseDir, String(p.properties.Sub_dir))
p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, proptools.String(p.properties.Sub_dir))
// This ensures that outputFilePath has the correct name for others to
// use, as the source file may have a different name.
ctx.Build(pctx, BuildParams{
Rule: Cp,
ctx.Build(pctx, android.BuildParams{
Rule: android.Cp,
Output: p.outputFilePath,
Input: p.sourceFilePath,
})
}
func (p *PrebuiltEtc) AndroidMkEntries() []AndroidMkEntries {
func (p *PrebuiltEtc) AndroidMkEntries() []android.AndroidMkEntries {
nameSuffix := ""
if p.inRamdisk() && !p.onlyInRamdisk() {
nameSuffix = ".ramdisk"
@ -195,12 +205,12 @@ func (p *PrebuiltEtc) AndroidMkEntries() []AndroidMkEntries {
if p.inRecovery() && !p.onlyInRecovery() {
nameSuffix = ".recovery"
}
return []AndroidMkEntries{AndroidMkEntries{
return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "ETC",
SubName: nameSuffix,
OutputFile: OptionalPathForPath(p.outputFilePath),
ExtraEntries: []AndroidMkExtraEntriesFunc{
func(entries *AndroidMkEntries) {
OutputFile: android.OptionalPathForPath(p.outputFilePath),
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(entries *android.AndroidMkEntries) {
entries.SetString("LOCAL_MODULE_TAGS", "optional")
entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.ToMakePath().String())
entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base())
@ -225,61 +235,61 @@ func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {
// prebuilt_etc is for a prebuilt artifact that is installed in
// <partition>/etc/<sub_dir> directory.
func PrebuiltEtcFactory() Module {
func PrebuiltEtcFactory() android.Module {
module := &PrebuiltEtc{}
InitPrebuiltEtcModule(module, "etc")
// This module is device-only
InitAndroidArchModule(module, DeviceSupported, MultilibFirst)
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
return module
}
// prebuilt_etc_host is for a host prebuilt artifact that is installed in
// $(HOST_OUT)/etc/<sub_dir> directory.
func PrebuiltEtcHostFactory() Module {
func PrebuiltEtcHostFactory() android.Module {
module := &PrebuiltEtc{}
InitPrebuiltEtcModule(module, "etc")
// This module is host-only
InitAndroidArchModule(module, HostSupported, MultilibCommon)
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
return module
}
// prebuilt_usr_share is for a prebuilt artifact that is installed in
// <partition>/usr/share/<sub_dir> directory.
func PrebuiltUserShareFactory() Module {
func PrebuiltUserShareFactory() android.Module {
module := &PrebuiltEtc{}
InitPrebuiltEtcModule(module, "usr/share")
// This module is device-only
InitAndroidArchModule(module, DeviceSupported, MultilibFirst)
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
return module
}
// prebuild_usr_share_host is for a host prebuilt artifact that is installed in
// $(HOST_OUT)/usr/share/<sub_dir> directory.
func PrebuiltUserShareHostFactory() Module {
func PrebuiltUserShareHostFactory() android.Module {
module := &PrebuiltEtc{}
InitPrebuiltEtcModule(module, "usr/share")
// This module is host-only
InitAndroidArchModule(module, HostSupported, MultilibCommon)
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
return module
}
// prebuilt_font installs a font in <partition>/fonts directory.
func PrebuiltFontFactory() Module {
func PrebuiltFontFactory() android.Module {
module := &PrebuiltEtc{}
InitPrebuiltEtcModule(module, "fonts")
// This module is device-only
InitAndroidArchModule(module, DeviceSupported, MultilibFirst)
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
return module
}
// prebuilt_firmware installs a firmware file to <partition>/etc/firmware directory for system image.
// If soc_specific property is set to true, the firmware file is installed to the vendor <partition>/firmware
// directory for vendor image.
func PrebuiltFirmwareFactory() Module {
func PrebuiltFirmwareFactory() android.Module {
module := &PrebuiltEtc{}
module.socInstallDirBase = "firmware"
InitPrebuiltEtcModule(module, "etc/firmware")
// This module is device-only
InitAndroidArchModule(module, DeviceSupported, MultilibFirst)
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
return module
}

View file

@ -12,24 +12,53 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package android
package etc
import (
"io/ioutil"
"os"
"path/filepath"
"reflect"
"testing"
"android/soong/android"
)
func testPrebuiltEtc(t *testing.T, bp string) (*TestContext, Config) {
var buildDir string
func setUp() {
var err error
buildDir, err = ioutil.TempDir("", "soong_etc_test")
if err != nil {
panic(err)
}
}
func tearDown() {
os.RemoveAll(buildDir)
}
func TestMain(m *testing.M) {
run := func() int {
setUp()
defer tearDown()
return m.Run()
}
os.Exit(run())
}
func testPrebuiltEtc(t *testing.T, bp string) (*android.TestContext, android.Config) {
fs := map[string][]byte{
"foo.conf": nil,
"bar.conf": nil,
"baz.conf": nil,
}
config := TestArchConfig(buildDir, nil, bp, fs)
config := android.TestArchConfig(buildDir, nil, bp, fs)
ctx := NewTestArchContext()
ctx := android.NewTestArchContext()
ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory)
ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory)
ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory)
@ -38,9 +67,9 @@ func testPrebuiltEtc(t *testing.T, bp string) (*TestContext, Config) {
ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
ctx.Register(config)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
FailIfErrored(t, errs)
android.FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
FailIfErrored(t, errs)
android.FailIfErrored(t, errs)
return ctx, config
}
@ -142,7 +171,7 @@ func TestPrebuiltEtcAndroidMk(t *testing.T) {
}
mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*PrebuiltEtc)
entries := AndroidMkEntriesForTest(t, config, "", mod)[0]
entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
for k, expectedValue := range expected {
if value, ok := entries.EntryMap[k]; ok {
if !reflect.DeepEqual(value, expectedValue) {
@ -162,7 +191,7 @@ func TestPrebuiltEtcHost(t *testing.T) {
}
`)
buildOS := BuildOs.String()
buildOS := android.BuildOs.String()
p := ctx.ModuleForTests("foo.conf", buildOS+"_common").Module().(*PrebuiltEtc)
if !p.Host() {
t.Errorf("host bit is not set for a prebuilt_etc_host module.")
@ -194,7 +223,7 @@ func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) {
}
`)
buildOS := BuildOs.String()
buildOS := android.BuildOs.String()
p := ctx.ModuleForTests("foo.conf", buildOS+"_common").Module().(*PrebuiltEtc)
expected := filepath.Join(buildDir, "host", config.PrebuiltOS(), "usr", "share", "bar")
if p.installDirPath.String() != expected {

18
genrule/Android.bp Normal file
View file

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

66
java/Android.bp Normal file
View file

@ -0,0 +1,66 @@
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: [
"aapt2.go",
"aar.go",
"android_manifest.go",
"android_resources.go",
"androidmk.go",
"app_builder.go",
"app.go",
"builder.go",
"device_host_converter.go",
"dex.go",
"dexpreopt.go",
"dexpreopt_bootjars.go",
"dexpreopt_config.go",
"droiddoc.go",
"gen.go",
"genrule.go",
"hiddenapi.go",
"hiddenapi_singleton.go",
"jacoco.go",
"java.go",
"jdeps.go",
"java_resources.go",
"kotlin.go",
"platform_compat_config.go",
"plugin.go",
"prebuilt_apis.go",
"proto.go",
"robolectric.go",
"sdk.go",
"sdk_library.go",
"support_libraries.go",
"sysprop.go",
"system_modules.go",
"testing.go",
"tradefed.go",
],
testSrcs: [
"androidmk_test.go",
"app_test.go",
"device_host_converter_test.go",
"dexpreopt_test.go",
"dexpreopt_bootjars_test.go",
"java_test.go",
"jdeps_test.go",
"kotlin_test.go",
"plugin_test.go",
"sdk_test.go",
],
pluginFor: ["soong_build"],
}

15
java/config/Android.bp Normal file
View file

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

12
phony/Android.bp Normal file
View file

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

24
python/Android.bp Normal file
View file

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

15
remoteexec/Android.bp Normal file
View file

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

32
rust/Android.bp Normal file
View file

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

19
rust/config/Android.bp Normal file
View file

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

27
sdk/Android.bp Normal file
View file

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

16
sh/Android.bp Normal file
View file

@ -0,0 +1,16 @@
bootstrap_go_package {
name: "soong-sh",
pkgPath: "android/soong/sh",
deps: [
"blueprint",
"soong",
"soong-android",
],
srcs: [
"sh_binary.go",
],
testSrcs: [
"sh_binary_test.go",
],
pluginFor: ["soong_build"],
}

View file

@ -12,12 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package android
package sh
import (
"fmt"
"path/filepath"
"strings"
"github.com/google/blueprint/proptools"
"android/soong/android"
)
// sh_binary is for shell scripts (and batch files) that are installed as
@ -26,11 +30,15 @@ import (
// Do not use them for prebuilt C/C++/etc files. Use cc_prebuilt_binary
// instead.
var pctx = android.NewPackageContext("android/soong/sh")
func init() {
RegisterModuleType("sh_binary", ShBinaryFactory)
RegisterModuleType("sh_binary_host", ShBinaryHostFactory)
RegisterModuleType("sh_test", ShTestFactory)
RegisterModuleType("sh_test_host", ShTestHostFactory)
pctx.Import("android/soong/android")
android.RegisterModuleType("sh_binary", ShBinaryFactory)
android.RegisterModuleType("sh_binary_host", ShBinaryHostFactory)
android.RegisterModuleType("sh_test", ShTestFactory)
android.RegisterModuleType("sh_test_host", ShTestHostFactory)
}
type shBinaryProperties struct {
@ -69,55 +77,55 @@ type TestProperties struct {
}
type ShBinary struct {
ModuleBase
android.ModuleBase
properties shBinaryProperties
sourceFilePath Path
outputFilePath OutputPath
installedFile InstallPath
sourceFilePath android.Path
outputFilePath android.OutputPath
installedFile android.InstallPath
}
var _ HostToolProvider = (*ShBinary)(nil)
var _ android.HostToolProvider = (*ShBinary)(nil)
type ShTest struct {
ShBinary
testProperties TestProperties
data Paths
data android.Paths
}
func (s *ShBinary) HostToolPath() OptionalPath {
return OptionalPathForPath(s.installedFile)
func (s *ShBinary) HostToolPath() android.OptionalPath {
return android.OptionalPathForPath(s.installedFile)
}
func (s *ShBinary) DepsMutator(ctx BottomUpMutatorContext) {
func (s *ShBinary) DepsMutator(ctx android.BottomUpMutatorContext) {
if s.properties.Src == nil {
ctx.PropertyErrorf("src", "missing prebuilt source file")
}
}
func (s *ShBinary) OutputFile() OutputPath {
func (s *ShBinary) OutputFile() android.OutputPath {
return s.outputFilePath
}
func (s *ShBinary) SubDir() string {
return String(s.properties.Sub_dir)
return proptools.String(s.properties.Sub_dir)
}
func (s *ShBinary) Installable() bool {
return s.properties.Installable == nil || Bool(s.properties.Installable)
return s.properties.Installable == nil || proptools.Bool(s.properties.Installable)
}
func (s *ShBinary) Symlinks() []string {
return s.properties.Symlinks
}
func (s *ShBinary) generateAndroidBuildActions(ctx ModuleContext) {
s.sourceFilePath = PathForModuleSrc(ctx, String(s.properties.Src))
filename := String(s.properties.Filename)
filename_from_src := Bool(s.properties.Filename_from_src)
func (s *ShBinary) generateAndroidBuildActions(ctx android.ModuleContext) {
s.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(s.properties.Src))
filename := proptools.String(s.properties.Filename)
filename_from_src := proptools.Bool(s.properties.Filename_from_src)
if filename == "" {
if filename_from_src {
filename = s.sourceFilePath.Base()
@ -128,38 +136,38 @@ func (s *ShBinary) generateAndroidBuildActions(ctx ModuleContext) {
ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
return
}
s.outputFilePath = PathForModuleOut(ctx, filename).OutputPath
s.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
// This ensures that outputFilePath has the correct name for others to
// use, as the source file may have a different name.
ctx.Build(pctx, BuildParams{
Rule: CpExecutable,
ctx.Build(pctx, android.BuildParams{
Rule: android.CpExecutable,
Output: s.outputFilePath,
Input: s.sourceFilePath,
})
}
func (s *ShBinary) GenerateAndroidBuildActions(ctx ModuleContext) {
func (s *ShBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
s.generateAndroidBuildActions(ctx)
installDir := PathForModuleInstall(ctx, "bin", String(s.properties.Sub_dir))
installDir := android.PathForModuleInstall(ctx, "bin", proptools.String(s.properties.Sub_dir))
s.installedFile = ctx.InstallExecutable(installDir, s.outputFilePath.Base(), s.outputFilePath)
}
func (s *ShBinary) AndroidMkEntries() []AndroidMkEntries {
return []AndroidMkEntries{AndroidMkEntries{
func (s *ShBinary) AndroidMkEntries() []android.AndroidMkEntries {
return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "EXECUTABLES",
OutputFile: OptionalPathForPath(s.outputFilePath),
OutputFile: android.OptionalPathForPath(s.outputFilePath),
Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
ExtraEntries: []AndroidMkExtraEntriesFunc{
func(entries *AndroidMkEntries) {
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(entries *android.AndroidMkEntries) {
s.customAndroidMkEntries(entries)
},
},
}}
}
func (s *ShBinary) customAndroidMkEntries(entries *AndroidMkEntries) {
entries.SetString("LOCAL_MODULE_RELATIVE_PATH", String(s.properties.Sub_dir))
func (s *ShBinary) customAndroidMkEntries(entries *android.AndroidMkEntries) {
entries.SetString("LOCAL_MODULE_RELATIVE_PATH", proptools.String(s.properties.Sub_dir))
entries.SetString("LOCAL_MODULE_SUFFIX", "")
entries.SetString("LOCAL_MODULE_STEM", s.outputFilePath.Rel())
if len(s.properties.Symlinks) > 0 {
@ -167,38 +175,38 @@ func (s *ShBinary) customAndroidMkEntries(entries *AndroidMkEntries) {
}
}
func (s *ShTest) GenerateAndroidBuildActions(ctx ModuleContext) {
func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
s.ShBinary.generateAndroidBuildActions(ctx)
testDir := "nativetest"
if ctx.Target().Arch.ArchType.Multilib == "lib64" {
testDir = "nativetest64"
}
if ctx.Target().NativeBridge == NativeBridgeEnabled {
if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
testDir = filepath.Join(testDir, ctx.Target().NativeBridgeRelativePath)
} else if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
testDir = filepath.Join(testDir, ctx.Arch().ArchType.String())
}
installDir := PathForModuleInstall(ctx, testDir, String(s.properties.Sub_dir))
installDir := android.PathForModuleInstall(ctx, testDir, proptools.String(s.properties.Sub_dir))
s.installedFile = ctx.InstallExecutable(installDir, s.outputFilePath.Base(), s.outputFilePath)
s.data = PathsForModuleSrc(ctx, s.testProperties.Data)
s.data = android.PathsForModuleSrc(ctx, s.testProperties.Data)
}
func (s *ShTest) InstallInData() bool {
return true
}
func (s *ShTest) AndroidMkEntries() []AndroidMkEntries {
return []AndroidMkEntries{AndroidMkEntries{
func (s *ShTest) AndroidMkEntries() []android.AndroidMkEntries {
return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "NATIVE_TESTS",
OutputFile: OptionalPathForPath(s.outputFilePath),
OutputFile: android.OptionalPathForPath(s.outputFilePath),
Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
ExtraEntries: []AndroidMkExtraEntriesFunc{
func(entries *AndroidMkEntries) {
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(entries *android.AndroidMkEntries) {
s.customAndroidMkEntries(entries)
entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", s.testProperties.Test_suites...)
entries.SetString("LOCAL_TEST_CONFIG", String(s.testProperties.Test_config))
entries.SetString("LOCAL_TEST_CONFIG", proptools.String(s.testProperties.Test_config))
for _, d := range s.data {
rel := d.Rel()
path := d.String()
@ -219,41 +227,41 @@ func InitShBinaryModule(s *ShBinary) {
// sh_binary is for a shell script or batch file to be installed as an
// executable binary to <partition>/bin.
func ShBinaryFactory() Module {
func ShBinaryFactory() android.Module {
module := &ShBinary{}
module.Prefer32(func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool {
return class == Device && ctx.Config().DevicePrefer32BitExecutables()
module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
return class == android.Device && ctx.Config().DevicePrefer32BitExecutables()
})
InitShBinaryModule(module)
InitAndroidArchModule(module, HostAndDeviceSupported, MultilibFirst)
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibFirst)
return module
}
// sh_binary_host is for a shell script to be installed as an executable binary
// to $(HOST_OUT)/bin.
func ShBinaryHostFactory() Module {
func ShBinaryHostFactory() android.Module {
module := &ShBinary{}
InitShBinaryModule(module)
InitAndroidArchModule(module, HostSupported, MultilibFirst)
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibFirst)
return module
}
// sh_test defines a shell script based test module.
func ShTestFactory() Module {
func ShTestFactory() android.Module {
module := &ShTest{}
InitShBinaryModule(&module.ShBinary)
module.AddProperties(&module.testProperties)
InitAndroidArchModule(module, HostAndDeviceSupported, MultilibFirst)
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibFirst)
return module
}
// sh_test_host defines a shell script based test module that runs on a host.
func ShTestHostFactory() Module {
func ShTestHostFactory() android.Module {
module := &ShTest{}
InitShBinaryModule(&module.ShBinary)
module.AddProperties(&module.testProperties)
InitAndroidArchModule(module, HostSupported, MultilibFirst)
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibFirst)
return module
}

View file

@ -1,27 +1,56 @@
package android
package sh
import (
"io/ioutil"
"os"
"reflect"
"testing"
"android/soong/android"
)
func testShBinary(t *testing.T, bp string) (*TestContext, Config) {
var buildDir string
func setUp() {
var err error
buildDir, err = ioutil.TempDir("", "soong_sh_test")
if err != nil {
panic(err)
}
}
func tearDown() {
os.RemoveAll(buildDir)
}
func TestMain(m *testing.M) {
run := func() int {
setUp()
defer tearDown()
return m.Run()
}
os.Exit(run())
}
func testShBinary(t *testing.T, bp string) (*android.TestContext, android.Config) {
fs := map[string][]byte{
"test.sh": nil,
"testdata/data1": nil,
"testdata/sub/data2": nil,
}
config := TestArchConfig(buildDir, nil, bp, fs)
config := android.TestArchConfig(buildDir, nil, bp, fs)
ctx := NewTestArchContext()
ctx := android.NewTestArchContext()
ctx.RegisterModuleType("sh_test", ShTestFactory)
ctx.RegisterModuleType("sh_test_host", ShTestHostFactory)
ctx.Register(config)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
FailIfErrored(t, errs)
android.FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
FailIfErrored(t, errs)
android.FailIfErrored(t, errs)
return ctx, config
}
@ -41,7 +70,7 @@ func TestShTestTestData(t *testing.T) {
mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*ShTest)
entries := AndroidMkEntriesForTest(t, config, "", mod)[0]
entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
expected := []string{":testdata/data1", ":testdata/sub/data2"}
actual := entries.EntryMap["LOCAL_TEST_DATA"]
if !reflect.DeepEqual(expected, actual) {
@ -62,7 +91,7 @@ func TestShTestHost(t *testing.T) {
}
`)
buildOS := BuildOs.String()
buildOS := android.BuildOs.String()
mod := ctx.ModuleForTests("foo", buildOS+"_x86_64").Module().(*ShTest)
if !mod.Host() {
t.Errorf("host bit is not set for a sh_test_host module.")

7
shared/Android.bp Normal file
View file

@ -0,0 +1,7 @@
bootstrap_go_package {
name: "soong-shared",
pkgPath: "android/soong/shared",
srcs: [
"paths.go",
],
}

18
sysprop/Android.bp Normal file
View file

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

14
tradefed/Android.bp Normal file
View file

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

18
xml/Android.bp Normal file
View file

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

View file

@ -16,6 +16,7 @@ package xml
import (
"android/soong/android"
"android/soong/etc"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@ -62,7 +63,7 @@ type prebuiltEtcXmlProperties struct {
}
type prebuiltEtcXml struct {
android.PrebuiltEtc
etc.PrebuiltEtc
properties prebuiltEtcXmlProperties
}
@ -121,7 +122,7 @@ func (p *prebuiltEtcXml) GenerateAndroidBuildActions(ctx android.ModuleContext)
func PrebuiltEtcXmlFactory() android.Module {
module := &prebuiltEtcXml{}
module.AddProperties(&module.properties)
android.InitPrebuiltEtcModule(&module.PrebuiltEtc, "etc")
etc.InitPrebuiltEtcModule(&module.PrebuiltEtc, "etc")
// This module is device-only
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
return module

View file

@ -20,6 +20,7 @@ import (
"testing"
"android/soong/android"
"android/soong/etc"
)
var buildDir string
@ -57,7 +58,7 @@ func testXml(t *testing.T, bp string) *android.TestContext {
}
config := android.TestArchConfig(buildDir, nil, bp, fs)
ctx := android.NewTestArchContext()
ctx.RegisterModuleType("prebuilt_etc", android.PrebuiltEtcFactory)
ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory)
ctx.RegisterModuleType("prebuilt_etc_xml", PrebuiltEtcXmlFactory)
ctx.Register(config)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})