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

Commit f835ded3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Export make vars using MakeVars method"

parents 3d186813 37eb8bbb
Loading
Loading
Loading
Loading
+8 −17
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ var String = proptools.String
func init() {
	android.RegisterModuleType("apex_key", apexKeyFactory)
	android.RegisterSingletonType("apex_keys_text", apexKeysTextFactory)
	android.RegisterMakeVarsProvider(pctx, apexKeysFileProvider)
}

type apexKey struct {
@@ -108,11 +107,12 @@ func (m *apexKey) AndroidMk() android.AndroidMkData {

////////////////////////////////////////////////////////////////////////
// apex_keys_text
type apexKeysText struct{}
type apexKeysText struct {
	output android.OutputPath
}

func (s *apexKeysText) GenerateBuildActions(ctx android.SingletonContext) {
	output := android.PathForOutput(ctx, "apexkeys.txt")
	*apexKeysFile(ctx.Config()) = output.String()
	s.output = android.PathForOutput(ctx, "apexkeys.txt")
	var filecontent strings.Builder
	ctx.VisitAllModules(func(module android.Module) {
		if m, ok := module.(android.Module); ok && !m.Enabled() {
@@ -131,27 +131,18 @@ func (s *apexKeysText) GenerateBuildActions(ctx android.SingletonContext) {
	})
	ctx.Build(pctx, android.BuildParams{
		Rule:        android.WriteFile,
		Description: "apex_keys.txt",
		Output:      output,
		Description: "apexkeys.txt",
		Output:      s.output,
		Args: map[string]string{
			"content": filecontent.String(),
		},
	})
}

var apexKeysFileKey = android.NewOnceKey("apexKeysFile")

func apexKeysFile(config android.Config) *string {
	return config.Once(apexKeysFileKey, func() interface{} {
		str := ""
		return &str
	}).(*string)
}

func apexKeysTextFactory() android.Singleton {
	return &apexKeysText{}
}

func apexKeysFileProvider(ctx android.MakeVarsContext) {
	ctx.Strict("SOONG_APEX_KEYS_FILE", *apexKeysFile(ctx.Config()))
func (s *apexKeysText) MakeVars(ctx android.MakeVarsContext) {
	ctx.Strict("SOONG_APEX_KEYS_FILE", s.output.String())
}