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

Commit 1b0d9291 authored by Cole Faust's avatar Cole Faust Committed by Gerrit Code Review
Browse files

Merge "Make the cflags property configurable" into main

parents 000fe5ac e96c16a8
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
<<$srcs := getSources .M>>
<<$srcs := getSources .M>>
<<$includeDirs := getIncludeDirs .Ctx .M>>
<<$includeDirs := getIncludeDirs .Ctx .M>>
<<$cflags := (getCompilerProperties .M).Cflags>>
<<$cflags := getCflagsProperty .Ctx .M>>
<<$deps := mapLibraries .Ctx .M (concat5
<<$deps := mapLibraries .Ctx .M (concat5
(getLinkerProperties .M).Whole_static_libs
(getLinkerProperties .M).Whole_static_libs
(getLinkerProperties .M).Static_libs
(getLinkerProperties .M).Static_libs
+4 −0
Original line number Original line Diff line number Diff line
@@ -187,6 +187,10 @@ func parseTemplate(templateContents string) *template.Template {
		"getCompilerProperties": func(m *Module) BaseCompilerProperties {
		"getCompilerProperties": func(m *Module) BaseCompilerProperties {
			return m.compiler.baseCompilerProps()
			return m.compiler.baseCompilerProps()
		},
		},
		"getCflagsProperty": func(ctx android.ModuleContext, m *Module) []string {
			cflags := m.compiler.baseCompilerProps().Cflags
			return cflags.GetOrDefault(ctx, nil)
		},
		"getLinkerProperties": func(m *Module) BaseLinkerProperties {
		"getLinkerProperties": func(m *Module) BaseLinkerProperties {
			return m.linker.baseLinkerProps()
			return m.linker.baseLinkerProps()
		},
		},
+6 −5
Original line number Original line Diff line number Diff line
@@ -50,7 +50,7 @@ type BaseCompilerProperties struct {
	Exclude_srcs []string `android:"path,arch_variant"`
	Exclude_srcs []string `android:"path,arch_variant"`


	// list of module-specific flags that will be used for C and C++ compiles.
	// list of module-specific flags that will be used for C and C++ compiles.
	Cflags []string `android:"arch_variant"`
	Cflags proptools.Configurable[[]string] `android:"arch_variant"`


	// list of module-specific flags that will be used for C++ compiles
	// list of module-specific flags that will be used for C++ compiles
	Cppflags []string `android:"arch_variant"`
	Cppflags []string `android:"arch_variant"`
@@ -274,7 +274,7 @@ func (compiler *baseCompiler) Srcs() android.Paths {
}
}


func (compiler *baseCompiler) appendCflags(flags []string) {
func (compiler *baseCompiler) appendCflags(flags []string) {
	compiler.Properties.Cflags = append(compiler.Properties.Cflags, flags...)
	compiler.Properties.Cflags.AppendSimpleValue(flags)
}
}


func (compiler *baseCompiler) appendAsflags(flags []string) {
func (compiler *baseCompiler) appendAsflags(flags []string) {
@@ -372,7 +372,8 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
	compiler.srcsBeforeGen = android.PathsForModuleSrcExcludes(ctx, compiler.Properties.Srcs, compiler.Properties.Exclude_srcs)
	compiler.srcsBeforeGen = android.PathsForModuleSrcExcludes(ctx, compiler.Properties.Srcs, compiler.Properties.Exclude_srcs)
	compiler.srcsBeforeGen = append(compiler.srcsBeforeGen, deps.GeneratedSources...)
	compiler.srcsBeforeGen = append(compiler.srcsBeforeGen, deps.GeneratedSources...)


	CheckBadCompilerFlags(ctx, "cflags", compiler.Properties.Cflags)
	cflags := compiler.Properties.Cflags.GetOrDefault(ctx, nil)
	CheckBadCompilerFlags(ctx, "cflags", cflags)
	CheckBadCompilerFlags(ctx, "cppflags", compiler.Properties.Cppflags)
	CheckBadCompilerFlags(ctx, "cppflags", compiler.Properties.Cppflags)
	CheckBadCompilerFlags(ctx, "conlyflags", compiler.Properties.Conlyflags)
	CheckBadCompilerFlags(ctx, "conlyflags", compiler.Properties.Conlyflags)
	CheckBadCompilerFlags(ctx, "asflags", compiler.Properties.Asflags)
	CheckBadCompilerFlags(ctx, "asflags", compiler.Properties.Asflags)
@@ -385,7 +386,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps


	esc := proptools.NinjaAndShellEscapeList
	esc := proptools.NinjaAndShellEscapeList


	flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Cflags)...)
	flags.Local.CFlags = append(flags.Local.CFlags, esc(cflags)...)
	flags.Local.CppFlags = append(flags.Local.CppFlags, esc(compiler.Properties.Cppflags)...)
	flags.Local.CppFlags = append(flags.Local.CppFlags, esc(compiler.Properties.Cppflags)...)
	flags.Local.ConlyFlags = append(flags.Local.ConlyFlags, esc(compiler.Properties.Conlyflags)...)
	flags.Local.ConlyFlags = append(flags.Local.ConlyFlags, esc(compiler.Properties.Conlyflags)...)
	flags.Local.AsFlags = append(flags.Local.AsFlags, esc(compiler.Properties.Asflags)...)
	flags.Local.AsFlags = append(flags.Local.AsFlags, esc(compiler.Properties.Asflags)...)
@@ -819,7 +820,7 @@ type RustBindgenClangProperties struct {
	Header_libs []string `android:"arch_variant,variant_prepend"`
	Header_libs []string `android:"arch_variant,variant_prepend"`


	// list of clang flags required to correctly interpret the headers.
	// list of clang flags required to correctly interpret the headers.
	Cflags []string `android:"arch_variant"`
	Cflags proptools.Configurable[[]string] `android:"arch_variant"`


	// list of c++ specific clang flags required to correctly interpret the headers.
	// list of c++ specific clang flags required to correctly interpret the headers.
	// This is provided primarily to make sure cppflags defined in cc_defaults are pulled in.
	// This is provided primarily to make sure cppflags defined in cc_defaults are pulled in.
+5 −5
Original line number Original line Diff line number Diff line
@@ -149,7 +149,7 @@ type StaticOrSharedProperties struct {


	Sanitized Sanitized `android:"arch_variant"`
	Sanitized Sanitized `android:"arch_variant"`


	Cflags []string `android:"arch_variant"`
	Cflags proptools.Configurable[[]string] `android:"arch_variant"`


	Enabled            *bool    `android:"arch_variant"`
	Enabled            *bool    `android:"arch_variant"`
	Whole_static_libs  []string `android:"arch_variant"`
	Whole_static_libs  []string `android:"arch_variant"`
@@ -464,9 +464,9 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla
	}
	}


	if library.static() {
	if library.static() {
		flags.Local.CFlags = append(flags.Local.CFlags, library.StaticProperties.Static.Cflags...)
		flags.Local.CFlags = append(flags.Local.CFlags, library.StaticProperties.Static.Cflags.GetOrDefault(ctx, nil)...)
	} else if library.shared() {
	} else if library.shared() {
		flags.Local.CFlags = append(flags.Local.CFlags, library.SharedProperties.Shared.Cflags...)
		flags.Local.CFlags = append(flags.Local.CFlags, library.SharedProperties.Shared.Cflags.GetOrDefault(ctx, nil)...)
	}
	}


	if library.shared() {
	if library.shared() {
@@ -2081,8 +2081,8 @@ func reuseStaticLibrary(mctx android.BottomUpMutatorContext, static, shared *Mod


		// Check libraries in addition to cflags, since libraries may be exporting different
		// Check libraries in addition to cflags, since libraries may be exporting different
		// include directories.
		// include directories.
		if len(staticCompiler.StaticProperties.Static.Cflags) == 0 &&
		if len(staticCompiler.StaticProperties.Static.Cflags.GetOrDefault(mctx, nil)) == 0 &&
			len(sharedCompiler.SharedProperties.Shared.Cflags) == 0 &&
			len(sharedCompiler.SharedProperties.Shared.Cflags.GetOrDefault(mctx, nil)) == 0 &&
			len(staticCompiler.StaticProperties.Static.Whole_static_libs) == 0 &&
			len(staticCompiler.StaticProperties.Static.Whole_static_libs) == 0 &&
			len(sharedCompiler.SharedProperties.Shared.Whole_static_libs) == 0 &&
			len(sharedCompiler.SharedProperties.Shared.Whole_static_libs) == 0 &&
			len(staticCompiler.StaticProperties.Static.Static_libs) == 0 &&
			len(staticCompiler.StaticProperties.Static.Static_libs) == 0 &&
+3 −2
Original line number Original line Diff line number Diff line
@@ -236,7 +236,8 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr
	esc := proptools.NinjaAndShellEscapeList
	esc := proptools.NinjaAndShellEscapeList


	// Filter out invalid cflags
	// Filter out invalid cflags
	for _, flag := range b.ClangProperties.Cflags {
	cflagsProp := b.ClangProperties.Cflags.GetOrDefault(ctx, nil)
	for _, flag := range cflagsProp {
		if flag == "-x c++" || flag == "-xc++" {
		if flag == "-x c++" || flag == "-xc++" {
			ctx.PropertyErrorf("cflags",
			ctx.PropertyErrorf("cflags",
				"-x c++ should not be specified in cflags; setting cpp_std specifies this is a C++ header, or change the file extension to '.hpp' or '.hh'")
				"-x c++ should not be specified in cflags; setting cpp_std specifies this is a C++ header, or change the file extension to '.hpp' or '.hh'")
@@ -248,7 +249,7 @@ func (b *bindgenDecorator) GenerateSource(ctx ModuleContext, deps PathDeps) andr
	}
	}


	// Module defined clang flags and include paths
	// Module defined clang flags and include paths
	cflags = append(cflags, esc(b.ClangProperties.Cflags)...)
	cflags = append(cflags, esc(cflagsProp)...)
	for _, include := range b.ClangProperties.Local_include_dirs {
	for _, include := range b.ClangProperties.Local_include_dirs {
		cflags = append(cflags, "-I"+android.PathForModuleSrc(ctx, include).String())
		cflags = append(cflags, "-I"+android.PathForModuleSrc(ctx, include).String())
		implicits = append(implicits, android.PathForModuleSrc(ctx, include))
		implicits = append(implicits, android.PathForModuleSrc(ctx, include))