Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions colcon_cmake/task/cmake/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,21 @@ def _get_make_arguments(self, env):
:returns: list of make arguments
:rtype: list of strings
"""
# check MAKEFLAGS for -j/--jobs/-l/--load-average arguments
makeflags = env.get('MAKEFLAGS', '')
# check {GNU,}MAKEFLAGS for -j/--jobs/-l/--load-average arguments
regex = (
r'(?:^|\s)'
r'(-?(?:j|l)(?:\s*[0-9]+|\s|$))'
r'|'
r'(?:^|\s)'
r'((?:--)?(?:jobs|load-average)(?:(?:=|\s+)[0-9]+|(?:\s|$)))'
)
matches = re.findall(regex, makeflags) or []
matches = [m[0] or m[1] for m in matches]
if matches:
# do not extend make arguments, let MAKEFLAGS set things
return []
for var_name in ('MAKEFLAGS', 'GNUMAKEFLAGS'):
flags = env.get(var_name) or ''
matches = re.findall(regex, flags) or []
matches = [m[0] or m[1] for m in matches]
if matches:
# do not extend make arguments, let the env var set things
return []

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if I understand correctly, the environment make variables take precedent always? I guess this was already behavior that existed, but perhaps maybe not what I might expect. On the other hand, it should perhaps be the responsible thing of the user to have a clean dev environment for this.

Anyway, just a design question mostly!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort of. We want to change the "default" behavior of colcon's invocations of make. Passing command line arguments to make will take precedence over MAKEFLAGS env var, but make will implicitly consume MAKEFLAGS by default.

We're really just using this information to decide whether or not to pass those command line arguments.

# Use the number of CPU cores
jobs = os.cpu_count()
with suppress(AttributeError):
Expand Down
1 change: 1 addition & 0 deletions test/spell_check.words
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ etree
findtext
getaffinity
github
gnumakeflags
https
importorskip
iterdir
Expand Down
Loading