29 lines
901 B
Python
Executable File
29 lines
901 B
Python
Executable File
#!/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()
|