Move filesystem into Config
The filesystem object was available through ModuleContext.Fs(), but
gives too much access to the filesystem without enforicing correct
dependencies. In order to support sandboxing the soong_build
process move the filesystem into the Config. The next change will
make it private.
Bug: 146437378
Test: all Soong tests
Change-Id: I5d3ae9108f120fd335b21efd612aefa078378813
diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go
index 81fb278..600f078 100644
--- a/android/prebuilt_test.go
+++ b/android/prebuilt_test.go
@@ -125,29 +125,30 @@
}
func TestPrebuilts(t *testing.T) {
- config := TestConfig(buildDir, nil)
+ fs := map[string][]byte{
+ "prebuilt_file": nil,
+ "source_file": nil,
+ }
for _, test := range prebuiltsTests {
t.Run(test.name, func(t *testing.T) {
+ bp := `
+ source {
+ name: "foo",
+ deps: [":bar"],
+ }
+ ` + test.modules
+ config := TestConfig(buildDir, nil, bp, fs)
+
ctx := NewTestContext()
ctx.PreArchMutators(RegisterPrebuiltsPreArchMutators)
ctx.PostDepsMutators(RegisterPrebuiltsPostDepsMutators)
ctx.RegisterModuleType("filegroup", FileGroupFactory)
ctx.RegisterModuleType("prebuilt", newPrebuiltModule)
ctx.RegisterModuleType("source", newSourceModule)
- ctx.Register()
- ctx.MockFileSystem(map[string][]byte{
- "prebuilt_file": nil,
- "source_file": nil,
- "Blueprints": []byte(`
- source {
- name: "foo",
- deps: [":bar"],
- }
- ` + test.modules),
- })
+ ctx.Register(config)
- _, errs := ctx.ParseBlueprintsFiles("Blueprints")
+ _, errs := ctx.ParseBlueprintsFiles("Android.bp")
FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
FailIfErrored(t, errs)