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

Commit ed87513b authored by Paul Duffin's avatar Paul Duffin
Browse files

Extract dist properties from commonProperties

Common properties are automatically inherited from a parent module
(i.e. one that calls CreateModule()) to the child module that it
creates. This makes no sense for dist/dists properties so this change
extracts them into their own structure separate to the
commonProperties.

Test: m checkbuild and TreeHugger
Bug: 160448975
Change-Id: Icceb20455e13394dd3b3bce464fb9bb34882d6c3
parent 4f78c512
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -195,7 +195,8 @@ func InitDefaultsModule(module DefaultsModule) {
	module.AddProperties(
		&hostAndDeviceProperties{},
		commonProperties,
		&ApexProperties{})
		&ApexProperties{},
		&distProperties{})

	initAndroidModuleBase(module)
	initProductVariableModule(module)
+23 −19
Original line number Diff line number Diff line
@@ -490,14 +490,6 @@ type commonProperties struct {
	// relative path to a file to include in the list of notices for the device
	Notice *string `android:"path"`

	// configuration to distribute output files from this module to the distribution
	// directory (default: $OUT/dist, configurable with $DIST_DIR)
	Dist Dist `android:"arch_variant"`

	// a list of configurations to distribute output files from this module to the
	// distribution directory (default: $OUT/dist, configurable with $DIST_DIR)
	Dists []Dist `android:"arch_variant"`

	// The OsType of artifacts that this module variant is responsible for creating.
	//
	// Set by osMutator
@@ -566,6 +558,16 @@ type commonProperties struct {
	ImageVariation string `blueprint:"mutated"`
}

type distProperties struct {
	// configuration to distribute output files from this module to the distribution
	// directory (default: $OUT/dist, configurable with $DIST_DIR)
	Dist Dist `android:"arch_variant"`

	// a list of configurations to distribute output files from this module to the
	// distribution directory (default: $OUT/dist, configurable with $DIST_DIR)
	Dists []Dist `android:"arch_variant"`
}

// A map of OutputFile tag keys to Paths, for disting purposes.
type TaggedDistFiles map[string]Paths

@@ -661,7 +663,8 @@ func InitAndroidModule(m Module) {

	m.AddProperties(
		&base.nameProperties,
		&base.commonProperties)
		&base.commonProperties,
		&base.distProperties)

	initProductVariableModule(m)

@@ -752,6 +755,7 @@ type ModuleBase struct {

	nameProperties          nameProperties
	commonProperties        commonProperties
	distProperties          distProperties
	variableProperties      interface{}
	hostAndDeviceProperties hostAndDeviceProperties
	generalProperties       []interface{}
@@ -861,13 +865,13 @@ func (m *ModuleBase) visibilityProperties() []visibilityProperty {
}

func (m *ModuleBase) Dists() []Dist {
	if len(m.commonProperties.Dist.Targets) > 0 {
	if len(m.distProperties.Dist.Targets) > 0 {
		// Make a copy of the underlying Dists slice to protect against
		// backing array modifications with repeated calls to this method.
		distsCopy := append([]Dist(nil), m.commonProperties.Dists...)
		return append(distsCopy, m.commonProperties.Dist)
		distsCopy := append([]Dist(nil), m.distProperties.Dists...)
		return append(distsCopy, m.distProperties.Dist)
	} else {
		return m.commonProperties.Dists
		return m.distProperties.Dists
	}
}

@@ -1344,20 +1348,20 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
	ctx.Variable(pctx, "moduleDescSuffix", s)

	// Some common property checks for properties that will be used later in androidmk.go
	if m.commonProperties.Dist.Dest != nil {
		_, err := validateSafePath(*m.commonProperties.Dist.Dest)
	if m.distProperties.Dist.Dest != nil {
		_, err := validateSafePath(*m.distProperties.Dist.Dest)
		if err != nil {
			ctx.PropertyErrorf("dist.dest", "%s", err.Error())
		}
	}
	if m.commonProperties.Dist.Dir != nil {
		_, err := validateSafePath(*m.commonProperties.Dist.Dir)
	if m.distProperties.Dist.Dir != nil {
		_, err := validateSafePath(*m.distProperties.Dist.Dir)
		if err != nil {
			ctx.PropertyErrorf("dist.dir", "%s", err.Error())
		}
	}
	if m.commonProperties.Dist.Suffix != nil {
		if strings.Contains(*m.commonProperties.Dist.Suffix, "/") {
	if m.distProperties.Dist.Suffix != nil {
		if strings.Contains(*m.distProperties.Dist.Suffix, "/") {
			ctx.PropertyErrorf("dist.suffix", "Suffix may not contain a '/' character.")
		}
	}