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

Commit 8d541848 authored by Cole Faust's avatar Cole Faust
Browse files

Add module dir to includes for cc_preprocess_no_configuration

This is needed to create the same behavior as other cc modules.

Bug: 372091092
Test: go test
Change-Id: I2c15dbc2c6a2b2ba693ef0f2a732525dd2f72d0f
parent ad5d8aa7
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package cc

import (
	"android/soong/android"
	"slices"
	"strings"
)

@@ -78,6 +79,12 @@ func (m *ccPreprocessNoConfiguration) GenerateAndroidBuildActions(ctx android.Mo
		return
	}

	cflags := slices.Clone(m.properties.Cflags)

	// Match behavior of other cc modules:
	// https://cs.android.com/android/platform/superproject/main/+/main:build/soong/cc/compiler.go;l=422;drc=7297f05ee8cda422ccb32c4af4d9d715d6bac10e
	cflags = append(cflags, "-I"+ctx.ModuleDir())

	var ccCmd string
	switch src.Ext() {
	case ".c":
@@ -99,7 +106,7 @@ func (m *ccPreprocessNoConfiguration) GenerateAndroidBuildActions(ctx android.Mo
		Output:      outFile,
		Input:       src,
		Args: map[string]string{
			"cFlags": strings.Join(m.properties.Cflags, " "),
			"cFlags": strings.Join(cflags, " "),
			"ccCmd":  ccCmd,
		},
	})
+11 −8
Original line number Diff line number Diff line
@@ -20,21 +20,24 @@ import (
)

func TestCcPreprocessNoConfiguration(t *testing.T) {
	fixture := android.GroupFixturePreparers(
		android.PrepareForIntegrationTestWithAndroid,
		android.FixtureRegisterWithContext(RegisterCCPreprocessNoConfiguration),
	)

	result := fixture.RunTestWithBp(t, `
	bp := `
	cc_preprocess_no_configuration {
		name: "foo",
		srcs: ["main.cc"],
		cflags: ["-E", "-DANDROID"],
	}
`)
	`

	fixture := android.GroupFixturePreparers(
		android.PrepareForIntegrationTestWithAndroid,
		android.FixtureRegisterWithContext(RegisterCCPreprocessNoConfiguration),
		android.FixtureAddTextFile("foo/bar/Android.bp", bp),
	)

	result := fixture.RunTest(t)

	foo := result.ModuleForTests("foo", "")
	actual := foo.Rule("cc").Args["cFlags"]
	expected := "-E -DANDROID"
	expected := "-E -DANDROID -Ifoo/bar"
	android.AssertStringEquals(t, "cflags should be correct", expected, actual)
}