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

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

Merge "Modify Soong to utilize from-text android.jar in build"

parents f1e0ce07 1bff0349
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -100,6 +100,8 @@ type CmdArgs struct {
	BazelForceEnabledModules string

	UseBazelProxy bool

	BuildFromTextStub bool
}

// Build modes that soong_build can run as.
@@ -272,6 +274,10 @@ type config struct {
	// If true, for any requests to Bazel, communicate with a Bazel proxy using
	// unix sockets, instead of spawning Bazel as a subprocess.
	UseBazelProxy bool

	// If buildFromTextStub is true then the Java API stubs are
	// built from the signature text files, not the source Java files.
	buildFromTextStub bool
}

type deviceConfig struct {
@@ -466,6 +472,8 @@ func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error)

		MultitreeBuild: cmdArgs.MultitreeBuild,
		UseBazelProxy:  cmdArgs.UseBazelProxy,

		buildFromTextStub: cmdArgs.BuildFromTextStub,
	}

	config.deviceConfig = &deviceConfig{
@@ -1882,3 +1890,7 @@ func (c *config) ApiSurfacesDir(s ApiSurface, version string) string {
		s.String(),
		version)
}

func (c *config) BuildFromTextStub() bool {
	return c.buildFromTextStub
}
+3 −2
Original line number Diff line number Diff line
@@ -94,8 +94,9 @@ func (k SdkKind) JavaLibraryName(c Config) string {
// not check if either module exists.
// TODO: Return .txt (single-tree or multi-tree equivalents) based on config
func JavaLibraryNameFromText(c Config, name string) string {
	// This returns the default for now.
	// TODO: Implement this
	if c.BuildFromTextStub() {
		return name + ".from-text"
	}
	return name
}

+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ func init() {
	flag.BoolVar(&cmdlineArgs.BazelModeStaging, "bazel-mode-staging", false, "use bazel for analysis of certain near-ready modules")
	flag.BoolVar(&cmdlineArgs.BazelModeDev, "bazel-mode-dev", false, "use bazel for analysis of a large number of modules (less stable)")
	flag.BoolVar(&cmdlineArgs.UseBazelProxy, "use-bazel-proxy", false, "communicate with bazel using unix socket proxy instead of spawning subprocesses")
	flag.BoolVar(&cmdlineArgs.BuildFromTextStub, "build-from-text-stub", false, "build Java stubs from API text files instead of source files")

	// Flags that probably shouldn't be flags of soong_build, but we haven't found
	// the time to remove them yet
+19 −0
Original line number Diff line number Diff line
@@ -733,3 +733,22 @@ func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
		},
	}
}

func (al *ApiLibrary) AndroidMkEntries() []android.AndroidMkEntries {
	var entriesList []android.AndroidMkEntries

	entriesList = append(entriesList, android.AndroidMkEntries{
		Class:      "JAVA_LIBRARIES",
		OutputFile: android.OptionalPathForPath(al.stubsJar),
		Include:    "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
		ExtraEntries: []android.AndroidMkExtraEntriesFunc{
			func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
				entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
				entries.SetPath("LOCAL_SOONG_CLASSES_JAR", al.stubsJar)
				entries.SetPath("LOCAL_SOONG_HEADER_JAR", al.stubsJar)
			},
		},
	})

	return entriesList
}
+18 −1
Original line number Diff line number Diff line
@@ -1697,6 +1697,12 @@ func metalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder,
		Flag("--color").
		Flag("--quiet").
		Flag("--format=v2").
		Flag("--include-annotations").
		// The flag makes nullability issues as warnings rather than errors by replacing
		// @Nullable/@NonNull in the listed packages APIs with @RecentlyNullable/@RecentlyNonNull,
		// and these packages are meant to have everything annotated
		// @RecentlyNullable/@RecentlyNonNull.
		FlagWithArg("--force-convert-to-warning-nullability-annotations ", "+*:-android.*:+android.icu.*:-dalvik.*").
		FlagWithArg("--repeat-errors-max ", "10").
		FlagWithArg("--hide ", "UnresolvedImport").
		FlagWithArg("--hide ", "InvalidNullabilityOverride").
@@ -1705,6 +1711,14 @@ func metalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder,
	return cmd
}

func (al *ApiLibrary) HeaderJars() android.Paths {
	return android.Paths{al.stubsJar}
}

func (al *ApiLibrary) OutputDirAndDeps() (android.Path, android.Paths) {
	return nil, nil
}

func (al *ApiLibrary) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsDir android.OptionalPath) {
	if stubsDir.Valid() {
		cmd.FlagWithArg("--stubs ", stubsDir.String())
@@ -1817,6 +1831,9 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {

	ctx.SetProvider(JavaInfoProvider, JavaInfo{
		HeaderJars:                     android.PathsIfNonNil(al.stubsJar),
		ImplementationAndResourcesJars: android.PathsIfNonNil(al.stubsJar),
		ImplementationJars:             android.PathsIfNonNil(al.stubsJar),
		AidlIncludeDirs:                android.Paths{},
	})
}

Loading