Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1b87c81 authored by Bob Badour's avatar Bob Badour Committed by Gerrit Code Review
Browse files

Merge changes from topic "revert-1377717-metalics-BOEMJWNSHV"

* changes:
  Revert "Add ability to declare licenses in soong."
  Revert "Export soong license data to make."
  Revert "Define the standard license_kind rules."
parents 659f11fc df98d3e4
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -30,9 +30,6 @@ bootstrap_go_package {
        "filegroup.go",
        "hooks.go",
        "image.go",
        "license.go",
        "license_kind.go",
        "licenses.go",
        "makefile_goal.go",
        "makevars.go",
        "metrics.go",
@@ -80,9 +77,6 @@ bootstrap_go_package {
        "depset_test.go",
        "deptag_test.go",
        "expand_test.go",
        "license_kind_test.go",
        "license_test.go",
        "licenses_test.go",
        "module_test.go",
        "mutator_test.go",
        "namespace_test.go",
+0 −45
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import (
	"io/ioutil"
	"os"
	"path/filepath"
	"reflect"
	"sort"
	"strings"

@@ -435,17 +434,6 @@ func (a *AndroidMkEntries) GetDistForGoals(mod blueprint.Module) []string {
	return generateDistContributionsForMake(distContributions)
}

// Write the license variables to Make for AndroidMkData.Custom(..) methods that do not call WriteAndroidMkData(..)
// It's required to propagate the license metadata even for module types that have non-standard interfaces to Make.
func (a *AndroidMkEntries) WriteLicenseVariables(w io.Writer) {
	fmt.Fprintln(w, "LOCAL_LICENSE_KINDS :=", strings.Join(a.EntryMap["LOCAL_LICENSE_KINDS"], " "))
	fmt.Fprintln(w, "LOCAL_LICENSE_CONDITIONS :=", strings.Join(a.EntryMap["LOCAL_LICENSE_CONDITIONS"], " "))
	fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", strings.Join(a.EntryMap["LOCAL_NOTICE_FILE"], " "))
	if pn, ok := a.EntryMap["LOCAL_LICENSE_PACKAGE_NAME"]; ok {
		fmt.Fprintln(w, "LOCAL_LICENSE_PACKAGE_NAME :=", strings.Join(pn, " "))
	}
}

// fillInEntries goes through the common variable processing and calls the extra data funcs to
// generate and fill in AndroidMkEntries's in-struct data, ready to be flushed to a file.
func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod blueprint.Module) {
@@ -472,13 +460,6 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
	// Collect make variable assignment entries.
	a.SetString("LOCAL_PATH", filepath.Dir(bpPath))
	a.SetString("LOCAL_MODULE", name+a.SubName)
	a.AddStrings("LOCAL_LICENSE_KINDS", amod.commonProperties.Effective_license_kinds...)
	a.AddStrings("LOCAL_LICENSE_CONDITIONS", amod.commonProperties.Effective_license_conditions...)
	a.AddStrings("LOCAL_NOTICE_FILE", amod.commonProperties.Effective_license_text...)
	// TODO(b/151177513): Does this code need to set LOCAL_MODULE_IS_CONTAINER ?
	if amod.commonProperties.Effective_package_name != nil {
		a.SetString("LOCAL_LICENSE_PACKAGE_NAME", *amod.commonProperties.Effective_package_name)
	}
	a.SetString("LOCAL_MODULE_CLASS", a.Class)
	a.SetString("LOCAL_PREBUILT_MODULE_FILE", a.OutputFile.String())
	a.AddStrings("LOCAL_REQUIRED_MODULES", a.Required...)
@@ -701,7 +682,6 @@ func translateAndroidMkModule(ctx SingletonContext, w io.Writer, mod blueprint.M
		}
	}()

	// Additional cases here require review for correct license propagation to make.
	switch x := mod.(type) {
	case AndroidMkDataProvider:
		return translateAndroidModule(ctx, w, mod, x)
@@ -710,7 +690,6 @@ func translateAndroidMkModule(ctx SingletonContext, w io.Writer, mod blueprint.M
	case AndroidMkEntriesProvider:
		return translateAndroidMkEntriesModule(ctx, w, mod, x)
	default:
		// Not exported to make so no make variables to set.
		return nil
	}
}
@@ -724,10 +703,6 @@ func translateGoBinaryModule(ctx SingletonContext, w io.Writer, mod blueprint.Mo
	fmt.Fprintln(w, ".PHONY:", name)
	fmt.Fprintln(w, name+":", goBinary.InstallPath())
	fmt.Fprintln(w, "")
	// Assuming no rules in make include go binaries in distributables.
	// If the assumption is wrong, make will fail to build without the necessary .meta_lic and .meta_module files.
	// In that case, add the targets and rules here to build a .meta_lic file for `name` and a .meta_module for
	// `goBinary.InstallPath()` pointing to the `name`.meta_lic file.

	return nil
}
@@ -793,25 +768,6 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, mod blueprint.Mod
	blueprintDir := filepath.Dir(ctx.BlueprintFile(mod))

	if data.Custom != nil {
		// List of module types allowed to use .Custom(...)
		// Additions to the list require careful review for proper license handling.
		switch reflect.TypeOf(mod).String() {  // ctx.ModuleType(mod) doesn't work: aidl_interface creates phony without type
		case "*aidl.aidlApi": // writes non-custom before adding .phony
		case "*aidl.aidlMapping": // writes non-custom before adding .phony
		case "*android.customModule": // appears in tests only
		case "*apex.apexBundle": // license properties written
		case "*bpf.bpf": // license properties written (both for module and objs)
		case "*genrule.Module": // writes non-custom before adding .phony
		case "*java.SystemModules": // doesn't go through base_rules
		case "*java.systemModulesImport": // doesn't go through base_rules
		case "*phony.phony": // license properties written
		case "*selinux.selinuxContextsModule": // license properties written
		case "*sysprop.syspropLibrary": // license properties written
		default:
			if ctx.Config().IsEnvTrue("ANDROID_REQUIRE_LICENSES") {
				return fmt.Errorf("custom make rules not allowed for %q (%q) module %q", ctx.ModuleType(mod), reflect.TypeOf(mod), ctx.ModuleName(mod))
			}
		}
		data.Custom(w, name, prefix, blueprintDir, data)
	} else {
		WriteAndroidMkData(w, data)
@@ -848,7 +804,6 @@ func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, mod blue
		return nil
	}

	// Any new or special cases here need review to verify correct propagation of license information.
	for _, entries := range provider.AndroidMkEntries() {
		entries.fillInEntries(ctx.Config(), ctx.BlueprintFile(mod), mod)
		entries.write(w)
+0 −3
Original line number Diff line number Diff line
@@ -204,9 +204,6 @@ func InitDefaultsModule(module DefaultsModule) {
	// its checking phase and parsing phase so add it to the list as a normal property.
	AddVisibilityProperty(module, "visibility", &commonProperties.Visibility)

	// The applicable licenses property for defaults is 'licenses'.
	setPrimaryLicensesProperty(module, "licenses", &commonProperties.Licenses)

	base.module = module
}

android/license.go

deleted100644 → 0
+0 −82
Original line number Diff line number Diff line
// 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 (
	"github.com/google/blueprint"
)

type licenseKindDependencyTag struct {
        blueprint.BaseDependencyTag
}

var (
	licenseKindTag = licenseKindDependencyTag{}
)

func init() {
	RegisterLicenseBuildComponents(InitRegistrationContext)
}

// Register the license module type.
func RegisterLicenseBuildComponents(ctx RegistrationContext) {
	ctx.RegisterModuleType("license", LicenseFactory)
}

type licenseProperties struct {
	// Specifies the kinds of license that apply.
	License_kinds []string
	// Specifies a short copyright notice to use for the license.
	Copyright_notice *string
	// Specifies the path or label for the text of the license.
	License_text []string `android:"path"`
	// Specifies the package name to which the license applies.
	Package_name *string
	// Specifies where this license can be used
	Visibility []string
}

type licenseModule struct {
	ModuleBase
	DefaultableModuleBase

	properties licenseProperties
}

func (m *licenseModule) DepsMutator(ctx BottomUpMutatorContext) {
	ctx.AddVariationDependencies(nil, licenseKindTag, m.properties.License_kinds...)
}

func (m *licenseModule) GenerateAndroidBuildActions(ctx ModuleContext) {
	// Nothing to do.
}

func LicenseFactory() Module {
	module := &licenseModule{}

	base := module.base()
	module.AddProperties(&base.nameProperties, &module.properties)

	base.generalProperties = module.GetProperties()
	base.customizableProperties = module.GetProperties()

	// The visibility property needs to be checked and parsed by the visibility module.
	setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)

	initAndroidModuleBase(module)
	InitDefaultableModule(module)

	return module
}

android/license_kind.go

deleted100644 → 0
+0 −66
Original line number Diff line number Diff line
// 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

func init() {
	RegisterLicenseKindBuildComponents(InitRegistrationContext)
}

// Register the license_kind module type.
func RegisterLicenseKindBuildComponents(ctx RegistrationContext) {
	ctx.RegisterModuleType("license_kind", LicenseKindFactory)
}

type licenseKindProperties struct {
	// Specifies the conditions for all licenses of the kind.
	Conditions []string
	// Specifies the url to the canonical license definition.
	Url string
	// Specifies where this license can be used
	Visibility []string
}

type licenseKindModule struct {
	ModuleBase
	DefaultableModuleBase

	properties licenseKindProperties
}

func (m *licenseKindModule) DepsMutator(ctx BottomUpMutatorContext) {
	// Nothing to do.
}

func (m *licenseKindModule) GenerateAndroidBuildActions(ModuleContext) {
	// Nothing to do.
}

func LicenseKindFactory() Module {
	module := &licenseKindModule{}

	base := module.base()
	module.AddProperties(&base.nameProperties, &module.properties)

	base.generalProperties = module.GetProperties()
	base.customizableProperties = module.GetProperties()

	// The visibility property needs to be checked and parsed by the visibility module.
	setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)

	initAndroidModuleBase(module)
	InitDefaultableModule(module)

	return module
}
Loading