Skip to content

Commit

Permalink
build: Fix protobuf generation rules
Browse files Browse the repository at this point in the history
protoc 3.3 seems to handle paths differently than later releases. This
change modifies the way protoc is invoked to be compatible with all
likely versions.

We want the generated `.pb.h` and `.pb.cc` files to placed in a
directory like

    build/release/gen/src/protobuf

and we want the `.pb.cc` file to have imports of the form

    #include "metrics2.pb.h"

protoc's `-I` argument instructs protoc how to generate the import
statements.

Therefore, we invoke protoc with a qualified import path and an input
file which includes that path:

    protoc --cpp_out=build/release/gen/src/proto -Isrc/proto src/proto/metrics2.proto

Signed-off-by: Jesse Haber-Kucharsky <jhaberku@scylladb.com>
Message-Id: <6625b60c296d3f34e8c7d0e60847aaf68675989d.1542750394.git.jhaberku@scylladb.com>
  • Loading branch information
Jesse Haber-Kucharsky authored and avikivity committed Nov 20, 2018
1 parent 2ec0a04 commit b924495
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ def have_hwloc():
command = scripts/seastar-json2code.py -f $in -o $out
description = SWAGGER $out
rule protobuf
command = mkdir -p $out_dir && {protoc} --cpp_out=$out_dir --proto_path=$pb_dir $pb_base_name
command = mkdir -p $out_dir && {protoc} --cpp_out=$out_dir -I$pb_dir $pb
description = PROTOC $out
rule copy_file
command = cp $in $out
Expand Down Expand Up @@ -1059,16 +1059,16 @@ def have_hwloc():
f.write('build {}: swagger {} | scripts/seastar-json2code.py\n'.format(hh,src))
for pb_hdr in protobufs:
(pb, pb_src) = protobufs[pb_hdr]
out_dir = os.path.dirname(pb_src)
pb_hdr_dir = os.path.dirname(pb_hdr)
pb_dir = os.path.dirname(pb)
out_dir = '$builddir/' + mode + '/gen/' + pb_dir

f.write('build {} {}: protobuf {}\n pb_dir = {}\n pb_base_name = {}\n out_dir = {}\n'.format(
f.write('build {} {}: protobuf {}\n out_dir = {}\n pb_dir={}\n pb={}\n'.format(
pb_src,
pb_hdr,
pb,
os.path.dirname(pb),
os.path.basename(pb),
out_dir))
out_dir,
pb_dir,
pb))

f.write(textwrap.dedent('''\
rule configure
Expand Down

0 comments on commit b924495

Please sign in to comment.