-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Describe the bug
Continuing from #7511
There may be a possible regression with 0.57 where @CURRENT_SOURCE_DIR@
has been removed from custom_target
. I realize that's not in the manual, but removing CURRENT_SOURCE_DIR
broke my build and I can't figure out a working replacement.
0.56.2
generates this build.ninja
...
build proto/settings.pb.cc: CUSTOM_COMMAND ../proto/settings.proto | /usr/bin/protoc
COMMAND = /usr/bin/protoc --proto_path=../proto --cpp_out=proto ../proto/settings.proto
description = Generating$ settings_pb_cc$ with$ a$ custom$ command
build proto/settings.pb.h: CUSTOM_COMMAND ../proto/settings.proto | /usr/bin/protoc
COMMAND = /usr/bin/protoc --proto_path=../proto --cpp_out=proto ../proto/settings.proto
description = Generating$ settings_pb_h$ with$ a$ custom$ command
...
0.57
generates:
build proto/settings.pb.cc: CUSTOM_COMMAND ../proto/settings.proto | /usr/bin/protoc
COMMAND = /usr/bin/protoc --proto_path=@CURRENT_SOURCE_DIR@ --cpp_out=proto ../proto/settings.proto
description = Generating$ settings_pb_cc$ with$ a$ custom$ command
build proto/settings.pb.h: CUSTOM_COMMAND ../proto/settings.proto | /usr/bin/protoc
COMMAND = /usr/bin/protoc --proto_path=@CURRENT_SOURCE_DIR@ --cpp_out=proto ../proto/settings.proto
description = Generating$ settings_pb_h$ with$ a$ custom$ command
To Reproduce
meson.build
protobuf = dependency('protobuf', version: '>=3.0.0')
protoc = find_program('protoc')
# many thanks to @marcelhollerbach for his solution.
# https://github.com/mesonbuild/meson/issues/7511#issuecomment-665470520
settings_pb_cc = custom_target('settings_pb_cc',
input: ['settings.proto'],
output: ['@BASENAME@.pb.cc'],
command: [
protoc,
'--proto_path=@CURRENT_SOURCE_DIR@',
'--cpp_out=@OUTDIR@',
'@INPUT@',
]
)
settings_pb_h = custom_target('settings_pb_h',
input: ['settings.proto'],
output: ['@BASENAME@.pb.h'],
command: [
protoc,
'--proto_path=@CURRENT_SOURCE_DIR@',
'--cpp_out=@OUTDIR@',
'@INPUT@',
],
install: true,
install_dir: get_option('includedir') / meson.project_name(),
)
settings_incdir = include_directories('.')
libazabacheproto = library(meson.project_name() + 'proto', settings_pb_cc,
version: meson.project_version(),
dependencies: protobuf,
# FIXME(mdegans): remove this when moving to a 20.04 rootfs with new protobuf
# becuase of this bug: https://github.com/protocolbuffers/protobuf/issues/4628
cpp_args: ['-Wno-unused-parameter'],
install: true,
)
azabacheproto_dep = declare_dependency(
link_with: libazabacheproto,
include_directories: include_directories('.'),
dependencies: protobuf,
)
# generate a separate .pc for just the protobuf code.
pkg = import('pkgconfig')
azabacheproto_pc = pkg.generate(libazabacheproto,
description: 'Azabache Camera Metadata Library',
url: project_url,
# for consistency with existing cmake install:
install_dir: get_option('datadir') / 'pkgconfig',
subdirs: meson.project_name(),
)
Any setttings.proto
should do.
As a workaround, i tried '--proto_path=' + meson.current_source_dir(),
but this doesn't seem to do the same thing. protoc
does not like absolute paths, apparently:
[1/56] Generating settings_pb_cc with a custom command
FAILED: proto/settings.pb.cc
/usr/bin/protoc --proto_path=/home/user/Projects/lib-azabache/proto --cpp_out=proto ../proto/settings.proto
../proto/settings.proto: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).
[2/56] Generating settings_pb_h with a custom command
FAILED: proto/settings.pb.h
/usr/bin/protoc --proto_path=/home/user/Projects/lib-azabache/proto --cpp_out=proto ../proto/settings.proto
../proto/settings.proto: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).
[3/56] Compiling C++ object src/libazabache-0.1.so.p/encoder.cpp.o
FAILED: src/libazabache-0.1.so.p/encoder.cpp.o
Expected behavior
@CURRENT_SOURCE_DIR
in custom_target to be replaced with the crurrent source dir, or for there to be a usable replacement. Per the referenced issue, generator
was unsuitable for this task. I'm using custom target, actually two of them, since I couldn't figure out a cleaner way.
system parameters
- plain, native build
- Ubuntu 18.04 aarch64 (Tegra)
- Python 3.6.9
- meson 0.57
- ninja 1.8.1