Skip to content

Commit

Permalink
Add ability to build from in-repo repos file (#2)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll authored Apr 3, 2024
1 parent 687baa5 commit 552ee34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gazebo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[ros]
[gazebo]
distro = "ionic"
colcon_defaults = ".github/ci/colcon_defaults.yaml"
22 changes: 16 additions & 6 deletions helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@

def sync(args, rem_args):
from vcstool.commands.vcs import main as vcs_main
if not os.path.exists(f'{args.distro}_ws/src'):
os.makedirs(os.path.join(args.curdir, f'{args.distro}_ws/src'))
urllib.request.urlretrieve(
workspace_name = f'{args.distro}_ws'
if args.repos_file:
repos_file = args.repos_file
else:
repos_file = f'{workspace_name}/gazebodistro.repos'
urllib.request.urlretrieve(
f'https://raw.githubusercontent.com/gazebo-tooling/gazebodistro/master/collection-{args.distro}.yaml',
f'{args.distro}_ws/gazebodistro.repos')
repos_file)

argv = ['import', '--input', f'{args.distro}_ws/gazebodistro.repos', *rem_args, f'{args.distro}_ws/src']
if not os.path.exists(f'{workspace_name}/src'):
os.makedirs(os.path.join(args.curdir, f'{workspace_name}/src'))

argv = ['import', '--input', repos_file, *rem_args, f'{workspace_name}/src']
return vcs_main(argv)


Expand All @@ -59,14 +65,18 @@ def clean(args, rem_args):
# Read some configuration defaults from the toml file
with open('gazebo.toml', 'rb') as f:
data = tomllib.load(f)
defaults = data['ros']
defaults = data['gazebo']

if 'repos_file' not in defaults:
defaults['repos_file'] = None

parser = argparse.ArgumentParser(
prog='Pixi Task Helper',
description='Help with common pixi tasks')

parser.add_argument('--distro', type=str, default=defaults['distro'])
parser.add_argument('--colcon-defaults', type=str, default=defaults['colcon_defaults'])
parser.add_argument('--repos-file', type=str, default=defaults['repos_file'])

subparsers = parser.add_subparsers()
sync_parser = subparsers.add_parser('sync')
Expand Down

0 comments on commit 552ee34

Please sign in to comment.