Skip to content

Commit 88d56e5

Browse files
BrandonThomasJonesARMJonathan Watson
authored andcommitted
feat(import_cc): add includes property
Change-Id: I505d42fe9f4ed53c38a85782705e0f44d84f9fa2
1 parent 20b240d commit 88d56e5

6 files changed

Lines changed: 20 additions & 5 deletions

File tree

core/import_cc.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type ImportCCProps struct {
1919
Target toolchain.TgtType
2020
Linkopts []string
2121
Defines []string
22+
Includes []string
2223
}
2324

2425
type ModuleImportCC struct {
@@ -34,6 +35,7 @@ var _ splittable = (*ModuleImportCC)(nil)
3435
type importCCInterface interface {
3536
splittable
3637
file.Provider
38+
flag.Provider
3739
}
3840

3941
func (m *ModuleImportCC) shortName() string {
@@ -43,6 +45,7 @@ func (m *ModuleImportCC) shortName() string {
4345
func (m *ModuleImportCC) processPaths(ctx blueprint.BaseModuleContext) {
4446
prefix := projectModuleDir(ctx)
4547
m.Properties.Headers = utils.PrefixDirs(m.Properties.Headers, prefix)
48+
m.Properties.Includes = utils.PrefixDirs(m.Properties.Includes, prefix)
4649
}
4750

4851
func (m *ModuleImportCC) OutFiles() (files file.Paths) {
@@ -58,7 +61,7 @@ func (m *ModuleImportCC) OutFiles() (files file.Paths) {
5861

5962
func (m *ModuleImportCC) FlagsOut() (flags flag.Flags) {
6063
headerPath := filepath.Join(backend.Get().BuildDir(), "gen", m.shortName())
61-
flags = append(flags, flag.FromIncludePathOwned(headerPath, m, flag.TypeInclude))
64+
flags = append(flags, flag.FromIncludePathOwned(headerPath, m, flag.TypeInclude|flag.TypeExported))
6265
lut := flag.FlagParserTable{
6366
{
6467
PropertyName: "Defines",
@@ -73,6 +76,11 @@ func (m *ModuleImportCC) FlagsOut() (flags flag.Flags) {
7376
}
7477
flags = append(flags, flag.ParseFromProperties(nil, lut, m.Properties)...)
7578

79+
for _, dir := range m.Properties.Includes {
80+
fp := file.NewPath(dir, m.Name(), file.TypeHeader)
81+
flags = append(flags, flag.FromIncludePath(fp.BuildPath(), flag.TypeInclude|flag.TypeExported))
82+
}
83+
7684
return
7785
}
7886

gendiffer/tests/cc_import/flags/out/linux/build.ninja.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ default import_lib_a
8080
# Factory: github.com/ARM-software/bob-build/core.Main.func1.1
8181
# Defined: build.bp:redacted
8282

83-
m.shared_lib_target.cflags = -DFOO
83+
m.shared_lib_target.cflags = -DFOO -I${g.bob.BuildDir}/gen/import_lib_a
8484
m.shared_lib_target.cxxflags =
8585

8686
build ${g.bob.BuildDir}/target/objects/shared_lib/main.cpp.o: g.bob.cxx $

gendiffer/tests/cc_import/header_only/app/build.bp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ bob_import_cc {
44
"libA/includes/a.h",
55
"libA/includes/a2.h",
66
],
7+
includes: [
8+
"libB/includes",
9+
],
710
target: "target",
811
}
912

gendiffer/tests/cc_import/header_only/out/linux/build.ninja.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ default import_lib_b
9494
# Factory: github.com/ARM-software/bob-build/core.Main.func1.1
9595
# Defined: build.bp:redacted
9696

97-
m.shared_lib_target.cflags =
97+
m.shared_lib_target.cflags = -I${g.bob.BuildDir}/gen/import_lib_a -I${g.bob.SrcDir}/libB/includes
9898
m.shared_lib_target.cxxflags =
9999

100100
build ${g.bob.BuildDir}/target/objects/shared_lib/main.cpp.o: g.bob.cxx $
@@ -107,7 +107,7 @@ build ${g.bob.BuildDir}/target/objects/shared_lib/main.cpp.o: g.bob.cxx $
107107
build ${g.bob.BuildDir}/target/shared/shared_lib.so: g.bob.shared_library $
108108
${g.bob.BuildDir}/target/objects/shared_lib/main.cpp.o
109109
build_wrapper =
110-
ldflags = -Wl,--as-needed -I${g.bob.BuildDir}/gen/import_lib_a
110+
ldflags = -Wl,--as-needed -I${g.bob.BuildDir}/gen/import_lib_a -I${g.bob.SrcDir}/libB/includes
111111
ldlibs =
112112
linker = g++
113113
shared_libs_dir = ${g.bob.BuildDir}/target/shared

tests/cc_import/build.bp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ bob_import_cc {
99

1010
bob_import_cc {
1111
name: "import_lib_b",
12-
headers: ["libB/includes/b.h"],
12+
includes: [
13+
"libB/includes",
14+
],
1315
target: "target",
1416
}
1517

@@ -20,6 +22,7 @@ bob_shared_library {
2022
],
2123
shared_libs: [
2224
"import_lib_a",
25+
"import_lib_b",
2326
],
2427
cflags: [
2528
"-fPIC",

tests/cc_import/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "libA/includes/a.h"
2+
#include "b.h"
23
int main()
34
{
45
if (a_return_true())

0 commit comments

Comments
 (0)