From 76ddbbed153dbb1a0898127662d1f55c607b900c Mon Sep 17 00:00:00 2001 From: James Pace Date: Sat, 22 Nov 2025 12:18:05 +0000 Subject: [PATCH] Init commit. --- CMakeLists.txt | 13 +++++++++++++ package.xml | 16 ++++++++++++++++ run.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 package.xml create mode 100755 run.py diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1ae6100 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.20) +project(build_info_getter) + +find_package(ament_cmake REQUIRED) + +add_custom_target(build_info ALL) +add_custom_command(TARGET build_info + POST_BUILD + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run.py --install-path ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURE_DIR} +) + +ament_package() diff --git a/package.xml b/package.xml new file mode 100644 index 0000000..028992c --- /dev/null +++ b/package.xml @@ -0,0 +1,16 @@ + + + + build_info_getter + 0.0.1 + TODO + MPL 2.0 + James Pace + James Pace + + ament_cmake + + + ament_cmake + + diff --git a/run.py b/run.py new file mode 100755 index 0000000..1590975 --- /dev/null +++ b/run.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +import argparse +import os +from pathlib import Path +import subprocess + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--install-path", type=str) + parser.add_argument("--project-dir", type=str, default=None) + args = parser.parse_args() + + project_directory = args.project_dir + if not project_directory: + # Assume we're being called from colcon and need to figure this out ourselves. + # When run by colcon cwd is something like /build/package_name + cwd = Path(os.getcwd()) + project_directory = cwd.parent.parent + + # Where we're going to save the output. + output_file = args.install_path + "/project_state.repos" + + # Now call vcs. + vcs_command = "vcs export {} > {}".format(project_directory, output_file) + subprocess.run(vcs_command, shell=True) + +if __name__ == "__main__": + main()