Skip to content

Commit

Permalink
build: making it so ephemeral list-type arguments are appended to exi…
Browse files Browse the repository at this point in the history
…sting list-type arguments

- affects behavior of --cmake-args, --make-args, and --catkin-make-args
- fixes broken --no-catkin-make-args (fixes #136)
  • Loading branch information
jbohren committed Mar 16, 2015
1 parent 7c10312 commit af7260c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
8 changes: 4 additions & 4 deletions catkin_tools/argument_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def add_cmake_and_make_and_catkin_make_args(parser):
add('--cmake-args', metavar='ARG', dest='cmake_args', nargs='+', required=False, type=str, default=None,
help='Arbitrary arguments which are passes to CMake. '
'It collects all of following arguments until a "--" is read.')
add('--no-cmake-args', dest='cmake_args', action='store_const', const='A', default=None,
add('--no-cmake-args', dest='cmake_args', action='store_const', const=[], default=None,
help='Pass no additional arguments to CMake.')

add = parser.add_mutually_exclusive_group().add_argument
Expand Down Expand Up @@ -134,11 +134,11 @@ def split_arguments(args, splitter_name):
args = [a for a in args if a not in implicit_cmake_args]
cmake_args = implicit_cmake_args + cmake_args

if '--no-cmake-args' not in args and len(cmake_args) == 0:
if ('--no-cmake-args' not in args) and len(cmake_args) == 0:
cmake_args = None
if '--no-make-args' not in args and len(make_args) == 0:
if ('--no-make-args' not in args) and len(make_args) == 0:
make_args = None
if extract_catkin_make and '--no-catkin_make_args' not in args and len(catkin_make_args) == 0:
if extract_catkin_make and ('--no-catkin-make-args' not in args) and len(catkin_make_args) == 0:
catkin_make_args = None

return args, cmake_args, make_args, catkin_make_args
Expand Down
13 changes: 9 additions & 4 deletions catkin_tools/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Context(object):
'space_suffix']

@classmethod
def Load(cls, workspace_hint=None, profile=None, opts=None, strict=False):
def Load(cls, workspace_hint=None, profile=None, opts=None, strict=False, append=False):
"""Load a context from a given workspace and profile with optional modifications.
This function will try to load a given context from the specified
Expand All @@ -93,6 +93,8 @@ def Load(cls, workspace_hint=None, profile=None, opts=None, strict=False):
:type opts: namespace
:param strict: Causes this function to return None if a workspace isn't found
:type strict: bool
:param append: Appends any list-type opts to existing opts
:type append: bool
:returns: A potentially valid Context object constructed from the given arguments
:rtype: Context
Expand Down Expand Up @@ -126,9 +128,12 @@ def Load(cls, workspace_hint=None, profile=None, opts=None, strict=False):

# User-supplied args are used to update stored args
# Only update context args with given opts which are not none
context_args.update(dict([
(k, v) for (k, v) in opts_vars.items()
if k in Context.KEYS and v is not None]))
for (k, v) in opts_vars.items():
if k in Context.KEYS and v is not None:
if append and type(context_args.get(k, None)) is list and type(v) is list:
context_args[k] += v
else:
context_args[k] = v

# Create the build context
return Context(**context_args)
Expand Down
2 changes: 1 addition & 1 deletion catkin_tools/verbs/catkin_build/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def main(opts):
set_color(False)

# Load the context
ctx = Context.Load(opts.workspace, opts.profile, opts)
ctx = Context.Load(opts.workspace, opts.profile, opts, append=True)

# Load the environment of the workspace to extend
if ctx.extend_path is not None:
Expand Down
2 changes: 1 addition & 1 deletion catkin_tools/verbs/catkin_create/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def main(opts):

try:
package_dest_path = opts.path
print('path: '+str(opts.path))
print('path: ' + str(opts.path))
for package_name in opts.name:
print('Creating package "%s" in "%s"...' % (package_name, package_dest_path))
target_path = os.path.join(package_dest_path, package_name)
Expand Down
2 changes: 1 addition & 1 deletion catkin_tools/verbs/catkin_list/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ def main(opts):
except InvalidPackage as ex:
message = '\n'.join(ex.args)
print(clr("@{rf}Error:@| The directory %s contains an invalid package."
" See below for details:\n\n%s" % (folder, message)))
" See below for details:\n\n%s" % (folder, message)))

0 comments on commit af7260c

Please sign in to comment.