Loading Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -508,11 +508,13 @@ bootstrap_go_package { ], srcs: [ "sdk/bp.go", "sdk/exports.go", "sdk/sdk.go", "sdk/update.go", ], testSrcs: [ "sdk/cc_sdk_test.go", "sdk/exports_test.go", "sdk/java_sdk_test.go", "sdk/sdk_test.go", "sdk/testing.go", Loading sdk/exports.go 0 → 100644 +39 −0 Original line number Diff line number Diff line // Copyright (C) 2019 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package sdk import "android/soong/android" func init() { android.RegisterModuleType("module_exports", ModuleExportsFactory) android.RegisterModuleType("module_exports_snapshot", ModuleExportsSnapshotsFactory) } // module_exports defines the exports of a mainline module. The exports are Soong modules // which are required by Soong modules that are not part of the mainline module. func ModuleExportsFactory() android.Module { s := newSdkModule() s.properties.Module_exports = true return s } // module_exports_snapshot is a versioned snapshot of prebuilt versions of all the exports // of a mainline module. func ModuleExportsSnapshotsFactory() android.Module { s := newSdkModule() s.properties.Snapshot = true s.properties.Module_exports = true return s } sdk/exports_test.go 0 → 100644 +66 −0 Original line number Diff line number Diff line // Copyright 2019 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package sdk import ( "testing" ) // Ensure that module_exports generates a module_exports_snapshot module. func TestModuleExportsSnapshot(t *testing.T) { packageBp := ` module_exports { name: "myexports", java_libs: [ "myjavalib", ], } java_library { name: "myjavalib", srcs: ["Test.java"], system_modules: "none", sdk_version: "none", } ` result := testSdkWithFs(t, ``, map[string][]byte{ "package/Test.java": nil, "package/Android.bp": []byte(packageBp), }) result.CheckSnapshot("myexports", "android_common", "package", checkAndroidBpContents(` // This is auto-generated. DO NOT EDIT. java_import { name: "myexports_myjavalib@current", sdk_member_name: "myjavalib", jars: ["java/myjavalib.jar"], } java_import { name: "myjavalib", prefer: false, jars: ["java/myjavalib.jar"], } module_exports_snapshot { name: "myexports@current", java_libs: ["myexports_myjavalib@current"], } `)) } sdk/sdk.go +11 −8 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ func init() { pctx.Import("android/soong/android") pctx.Import("android/soong/java/config") android.RegisterModuleType("sdk", ModuleFactory) android.RegisterModuleType("sdk", SdkModuleFactory) android.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory) android.PreDepsMutators(RegisterPreDepsMutators) android.PostDepsMutators(RegisterPostDepsMutators) Loading @@ -60,6 +60,9 @@ type sdk struct { type sdkProperties struct { Snapshot bool `blueprint:"mutated"` // True if this is a module_exports (or module_exports_snapshot) module type. Module_exports bool `blueprint:"mutated"` } type sdkMemberDependencyTag struct { Loading Loading @@ -182,18 +185,18 @@ func createDynamicSdkMemberTypes(sdkMemberTypes []android.SdkMemberType) *dynami // sdk defines an SDK which is a logical group of modules (e.g. native libs, headers, java libs, etc.) // which Mainline modules like APEX can choose to build with. func ModuleFactory() android.Module { s := &sdk{} func SdkModuleFactory() android.Module { return newSdkModule() } func newSdkModule() *sdk { s := &sdk{} // Get the dynamic sdk member type data for the currently registered sdk member types. s.dynamicSdkMemberTypes = getDynamicSdkMemberTypes(android.SdkMemberTypes) // Create an instance of the dynamically created struct that contains all the // properties for the member type specific list properties. s.dynamicMemberTypeListProperties = s.dynamicSdkMemberTypes.createMemberListProperties() s.AddProperties(&s.properties, s.dynamicMemberTypeListProperties) android.InitAndroidMultiTargetsArchModule(s, android.HostAndDeviceSupported, android.MultilibCommon) android.InitDefaultableModule(s) android.AddLoadHook(s, func(ctx android.LoadHookContext) { Loading @@ -208,8 +211,8 @@ func ModuleFactory() android.Module { // sdk_snapshot is a versioned snapshot of an SDK. This is an auto-generated module. func SnapshotModuleFactory() android.Module { s := ModuleFactory() s.(*sdk).properties.Snapshot = true s := newSdkModule() s.properties.Snapshot = true return s } Loading sdk/testing.go +3 −1 Original line number Diff line number Diff line Loading @@ -84,8 +84,10 @@ func testSdkContext(bp string, fs map[string][]byte) (*android.TestContext, andr ctx.PostDepsMutators(apex.RegisterPostDepsMutators) // from this package ctx.RegisterModuleType("sdk", ModuleFactory) ctx.RegisterModuleType("sdk", SdkModuleFactory) ctx.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory) ctx.RegisterModuleType("module_exports", ModuleExportsFactory) ctx.RegisterModuleType("module_exports_snapshot", ModuleExportsSnapshotsFactory) ctx.PreDepsMutators(RegisterPreDepsMutators) ctx.PostDepsMutators(RegisterPostDepsMutators) Loading Loading
Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -508,11 +508,13 @@ bootstrap_go_package { ], srcs: [ "sdk/bp.go", "sdk/exports.go", "sdk/sdk.go", "sdk/update.go", ], testSrcs: [ "sdk/cc_sdk_test.go", "sdk/exports_test.go", "sdk/java_sdk_test.go", "sdk/sdk_test.go", "sdk/testing.go", Loading
sdk/exports.go 0 → 100644 +39 −0 Original line number Diff line number Diff line // Copyright (C) 2019 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package sdk import "android/soong/android" func init() { android.RegisterModuleType("module_exports", ModuleExportsFactory) android.RegisterModuleType("module_exports_snapshot", ModuleExportsSnapshotsFactory) } // module_exports defines the exports of a mainline module. The exports are Soong modules // which are required by Soong modules that are not part of the mainline module. func ModuleExportsFactory() android.Module { s := newSdkModule() s.properties.Module_exports = true return s } // module_exports_snapshot is a versioned snapshot of prebuilt versions of all the exports // of a mainline module. func ModuleExportsSnapshotsFactory() android.Module { s := newSdkModule() s.properties.Snapshot = true s.properties.Module_exports = true return s }
sdk/exports_test.go 0 → 100644 +66 −0 Original line number Diff line number Diff line // Copyright 2019 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package sdk import ( "testing" ) // Ensure that module_exports generates a module_exports_snapshot module. func TestModuleExportsSnapshot(t *testing.T) { packageBp := ` module_exports { name: "myexports", java_libs: [ "myjavalib", ], } java_library { name: "myjavalib", srcs: ["Test.java"], system_modules: "none", sdk_version: "none", } ` result := testSdkWithFs(t, ``, map[string][]byte{ "package/Test.java": nil, "package/Android.bp": []byte(packageBp), }) result.CheckSnapshot("myexports", "android_common", "package", checkAndroidBpContents(` // This is auto-generated. DO NOT EDIT. java_import { name: "myexports_myjavalib@current", sdk_member_name: "myjavalib", jars: ["java/myjavalib.jar"], } java_import { name: "myjavalib", prefer: false, jars: ["java/myjavalib.jar"], } module_exports_snapshot { name: "myexports@current", java_libs: ["myexports_myjavalib@current"], } `)) }
sdk/sdk.go +11 −8 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ func init() { pctx.Import("android/soong/android") pctx.Import("android/soong/java/config") android.RegisterModuleType("sdk", ModuleFactory) android.RegisterModuleType("sdk", SdkModuleFactory) android.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory) android.PreDepsMutators(RegisterPreDepsMutators) android.PostDepsMutators(RegisterPostDepsMutators) Loading @@ -60,6 +60,9 @@ type sdk struct { type sdkProperties struct { Snapshot bool `blueprint:"mutated"` // True if this is a module_exports (or module_exports_snapshot) module type. Module_exports bool `blueprint:"mutated"` } type sdkMemberDependencyTag struct { Loading Loading @@ -182,18 +185,18 @@ func createDynamicSdkMemberTypes(sdkMemberTypes []android.SdkMemberType) *dynami // sdk defines an SDK which is a logical group of modules (e.g. native libs, headers, java libs, etc.) // which Mainline modules like APEX can choose to build with. func ModuleFactory() android.Module { s := &sdk{} func SdkModuleFactory() android.Module { return newSdkModule() } func newSdkModule() *sdk { s := &sdk{} // Get the dynamic sdk member type data for the currently registered sdk member types. s.dynamicSdkMemberTypes = getDynamicSdkMemberTypes(android.SdkMemberTypes) // Create an instance of the dynamically created struct that contains all the // properties for the member type specific list properties. s.dynamicMemberTypeListProperties = s.dynamicSdkMemberTypes.createMemberListProperties() s.AddProperties(&s.properties, s.dynamicMemberTypeListProperties) android.InitAndroidMultiTargetsArchModule(s, android.HostAndDeviceSupported, android.MultilibCommon) android.InitDefaultableModule(s) android.AddLoadHook(s, func(ctx android.LoadHookContext) { Loading @@ -208,8 +211,8 @@ func ModuleFactory() android.Module { // sdk_snapshot is a versioned snapshot of an SDK. This is an auto-generated module. func SnapshotModuleFactory() android.Module { s := ModuleFactory() s.(*sdk).properties.Snapshot = true s := newSdkModule() s.properties.Snapshot = true return s } Loading
sdk/testing.go +3 −1 Original line number Diff line number Diff line Loading @@ -84,8 +84,10 @@ func testSdkContext(bp string, fs map[string][]byte) (*android.TestContext, andr ctx.PostDepsMutators(apex.RegisterPostDepsMutators) // from this package ctx.RegisterModuleType("sdk", ModuleFactory) ctx.RegisterModuleType("sdk", SdkModuleFactory) ctx.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory) ctx.RegisterModuleType("module_exports", ModuleExportsFactory) ctx.RegisterModuleType("module_exports_snapshot", ModuleExportsSnapshotsFactory) ctx.PreDepsMutators(RegisterPreDepsMutators) ctx.PostDepsMutators(RegisterPostDepsMutators) Loading