diff options
author | 2023-04-26 16:39:20 +0900 | |
---|---|---|
committer | 2023-04-26 16:46:03 +0900 | |
commit | a2b57abb4ab379ae3f3747e0c97efabeacdf4a28 (patch) | |
tree | 8d0ad3f08d5e738cbe37326b6ed15ce80f8fde99 | |
parent | dfd4c8b8a43cabf4b2a5d7048f714ef202315774 (diff) |
Remove makefile_goal
This was added to use 'make' target in soong. It was a hacky way and
caused many problems:
- can't track dependency
- doesn't work with sanitizer
- VSDK snapshot doesn't support
- ..
Now references are all gone. Let's remove it.
Bug: n/a
Test: m
Change-Id: I0336a490780f37a4e77d343c61315686e23db643
-rw-r--r-- | android/Android.bp | 1 | ||||
-rw-r--r-- | android/makefile_goal.go | 98 | ||||
-rw-r--r-- | android/neverallow.go | 15 | ||||
-rw-r--r-- | android/neverallow_test.go | 59 |
4 files changed, 0 insertions, 173 deletions
diff --git a/android/Android.bp b/android/Android.bp index 641c438f1..2bc96f1e8 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -60,7 +60,6 @@ bootstrap_go_package { "license_metadata.go", "license_sdk_member.go", "licenses.go", - "makefile_goal.go", "makevars.go", "metrics.go", "module.go", diff --git a/android/makefile_goal.go b/android/makefile_goal.go deleted file mode 100644 index 07354a648..000000000 --- a/android/makefile_goal.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2020 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 android - -import ( - "fmt" - "io" - "path/filepath" - - "github.com/google/blueprint/proptools" -) - -func init() { - RegisterModuleType("makefile_goal", MakefileGoalFactory) -} - -type makefileGoalProperties struct { - // Sources. - - // Makefile goal output file path, relative to PRODUCT_OUT. - Product_out_path *string -} - -type makefileGoal struct { - ModuleBase - - properties makefileGoalProperties - - // Destination. Output file path of this module. - outputFilePath OutputPath -} - -var _ AndroidMkEntriesProvider = (*makefileGoal)(nil) -var _ OutputFileProducer = (*makefileGoal)(nil) - -// Input file of this makefile_goal module. Nil if none specified. May use variable names in makefiles. -func (p *makefileGoal) inputPath() *string { - if p.properties.Product_out_path != nil { - return proptools.StringPtr(filepath.Join("$(PRODUCT_OUT)", proptools.String(p.properties.Product_out_path))) - } - return nil -} - -// OutputFileProducer -func (p *makefileGoal) OutputFiles(tag string) (Paths, error) { - if tag != "" { - return nil, fmt.Errorf("unsupported tag %q", tag) - } - return Paths{p.outputFilePath}, nil -} - -// AndroidMkEntriesProvider -func (p *makefileGoal) DepsMutator(ctx BottomUpMutatorContext) { - if p.inputPath() == nil { - ctx.PropertyErrorf("product_out_path", "Path relative to PRODUCT_OUT required") - } -} - -func (p *makefileGoal) GenerateAndroidBuildActions(ctx ModuleContext) { - filename := filepath.Base(proptools.String(p.inputPath())) - p.outputFilePath = PathForModuleOut(ctx, filename).OutputPath - - ctx.InstallFile(PathForModuleInstall(ctx, "etc"), ctx.ModuleName(), p.outputFilePath) -} - -func (p *makefileGoal) AndroidMkEntries() []AndroidMkEntries { - return []AndroidMkEntries{AndroidMkEntries{ - Class: "ETC", - OutputFile: OptionalPathForPath(p.outputFilePath), - ExtraFooters: []AndroidMkExtraFootersFunc{ - func(w io.Writer, name, prefix, moduleDir string) { - // Can't use Cp because inputPath() is not a valid Path. - fmt.Fprintf(w, "$(eval $(call copy-one-file,%s,%s))\n", proptools.String(p.inputPath()), p.outputFilePath) - }, - }, - }} -} - -// Import a Makefile goal to Soong by copying the file built by -// the goal to a path visible to Soong. This rule only works on boot images. -func MakefileGoalFactory() Module { - module := &makefileGoal{} - module.AddProperties(&module.properties) - InitAndroidModule(module) - return module -} diff --git a/android/neverallow.go b/android/neverallow.go index 2139c3c3e..5b5e61328 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -55,7 +55,6 @@ func init() { AddNeverAllowRules(createJavaDeviceForHostRules()...) AddNeverAllowRules(createCcSdkVariantRules()...) AddNeverAllowRules(createUncompressDexRules()...) - AddNeverAllowRules(createMakefileGoalRules()...) AddNeverAllowRules(createInitFirstStageRules()...) AddNeverAllowRules(createProhibitFrameworkAccessRules()...) AddNeverAllowRules(createBp2BuildRule()) @@ -236,20 +235,6 @@ func createUncompressDexRules() []Rule { } } -func createMakefileGoalRules() []Rule { - allowlist := []string{ - // libwifi_hal uses makefile_goal for its dependencies - "frameworks/opt/net/wifi/libwifi_hal", - } - return []Rule{ - NeverAllow(). - ModuleType("makefile_goal"). - WithoutMatcher("product_out_path", Regexp("^boot[0-9a-zA-Z.-]*[.]img$")). - NotIn(allowlist...). - Because("Only boot images may be imported as a makefile goal if not in allowed projects"), - } -} - func createInitFirstStageRules() []Rule { return []Rule{ NeverAllow(). diff --git a/android/neverallow_test.go b/android/neverallow_test.go index 5f5f9a193..ddd982d15 100644 --- a/android/neverallow_test.go +++ b/android/neverallow_test.go @@ -313,45 +313,6 @@ var neverallowTests = []struct { "module \"outside_art_libraries\": violates neverallow", }, }, - { - name: "disallowed makefile_goal", - fs: map[string][]byte{ - "Android.bp": []byte(` - makefile_goal { - name: "foo", - product_out_path: "boot/trap.img" - } - `), - }, - expectedErrors: []string{ - "Only boot images.* may be imported as a makefile goal", - }, - }, - { - name: "disallowed makefile_goal outside external", - fs: map[string][]byte{ - "project/Android.bp": []byte(` - makefile_goal { - name: "foo", - product_out_path: "obj/EXE/foo", - } - `), - }, - expectedErrors: []string{ - "not in allowed projects", - }, - }, - { - name: "allow makefile_goal within external", - fs: map[string][]byte{ - "frameworks/opt/net/wifi/libwifi_hal/Android.bp": []byte(` - makefile_goal { - name: "foo", - product_out_path: "obj/EXE/foo", - } - `), - }, - }, // Tests for the rule prohibiting the use of framework { name: "prohibit framework", @@ -391,7 +352,6 @@ var prepareForNeverAllowTest = GroupFixturePreparers( ctx.RegisterModuleType("java_library", newMockJavaLibraryModule) ctx.RegisterModuleType("java_library_host", newMockJavaLibraryModule) ctx.RegisterModuleType("java_device_for_host", newMockJavaLibraryModule) - ctx.RegisterModuleType("makefile_goal", newMockMakefileGoalModule) }), ) @@ -489,22 +449,3 @@ func newMockJavaLibraryModule() Module { func (p *mockJavaLibraryModule) GenerateAndroidBuildActions(ModuleContext) { } - -type mockMakefileGoalProperties struct { - Product_out_path *string -} - -type mockMakefileGoalModule struct { - ModuleBase - properties mockMakefileGoalProperties -} - -func newMockMakefileGoalModule() Module { - m := &mockMakefileGoalModule{} - m.AddProperties(&m.properties) - InitAndroidModule(m) - return m -} - -func (p *mockMakefileGoalModule) GenerateAndroidBuildActions(ModuleContext) { -} |