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

Commit 37eb8bbb authored by Jiyong Park's avatar Jiyong Park
Browse files

Export make vars using MakeVars method

ed023eca introduced a new (better) way
of exporting make vars from singletone. apex_keys_text singletone is
switched to the new method.

Test: inspect out/soong/make_vars-<target>.mk
Check SOONG_SOONG_APEX_KEYS_FILE is set

Change-Id: Ia218852ba9ae40070cb6c99340d97e0c77d19841
parent e0233a5b
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())
}