Merge "Revert "Add baseProps and fsProps into system bp generation"" into main
diff --git a/cc/cc_preprocess_no_configuration.go b/cc/cc_preprocess_no_configuration.go
index 3d1d0a5..3d4b077 100644
--- a/cc/cc_preprocess_no_configuration.go
+++ b/cc/cc_preprocess_no_configuration.go
@@ -16,6 +16,7 @@
 
 import (
 	"android/soong/android"
+	"slices"
 	"strings"
 )
 
@@ -78,6 +79,12 @@
 		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 @@
 		Output:      outFile,
 		Input:       src,
 		Args: map[string]string{
-			"cFlags": strings.Join(m.properties.Cflags, " "),
+			"cFlags": strings.Join(cflags, " "),
 			"ccCmd":  ccCmd,
 		},
 	})
diff --git a/cc/cc_preprocess_no_configuration_test.go b/cc/cc_preprocess_no_configuration_test.go
index 43e726d..c6eae4c 100644
--- a/cc/cc_preprocess_no_configuration_test.go
+++ b/cc/cc_preprocess_no_configuration_test.go
@@ -20,21 +20,24 @@
 )
 
 func TestCcPreprocessNoConfiguration(t *testing.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.RunTestWithBp(t, `
-cc_preprocess_no_configuration {
-	name: "foo",
-	srcs: ["main.cc"],
-	cflags: ["-E", "-DANDROID"],
-}
-`)
+	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)
 }
diff --git a/cc/compiler.go b/cc/compiler.go
index 022b712..7bba962 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -695,7 +695,9 @@
 
 	if ctx.optimizeForSize() {
 		flags.Local.CFlags = append(flags.Local.CFlags, "-Oz")
-		flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm,-enable-ml-inliner=release")
+		if !ctx.Config().IsEnvFalse("THINLTO_USE_MLGO") {
+			flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm,-enable-ml-inliner=release")
+		}
 	}
 
 	// Exclude directories from manual binder interface allowed list.
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index c94df09..89db166 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -482,10 +482,14 @@
 
 	var diffTestFiles []android.Path
 	for _, partitionType := range f.properties.Generated_partition_types {
-		diffTestFiles = append(diffTestFiles, f.createDiffTest(ctx, partitionType))
+		diffTestFile := f.createDiffTest(ctx, partitionType)
+		diffTestFiles = append(diffTestFiles, diffTestFile)
+		ctx.Phony(fmt.Sprintf("soong_generated_%s_filesystem_test", partitionType), diffTestFile)
 	}
 	for _, partitionType := range f.properties.Unsupported_partition_types {
-		diffTestFiles = append(diffTestFiles, createFailingCommand(ctx, fmt.Sprintf("Couldn't build %s partition", partitionType)))
+		diffTestFile := createFailingCommand(ctx, fmt.Sprintf("Couldn't build %s partition", partitionType))
+		diffTestFiles = append(diffTestFiles, diffTestFile)
+		ctx.Phony(fmt.Sprintf("soong_generated_%s_filesystem_test", partitionType), diffTestFile)
 	}
 	ctx.Phony("soong_generated_filesystem_tests", diffTestFiles...)
 }
diff --git a/java/app.go b/java/app.go
index dd99675..e112e93 100644
--- a/java/app.go
+++ b/java/app.go
@@ -30,7 +30,6 @@
 	"android/soong/android"
 	"android/soong/cc"
 	"android/soong/dexpreopt"
-	"android/soong/genrule"
 	"android/soong/tradefed"
 )
 
@@ -1333,7 +1332,7 @@
 			Srcs:  []string{":" + a.Name() + "{.apk}"},
 			Cmd:   proptools.StringPtr("$(location characteristics_rro_generator) $$($(location aapt2) dump packagename $(in)) $(out)"),
 		}
-		ctx.CreateModule(genrule.GenRuleFactory, &rroManifestProperties)
+		ctx.CreateModule(GenRuleFactory, &rroManifestProperties)
 
 		rroProperties := struct {
 			Name           *string
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 637da36..5928446 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -562,7 +562,7 @@
 	// TODO(b/346662300): Let dexpreopter generate the installPath for dexpreopt files instead of
 	// using the dex location to generate the installPath.
 	if isApexSystemServerJar {
-		dexpreoptPartition = "system"
+		dexpreoptPartition = dexpreoptConfig.ApexPartition
 	}
 	for _, install := range dexpreoptRule.Installs() {
 		// Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT.