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

Commit ef002477 authored by Aleks Todorov's avatar Aleks Todorov Committed by Gerrit Code Review
Browse files

Merge "cc: Make export_include_dirs configurable" into main

parents cdb8501c c9becde0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -507,7 +507,7 @@ func getIncludeDirs(ctx android.ModuleContext, m *Module) []string {
	moduleDir := ctx.OtherModuleDir(m) + string(filepath.Separator)
	switch decorator := m.compiler.(type) {
	case *libraryDecorator:
		return sliceWithPrefix(moduleDir, decorator.flagExporter.Properties.Export_include_dirs)
		return sliceWithPrefix(moduleDir, decorator.flagExporter.Properties.Export_include_dirs.GetOrDefault(ctx, nil))
	}
	return nil
}
+16 −6
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ type FlagExporterProperties struct {
	// be added to the include path (using -I) for this module and any module that links
	// against this module.  Directories listed in export_include_dirs do not need to be
	// listed in local_include_dirs.
	Export_include_dirs []string `android:"arch_variant,variant_prepend"`
	Export_include_dirs proptools.Configurable[[]string] `android:"arch_variant,variant_prepend"`

	// list of directories that will be added to the system include path
	// using -isystem for this module and any module that links against this module.
@@ -292,7 +292,7 @@ func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
	if ctx.inProduct() && f.Properties.Target.Product.Override_export_include_dirs != nil {
		return android.PathsForModuleSrc(ctx, f.Properties.Target.Product.Override_export_include_dirs)
	}
	return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs)
	return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs.GetOrDefault(ctx, nil))
}

func (f *flagExporter) exportedSystemIncludes(ctx ModuleContext) android.Paths {
@@ -1588,14 +1588,19 @@ func (library *libraryDecorator) link(ctx ModuleContext,
		// override the module's export_include_dirs with llndk.override_export_include_dirs
		// if it is set.
		if override := library.Properties.Llndk.Override_export_include_dirs; override != nil {
			library.flagExporter.Properties.Export_include_dirs = override
			library.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](
				nil,
				[]proptools.ConfigurableCase[[]string]{
					proptools.NewConfigurableCase[[]string](nil, &override),
				},
			)
		}

		if Bool(library.Properties.Llndk.Export_headers_as_system) {
			library.flagExporter.Properties.Export_system_include_dirs = append(
				library.flagExporter.Properties.Export_system_include_dirs,
				library.flagExporter.Properties.Export_include_dirs...)
			library.flagExporter.Properties.Export_include_dirs = nil
				library.flagExporter.Properties.Export_include_dirs.GetOrDefault(ctx, nil)...)
			library.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](nil, nil)
		}
	}

@@ -1603,7 +1608,12 @@ func (library *libraryDecorator) link(ctx ModuleContext,
		// override the module's export_include_dirs with vendor_public_library.override_export_include_dirs
		// if it is set.
		if override := library.Properties.Vendor_public_library.Override_export_include_dirs; override != nil {
			library.flagExporter.Properties.Export_include_dirs = override
			library.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](
				nil,
				[]proptools.ConfigurableCase[[]string]{
					proptools.NewConfigurableCase[[]string](nil, &override),
				},
			)
		}
	}

+12 −5
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import (

	"android/soong/android"
	"android/soong/multitree"

	"github.com/google/blueprint/proptools"
)

var (
@@ -122,7 +124,7 @@ func (d *apiLibraryDecorator) Name(basename string) string {
// The directories are not guaranteed to exist during Soong analysis.
func (d *apiLibraryDecorator) exportIncludes(ctx ModuleContext) {
	exporterProps := d.flagExporter.Properties
	for _, dir := range exporterProps.Export_include_dirs {
	for _, dir := range exporterProps.Export_include_dirs.GetOrDefault(ctx, nil) {
		d.dirs = append(d.dirs, android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), dir))
	}
	// system headers
@@ -178,16 +180,21 @@ func (d *apiLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps
				in = variantMod.Src()

				// Copy LLDNK properties to cc_api_library module
				d.libraryDecorator.flagExporter.Properties.Export_include_dirs = append(
					d.libraryDecorator.flagExporter.Properties.Export_include_dirs,
				exportIncludeDirs := append(d.libraryDecorator.flagExporter.Properties.Export_include_dirs.GetOrDefault(ctx, nil),
					variantMod.exportProperties.Export_include_dirs...)
				d.libraryDecorator.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](
					nil,
					[]proptools.ConfigurableCase[[]string]{
						proptools.NewConfigurableCase[[]string](nil, &exportIncludeDirs),
					},
				)

				// Export headers as system include dirs if specified. Mostly for libc
				if Bool(variantMod.exportProperties.Export_headers_as_system) {
					d.libraryDecorator.flagExporter.Properties.Export_system_include_dirs = append(
						d.libraryDecorator.flagExporter.Properties.Export_system_include_dirs,
						d.libraryDecorator.flagExporter.Properties.Export_include_dirs...)
					d.libraryDecorator.flagExporter.Properties.Export_include_dirs = nil
						d.libraryDecorator.flagExporter.Properties.Export_include_dirs.GetOrDefault(ctx, nil)...)
					d.libraryDecorator.flagExporter.Properties.Export_include_dirs = proptools.NewConfigurable[[]string](nil, nil)
				}
			}
		}