Init commit.

This commit is contained in:
James Pace 2025-11-22 12:18:05 +00:00
commit 76ddbbed15
3 changed files with 57 additions and 0 deletions

13
CMakeLists.txt Normal file
View File

@ -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()

16
package.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>build_info_getter</name>
<version>0.0.1</version>
<description>TODO</description>
<license>MPL 2.0</license>
<author email="jpace121@gmail.com">James Pace</author>
<maintainer email="jpace121@gmail.com">James Pace</maintainer>
<buildtool_depend>ament_cmake</buildtool_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>

28
run.py Executable file
View File

@ -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 <path i want>/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()