diff options
| author | Dan Willemsen <dwillemsen@google.com> | 2018-02-23 21:00:53 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2018-02-23 21:00:53 +0000 |
| commit | 6c3ba6c46c59d96b9050f309b6e6581b59b7e1e3 (patch) | |
| tree | 72c459f74452f37107f29385c37d464e09af37d7 /cc | |
| parent | 77b3dc4172693c9e8b7ce17c7cbda61f3575c263 (diff) | |
| parent | fb408c8e6d2c9bc08df266672c817bfb64d654d0 (diff) | |
| download | build_soong-6c3ba6c46c59d96b9050f309b6e6581b59b7e1e3.tar.gz build_soong-6c3ba6c46c59d96b9050f309b6e6581b59b7e1e3.tar.bz2 build_soong-6c3ba6c46c59d96b9050f309b6e6581b59b7e1e3.zip | |
Merge "Add proto.canonical_path_from_root" am: 7c695eb797 am: c530837d4c
am: fb408c8e6d
Change-Id: I6bfe260cc2c8d67f73bdbb1eb70ee1df6bf33de4
Diffstat (limited to 'cc')
| -rw-r--r-- | cc/builder.go | 1 | ||||
| -rw-r--r-- | cc/cc.go | 1 | ||||
| -rw-r--r-- | cc/gen.go | 2 | ||||
| -rw-r--r-- | cc/library.go | 11 | ||||
| -rw-r--r-- | cc/proto.go | 33 | ||||
| -rw-r--r-- | cc/util.go | 1 |
6 files changed, 34 insertions, 15 deletions
diff --git a/cc/builder.go b/cc/builder.go index 8f253caa..1d12b5f0 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -252,6 +252,7 @@ type builderFlags struct { tidy bool coverage bool sAbiDump bool + protoRoot bool systemIncludeFlags string @@ -134,6 +134,7 @@ type Flags struct { Tidy bool Coverage bool SAbiDump bool + ProtoRoot bool RequiredInstructionSet string DynamicLinker string @@ -154,7 +154,7 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths, genLex(ctx, srcFile, cppFile) case ".proto": ccFile, headerFile := genProto(ctx, srcFile, buildFlags.protoFlags, - buildFlags.protoOutParams) + buildFlags.protoOutParams, buildFlags.protoRoot) srcFiles[i] = ccFile deps = append(deps, headerFile) case ".aidl": diff --git a/cc/library.go b/cc/library.go index f8e20e24..d3717dd9 100644 --- a/cc/library.go +++ b/cc/library.go @@ -690,12 +690,13 @@ func (library *libraryDecorator) link(ctx ModuleContext, if Bool(library.Properties.Proto.Export_proto_headers) { if library.baseCompiler.hasSrcExt(".proto") { - flags := []string{ - "-I" + android.ProtoSubDir(ctx).String(), - "-I" + android.ProtoDir(ctx).String(), + includes := []string{} + if flags.ProtoRoot { + includes = append(includes, "-I"+android.ProtoSubDir(ctx).String()) } - library.reexportFlags(flags) - library.reuseExportedFlags = append(library.reuseExportedFlags, flags...) + includes = append(includes, "-I"+android.ProtoDir(ctx).String()) + library.reexportFlags(includes) + library.reuseExportedFlags = append(library.reuseExportedFlags, includes...) library.reexportDeps(library.baseCompiler.pathDeps) // TODO: restrict to proto deps library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.pathDeps...) } diff --git a/cc/proto.go b/cc/proto.go index 3b5fd3b6..c53dcf40 100644 --- a/cc/proto.go +++ b/cc/proto.go @@ -15,7 +15,10 @@ package cc import ( + "strings" + "github.com/google/blueprint" + "github.com/google/blueprint/pathtools" "github.com/google/blueprint/proptools" "android/soong/android" @@ -28,18 +31,27 @@ func init() { var ( proto = pctx.AndroidStaticRule("protoc", blueprint.RuleParams{ - Command: "$protocCmd --cpp_out=$protoOutParams:$outDir $protoFlags $in", + Command: "$protocCmd --cpp_out=$protoOutParams:$outDir -I $protoBase $protoFlags $in", CommandDeps: []string{"$protocCmd"}, - }, "protoFlags", "protoOutParams", "outDir") + }, "protoFlags", "protoOutParams", "protoBase", "outDir") ) // genProto creates a rule to convert a .proto file to generated .pb.cc and .pb.h files and returns // the paths to the generated files. func genProto(ctx android.ModuleContext, protoFile android.Path, - protoFlags string, protoOutParams string) (ccFile, headerFile android.WritablePath) { + protoFlags, protoOutParams string, root bool) (ccFile, headerFile android.WritablePath) { - ccFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.cc") - headerFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.h") + var protoBase string + if root { + protoBase = "." + ccFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.cc") + headerFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.h") + } else { + rel := protoFile.Rel() + protoBase = strings.TrimSuffix(protoFile.String(), rel) + ccFile = android.PathForModuleGen(ctx, "proto", pathtools.ReplaceExtension(rel, "pb.cc")) + headerFile = android.PathForModuleGen(ctx, "proto", pathtools.ReplaceExtension(rel, "pb.h")) + } ctx.Build(pctx, android.BuildParams{ Rule: proto, @@ -50,6 +62,7 @@ func genProto(ctx android.ModuleContext, protoFile android.Path, "outDir": android.ProtoDir(ctx).String(), "protoFlags": protoFlags, "protoOutParams": protoOutParams, + "protoBase": protoBase, }, }) @@ -92,10 +105,12 @@ func protoDeps(ctx BaseModuleContext, deps Deps, p *android.ProtoProperties, sta func protoFlags(ctx ModuleContext, flags Flags, p *android.ProtoProperties) Flags { flags.CFlags = append(flags.CFlags, "-DGOOGLE_PROTOBUF_NO_RTTI") - flags.GlobalFlags = append(flags.GlobalFlags, - "-I"+android.ProtoSubDir(ctx).String(), - "-I"+android.ProtoDir(ctx).String(), - ) + + flags.ProtoRoot = android.ProtoCanonicalPathFromRoot(ctx, p) + if flags.ProtoRoot { + flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.ProtoSubDir(ctx).String()) + } + flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.ProtoDir(ctx).String()) flags.protoFlags = android.ProtoFlags(ctx, p) @@ -80,6 +80,7 @@ func flagsToBuilderFlags(in Flags) builderFlags { coverage: in.Coverage, tidy: in.Tidy, sAbiDump: in.SAbiDump, + protoRoot: in.ProtoRoot, systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "), |
