Skip to content

Commit

Permalink
Better message when missing a required command line tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepurvis committed Apr 28, 2017
1 parent 319846a commit 7d687ab
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 41 deletions.
5 changes: 5 additions & 0 deletions catkin_tools/jobs/catkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from .utils import copyfiles
from .utils import loadenv
from .utils import makedirs
from .utils import require_command
from .utils import rmfiles


Expand Down Expand Up @@ -432,6 +433,8 @@ def create_catkin_build_job(context, package, package_path, dependencies, force_
prefix=context.package_dest_path(package)
))

require_command('cmake', CMAKE_EXEC)

# CMake command
stages.append(CommandStage(
'cmake',
Expand Down Expand Up @@ -473,6 +476,8 @@ def create_catkin_build_job(context, package, package_path, dependencies, force_
cwd=build_space,
))

require_command('make', MAKE_EXEC)

# Make command
stages.append(CommandStage(
'make',
Expand Down
4 changes: 4 additions & 0 deletions catkin_tools/jobs/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ def create_cmake_build_job(context, package, package_path, dependencies, force_c
dest_path=os.path.join(metadata_path, 'package.xml')
))

require_command('cmake', CMAKE_EXEC)

# CMake command
makefile_path = os.path.join(build_space, 'Makefile')
if not os.path.isfile(makefile_path) or force_cmake:
Expand Down Expand Up @@ -291,6 +293,8 @@ def create_cmake_build_job(context, package, package_path, dependencies, force_c
cwd=build_space,
))

require_command('make', MAKE_EXEC)

# Make command
stages.append(CommandStage(
'make',
Expand Down
14 changes: 14 additions & 0 deletions catkin_tools/jobs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@
from catkin_tools.execution.events import ExecutionEvent


class CommandMissing(Exception):
'''A required command is missing.'''

def __init__(self, name):
super(CommandMissing, self).__init__(
'Cannot find required tool `%s` on the PATH, is it installed?' % name)


def require_command(name, which):
if not which:
import errno
raise CommandMissing(name)


def get_env_loaders(package, context):
"""Get a list of env loaders required to build this package."""

Expand Down
87 changes: 46 additions & 41 deletions catkin_tools/verbs/catkin_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from catkin_tools.jobs.catkin import create_catkin_build_job
from catkin_tools.jobs.catkin import create_catkin_clean_job
from catkin_tools.jobs.catkin import get_prebuild_package
from catkin_tools.jobs.utils import CommandMissing

from .color import clr

Expand Down Expand Up @@ -461,49 +462,53 @@ def build_isolated_workspace(
if len(build_job_creators) == 0:
sys.exit('Error: No build types available. Please check your catkin_tools installation.')

# Construct jobs
for pkg_path, pkg in all_packages:
if pkg.name not in packages_to_be_built_names:
continue
try:
# Construct jobs
for pkg_path, pkg in all_packages:
if pkg.name not in packages_to_be_built_names:
continue

# Ignore metapackages
if 'metapackage' in [e.tagname for e in pkg.exports]:
continue

# Get actual execution deps
deps = [
p.name for _, p
in get_cached_recursive_build_depends_in_workspace(pkg, packages_to_be_built)
if p.name not in prebuild_jobs
]
# All jobs depend on the prebuild jobs if they're defined
if not no_deps:
for j in prebuild_jobs.values():
deps.append(j.jid)

# Determine the job parameters
build_job_kwargs = dict(
context=context,
package=pkg,
package_path=pkg_path,
dependencies=deps,
force_cmake=force_cmake,
pre_clean=pre_clean)

# Ignore metapackages
if 'metapackage' in [e.tagname for e in pkg.exports]:
continue
# Create the job based on the build type
build_type = get_build_type(pkg)

# Get actual execution deps
deps = [
p.name for _, p
in get_cached_recursive_build_depends_in_workspace(pkg, packages_to_be_built)
if p.name not in prebuild_jobs
]
# All jobs depend on the prebuild jobs if they're defined
if not no_deps:
for j in prebuild_jobs.values():
deps.append(j.jid)

# Determine the job parameters
build_job_kwargs = dict(
context=context,
package=pkg,
package_path=pkg_path,
dependencies=deps,
force_cmake=force_cmake,
pre_clean=pre_clean)

# Create the job based on the build type
build_type = get_build_type(pkg)

if build_type in build_job_creators:
jobs.append(build_job_creators[build_type](**build_job_kwargs))
else:
wide_log(clr(
"[build] @!@{yf}Warning:@| Skipping package `{}` because it "
"has an unsupported package build type: `{}`"
).format(pkg.name, build_type))

wide_log(clr("[build] Note: Available build types:"))
for bt_name in build_job_creators.keys():
wide_log(clr("[build] - `{}`".format(bt_name)))
if build_type in build_job_creators:
jobs.append(build_job_creators[build_type](**build_job_kwargs))
else:
wide_log(clr(
"[build] @!@{yf}Warning:@| Skipping package `{}` because it "
"has an unsupported package build type: `{}`"
).format(pkg.name, build_type))

wide_log(clr("[build] Note: Available build types:"))
for bt_name in build_job_creators.keys():
wide_log(clr("[build] - `{}`".format(bt_name)))

except CommandMissing as e:
sys.exit(clr("[build] @!@{rf}Error:@| {0}").format(e))

# Queue for communicating status
event_queue = Queue()
Expand Down

0 comments on commit 7d687ab

Please sign in to comment.