diff --git a/bloom/generators/debian/generate_cmd.py b/bloom/generators/debian/generate_cmd.py index 5dc9f8b9..7ca1d139 100644 --- a/bloom/generators/debian/generate_cmd.py +++ b/bloom/generators/debian/generate_cmd.py @@ -79,17 +79,19 @@ def prepare_arguments(parser): add('--native', action='store_true', help="generate native package") add('--ignore-shlibs-missing-info', default=False, action="store_true", help="Ignore missing library info detected by shlibs") + add('--src-dir', help='Location of source directory in package') return parser -def get_subs(pkg, os_name, os_version, ros_distro, deb_inc=0, native=False): +def get_subs(pkg, os_name, os_version, ros_distro, deb_inc=0, native=False, source_directory=None): return generate_substitutions_from_package( pkg, os_name, os_version, ros_distro, deb_inc=deb_inc, - native=native + native=native, + source_directory=source_directory ) @@ -127,7 +129,7 @@ def main(args=None, get_subs_fn=None): for path, pkg in pkgs_dict.items(): template_files = None try: - subs = get_subs_fn(pkg, os_name, os_version, ros_distro, args.debian_inc, args.native) + subs = get_subs_fn(pkg, os_name, os_version, ros_distro, args.debian_inc, args.native, args.src_dir) if _place_template_files: # Place template files place_template_files(path, pkg.get_build_type()) diff --git a/bloom/generators/debian/generator.py b/bloom/generators/debian/generator.py index e78c08b8..22e00d82 100644 --- a/bloom/generators/debian/generator.py +++ b/bloom/generators/debian/generator.py @@ -316,7 +316,8 @@ def generate_substitutions_from_package( peer_packages=None, releaser_history=None, fallback_resolver=None, - native=False + native=False, + source_directory=None ): peer_packages = peer_packages or [] data = {} @@ -344,6 +345,8 @@ def generate_substitutions_from_package( data['Package'] = sanitize_package_name(package.name) # Installation prefix data['InstallationPrefix'] = installation_prefix + # Source directory + data['SourceDirectory'] = source_directory # Resolve dependencies evaluate_package_conditions(package, ros_distro) depends = [ diff --git a/bloom/generators/debian/templates/cmake/rules.em b/bloom/generators/debian/templates/cmake/rules.em index 284a0714..6573ecc4 100755 --- a/bloom/generators/debian/templates/cmake/rules.em +++ b/bloom/generators/debian/templates/cmake/rules.em @@ -26,8 +26,13 @@ export DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +@{ +dh_arguments = '' +if SourceDirectory: + dh_arguments += f" -D{SourceDirectory}" +}@ %: - dh $@@ -v --buildsystem=cmake --builddirectory=.obj-$(DEB_HOST_GNU_TYPE) + dh $@@ -v --buildsystem=cmake --builddirectory=.obj-$(DEB_HOST_GNU_TYPE)@(dh_arguments) override_dh_auto_configure: # In case we're installing to a non-standard location, look for a setup.sh