diff options
author | Jiyong Park | 2019-03-29 00:23:10 -0500 |
---|---|---|
committer | Jiyong Park | 2019-03-30 00:11:37 -0500 |
commit | c95714ed0d31dd2d5a086858fbcd5ec74f9dbb68 (patch) | |
tree | 03ba63e552cbe6f17ede1695475842d1ac7941c0 /apex | |
parent | 939ebd5f332b243f2921d26f16922cfa8750d862 (diff) | |
download | platform-build-soong-c95714ed0d31dd2d5a086858fbcd5ec74f9dbb68.tar.gz platform-build-soong-c95714ed0d31dd2d5a086858fbcd5ec74f9dbb68.tar.xz platform-build-soong-c95714ed0d31dd2d5a086858fbcd5ec74f9dbb68.zip |
Arch-specific source for prebuilt_apex
Arch-specific source can be specified for prebuilt_apex as follows.
arch: {
arm64: {
src: "myapex-arm64.apex",
},
},
A note on the implementation. The Src property was not tagged as
`android:"arch_variant"` as usual. Instead, multiple Src properties are
explicitly declared like
struct Arch {
struct Arm {
struct Src *string
}
...
}
Corresponding Src property is manually selected according to the
MultiTargets()[0].
This is because prebuilt_apex is mutated only for android_common, in
order to have the same arch variant with the apex module type.
Therefore, we can't rely on the arch_variant tag.
Bug: 127789981
Test: m (apex_test amended)
Change-Id: I77dbe626171d8975f549bdb4af3c487232cf05f7
Diffstat (limited to 'apex')
-rw-r--r-- | apex/apex.go | 50 | ||||
-rw-r--r-- | apex/apex_test.go | 17 |
2 files changed, 61 insertions, 6 deletions
diff --git a/apex/apex.go b/apex/apex.go index 685a7746..e07fae06 100644 --- a/apex/apex.go +++ b/apex/apex.go | |||
@@ -1300,7 +1300,23 @@ type Prebuilt struct { | |||
1300 | 1300 | ||
1301 | type PrebuiltProperties struct { | 1301 | type PrebuiltProperties struct { |
1302 | // the path to the prebuilt .apex file to import. | 1302 | // the path to the prebuilt .apex file to import. |
1303 | Src string `android:"arch_variant"` | 1303 | Source string `blueprint:"mutated"` |
1304 | |||
1305 | Src *string | ||
1306 | Arch struct { | ||
1307 | Arm struct { | ||
1308 | Src *string | ||
1309 | } | ||
1310 | Arm64 struct { | ||
1311 | Src *string | ||
1312 | } | ||
1313 | X86 struct { | ||
1314 | Src *string | ||
1315 | } | ||
1316 | X86_64 struct { | ||
1317 | Src *string | ||
1318 | } | ||
1319 | } | ||
1304 | 1320 | ||
1305 | // the name of the apex_key module that contains the matching public key to be installed. | 1321 | // the name of the apex_key module that contains the matching public key to be installed. |
1306 | Key *string | 1322 | Key *string |
@@ -1312,11 +1328,37 @@ func (p *Prebuilt) DepsMutator(ctx android.BottomUpMutatorContext) { | |||
1312 | return | 1328 | return |
1313 | } | 1329 | } |
1314 | ctx.AddDependency(ctx.Module(), keyTag, *p.properties.Key) | 1330 | ctx.AddDependency(ctx.Module(), keyTag, *p.properties.Key) |
1331 | |||
1332 | // This is called before prebuilt_select and prebuilt_postdeps mutators | ||
1333 | // The mutators requires that src to be set correctly for each arch so that | ||
1334 | // arch variants are disabled when src is not provided for the arch. | ||
1335 | if len(ctx.MultiTargets()) != 1 { | ||
1336 | ctx.ModuleErrorf("compile_multilib shouldn't be \"both\" for prebuilt_apex") | ||
1337 | return | ||
1338 | } | ||
1339 | var src string | ||
1340 | switch ctx.MultiTargets()[0].Arch.ArchType { | ||
1341 | case android.Arm: | ||
1342 | src = String(p.properties.Arch.Arm.Src) | ||
1343 | case android.Arm64: | ||
1344 | src = String(p.properties.Arch.Arm64.Src) | ||
1345 | case android.X86: | ||
1346 | src = String(p.properties.Arch.X86.Src) | ||
1347 | case android.X86_64: | ||
1348 | src = String(p.properties.Arch.X86_64.Src) | ||
1349 | default: | ||
1350 | ctx.ModuleErrorf("prebuilt_apex does not support %q", ctx.MultiTargets()[0].Arch.String()) | ||
1351 | return | ||
1352 | } | ||
1353 | if src == "" { | ||
1354 | src = String(p.properties.Src) | ||
1355 | } | ||
1356 | p.properties.Source = src | ||
1315 | } | 1357 | } |
1316 | 1358 | ||
1317 | func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { | 1359 | func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
1318 | // TODO(jungjw): Check the key validity. | 1360 | // TODO(jungjw): Check the key validity. |
1319 | p.inputApex = p.prebuilt.SingleSourcePath(ctx) | 1361 | p.inputApex = p.Prebuilt().SingleSourcePath(ctx) |
1320 | p.installDir = android.PathForModuleInstall(ctx, "apex") | 1362 | p.installDir = android.PathForModuleInstall(ctx, "apex") |
1321 | ctx.InstallFile(p.installDir, ctx.ModuleName()+imageApexSuffix, p.inputApex) | 1363 | ctx.InstallFile(p.installDir, ctx.ModuleName()+imageApexSuffix, p.inputApex) |
1322 | } | 1364 | } |
@@ -1348,7 +1390,7 @@ func (p *Prebuilt) AndroidMk() android.AndroidMkData { | |||
1348 | func PrebuiltFactory() android.Module { | 1390 | func PrebuiltFactory() android.Module { |
1349 | module := &Prebuilt{} | 1391 | module := &Prebuilt{} |
1350 | module.AddProperties(&module.properties) | 1392 | module.AddProperties(&module.properties) |
1351 | android.InitSingleSourcePrebuiltModule(module, &module.properties.Src) | 1393 | android.InitSingleSourcePrebuiltModule(module, &module.properties.Source) |
1352 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) | 1394 | android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon) |
1353 | return module | 1395 | return module |
1354 | } | 1396 | } |
diff --git a/apex/apex_test.go b/apex/apex_test.go index 2d9cca6f..1e8d5b44 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go | |||
@@ -171,7 +171,8 @@ func testApex(t *testing.T, bp string) *android.TestContext { | |||
171 | "custom_notice": nil, | 171 | "custom_notice": nil, |
172 | "testkey2.avbpubkey": nil, | 172 | "testkey2.avbpubkey": nil, |
173 | "testkey2.pem": nil, | 173 | "testkey2.pem": nil, |
174 | "myapex.apex": nil, | 174 | "myapex-arm64.apex": nil, |
175 | "myapex-arm.apex": nil, | ||
175 | }) | 176 | }) |
176 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) | 177 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
177 | android.FailIfErrored(t, errs) | 178 | android.FailIfErrored(t, errs) |
@@ -1243,7 +1244,14 @@ func TestPrebuilt(t *testing.T) { | |||
1243 | ctx := testApex(t, ` | 1244 | ctx := testApex(t, ` |
1244 | prebuilt_apex { | 1245 | prebuilt_apex { |
1245 | name: "myapex", | 1246 | name: "myapex", |
1246 | src: "myapex.apex", | 1247 | arch: { |
1248 | arm64: { | ||
1249 | src: "myapex-arm64.apex", | ||
1250 | }, | ||
1251 | arm: { | ||
1252 | src: "myapex-arm.apex", | ||
1253 | }, | ||
1254 | }, | ||
1247 | key: "myapex.key" | 1255 | key: "myapex.key" |
1248 | } | 1256 | } |
1249 | 1257 | ||
@@ -1257,6 +1265,11 @@ func TestPrebuilt(t *testing.T) { | |||
1257 | 1265 | ||
1258 | prebuilt := ctx.ModuleForTests("myapex", "android_common").Module().(*Prebuilt) | 1266 | prebuilt := ctx.ModuleForTests("myapex", "android_common").Module().(*Prebuilt) |
1259 | 1267 | ||
1268 | expectedInput := "myapex-arm64.apex" | ||
1269 | if prebuilt.inputApex.String() != expectedInput { | ||
1270 | t.Errorf("inputApex invalid. expected: %q, actual: %q", expectedInput, prebuilt.inputApex.String()) | ||
1271 | } | ||
1272 | |||
1260 | // Check if the key module is added as a required module. | 1273 | // Check if the key module is added as a required module. |
1261 | buf := &bytes.Buffer{} | 1274 | buf := &bytes.Buffer{} |
1262 | prebuilt.AndroidMk().Extra[0](buf, nil) | 1275 | prebuilt.AndroidMk().Extra[0](buf, nil) |