def get_commands(self): commands = [] # Setup build variables pkg_dir = os.path.join(self.context.source_space_abs, self.package_path) build_space = create_build_space(self.context.build_space_abs, self.package.name) if self.context.isolate_devel: devel_space = os.path.join(self.context.devel_space_abs, self.package.name) else: devel_space = self.context.devel_space_abs if self.context.isolate_install: install_space = os.path.join(self.context.install_space_abs, self.package.name) else: install_space = self.context.install_space_abs # Create an environment file env_cmd = create_env_file(self.package, self.context) # CMake command makefile_path = os.path.join(build_space, 'Makefile') if not os.path.isfile(makefile_path) or self.force_cmake: commands.append( CMakeCommand(env_cmd, [ CMAKE_EXEC, pkg_dir, '-DCATKIN_DEVEL_PREFIX=' + devel_space, '-DCMAKE_INSTALL_PREFIX=' + install_space ] + self.context.cmake_args, build_space)) else: commands.append( MakeCommand(env_cmd, [MAKE_EXEC, 'cmake_check_build_system'], build_space)) # Make command commands.append( MakeCommand(env_cmd, [MAKE_EXEC] + handle_make_arguments(self.context.make_args + self.context.catkin_make_args), build_space)) # Make install command, if installing if self.context.install: commands.append( InstallCommand(env_cmd, [MAKE_EXEC, 'install'], build_space)) return commands
def get_commands(self): commands = [] # Setup build variables pkg_dir = os.path.join(self.context.source_space_abs, self.package_path) build_space = create_build_space(self.context.build_space_abs, self.package.name) if self.context.isolate_devel: devel_space = os.path.join(self.context.devel_space_abs, self.package.name) else: devel_space = self.context.devel_space_abs if self.context.isolate_install: install_space = os.path.join(self.context.install_space_abs, self.package.name) else: install_space = self.context.install_space_abs # Create an environment file env_cmd = create_env_file(self.package, self.context) # CMake command makefile_path = os.path.join(build_space, 'Makefile') if not os.path.isfile(makefile_path) or self.force_cmake: commands.append(CMakeCommand( env_cmd, [ CMAKE_EXEC, pkg_dir, '-DCATKIN_DEVEL_PREFIX=' + devel_space, '-DCMAKE_INSTALL_PREFIX=' + install_space ] + self.context.cmake_args, build_space )) else: commands.append(MakeCommand(env_cmd, [MAKE_EXEC, 'cmake_check_build_system'], build_space)) # Make command commands.append(MakeCommand( env_cmd, [MAKE_EXEC] + handle_make_arguments(self.context.make_args + self.context.catkin_make_args), build_space )) # Make install command, if installing if self.context.install: commands.append(InstallCommand(env_cmd, [MAKE_EXEC, 'install'], build_space)) return commands
def create_package_job(context, package, package_tests): build_space = os.path.join(context.build_space_abs, package.name) if not os.path.exists(os.path.join(build_space, 'Makefile')): raise build_space = context.package_build_space(package) devel_space = context.package_devel_space(package) catkin_test_results_dir = os.path.join(build_space, 'test_results') #package_path_abs = os.path.join(context.source_space_abs, package_path) job_env = dict(os.environ) stages = [] stages.append( FunctionStage('loadenv', loadenv, job_env=job_env, package=package, context=context)) package_test_targets = [ 'run_tests_%s_%s' % (package.name, test_name) for test_name in package_tests ] make_args = handle_make_arguments(context.make_args + context.catkin_make_args + package_test_targets) stages.append( CommandStage( 'make', [MAKE_EXEC] + make_args, cwd=build_space, #env_overrides=env_overrides, logger_factory=CMakeMakeIOBufferProtocol.factory)) return Job(jid=package.name, deps=[], env=job_env, stages=stages)
def create_catkin_build_job(context, package, package_path, dependencies, force_cmake, pre_clean, prebuild=False): """Job class for building catkin packages""" # Package source space path pkg_dir = os.path.join(context.source_space_abs, package_path) # Package build space path build_space = context.package_build_space(package) # Package devel space path devel_space = context.package_devel_space(package) # Package install space path install_space = context.package_install_space(package) # Package metadata path metadata_path = context.package_metadata_path(package) # Create job stages stages = [] # Create package build space stages.append(FunctionStage('mkdir', makedirs, path=build_space)) # Create package metadata dir stages.append(FunctionStage('mkdir', makedirs, path=metadata_path)) # Copy source manifest stages.append( FunctionStage('cache-manifest', copyfiles, source_paths=[ os.path.join(context.source_space_abs, package_path, 'package.xml') ], dest_path=os.path.join(metadata_path, 'package.xml'))) # Define test results directory catkin_test_results_dir = os.path.join(build_space, 'test_results') # Always override the CATKIN and ROS _TEST_RESULTS_DIR environment variables. # This is in order to avoid cross talk due to parallel builds. # This is only needed for ROS Hydro and earlier (the problem was addressed upstream in Indigo). # See: https://github.com/catkin/catkin_tools/issues/139 ctr_env = { 'CATKIN_TEST_RESULTS_DIR': catkin_test_results_dir, 'ROS_TEST_RESULTS_DIR': catkin_test_results_dir } # Only run CMake if the Makefile doesn't exist or if --force-cmake is given # TODO: This would need to be different with `cmake --build` makefile_path = os.path.join(build_space, 'Makefile') if not os.path.isfile(makefile_path) or force_cmake: # Create an env-hook which clears the catkin and ros test results environment variable. stages.append( FunctionStage('ctr-nuke', ctr_nuke, prefix=context.package_dest_path(package))) # CMake command stages.append( CommandStage( 'cmake', [ CMAKE_EXEC, pkg_dir, '--no-warn-unused-cli', '-DCATKIN_DEVEL_PREFIX=' + devel_space, '-DCMAKE_INSTALL_PREFIX=' + install_space ] + context.cmake_args, cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir), occupy_job=True)) else: # Check buildsystem command stages.append( CommandStage( 'check', [MAKE_EXEC, 'cmake_check_build_system'], cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir), occupy_job=True)) # Filter make arguments make_args = handle_make_arguments(context.make_args + context.catkin_make_args) # Determine if the catkin test results env needs to be overridden env_overrides = ctr_env if 'test' in make_args else {} # Pre-clean command if pre_clean: # TODO: Remove target args from `make_args` stages.append( CommandStage( 'preclean', [MAKE_EXEC, 'clean'] + make_args, cwd=build_space, )) # Make command stages.append( CommandStage('make', [MAKE_EXEC] + make_args, cwd=build_space, env_overrides=env_overrides, logger_factory=CMakeMakeIOBufferProtocol.factory)) # Symlink command if using a linked develspace if context.link_devel: stages.append( FunctionStage( 'symlink', link_devel_products, locked_resource='symlink-collisions-file', package=package, package_path=package_path, devel_manifest_path=context.package_metadata_path(package), source_devel_path=context.package_devel_space(package), dest_devel_path=context.devel_space_abs, metadata_path=context.metadata_path(), prebuild=prebuild)) # Make install command, if installing if context.install: stages.append( CommandStage('install', [MAKE_EXEC, 'install'], cwd=build_space, logger_factory=CMakeMakeIOBufferProtocol.factory, locked_resource='installspace')) return Job(jid=package.name, deps=dependencies, env_loader=get_env_loader(package, context), stages=stages)
def create_catkin_build_job(context, package, package_path, dependencies, force_cmake, pre_clean, prebuild=False): """Job class for building catkin packages""" # Package source space path pkg_dir = os.path.join(context.source_space_abs, package_path) # Package build space path build_space = context.package_build_space(package) # Package devel space path devel_space = context.package_devel_space(package) # Package install space path install_space = context.package_install_space(package) # Package metadata path metadata_path = context.package_metadata_path(package) # Environment dictionary for the job, which will be built # up by the executions in the loadenv stage. job_env = dict(os.environ) # Create job stages stages = [] # Load environment for job. stages.append( FunctionStage('loadenv', loadenv, locked_resource=None if context.isolate_install else 'installspace', job_env=job_env, package=package, context=context)) # Create package build space stages.append(FunctionStage('mkdir', makedirs, path=build_space)) # Create package metadata dir stages.append(FunctionStage('mkdir', makedirs, path=metadata_path)) # Copy source manifest stages.append( FunctionStage('cache-manifest', copyfiles, source_paths=[ os.path.join(context.source_space_abs, package_path, 'package.xml') ], dest_path=os.path.join(metadata_path, 'package.xml'))) # Only run CMake if the Makefile doesn't exist or if --force-cmake is given # TODO: This would need to be different with `cmake --build` makefile_path = os.path.join(build_space, 'Makefile') if not os.path.isfile(makefile_path) or force_cmake: require_command('cmake', CMAKE_EXEC) # CMake command stages.append( CommandStage( 'cmake', [ CMAKE_EXEC, pkg_dir, '--no-warn-unused-cli', '-DCATKIN_DEVEL_PREFIX=' + devel_space, '-DCMAKE_INSTALL_PREFIX=' + install_space ] + context.cmake_args, cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir), occupy_job=True)) else: # Check buildsystem command stages.append( CommandStage( 'check', [MAKE_EXEC, 'cmake_check_build_system'], cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir), occupy_job=True)) # Filter make arguments make_args = handle_make_arguments(context.make_args + context.catkin_make_args) # Pre-clean command if pre_clean: # TODO: Remove target args from `make_args` stages.append( CommandStage( 'preclean', [MAKE_EXEC, 'clean'] + make_args, cwd=build_space, )) require_command('make', MAKE_EXEC) # Make command stages.append( CommandStage('make', [MAKE_EXEC] + make_args, cwd=build_space, logger_factory=CMakeMakeIOBufferProtocol.factory)) # Symlink command if using a linked develspace if context.link_devel: stages.append( FunctionStage( 'symlink', link_devel_products, locked_resource='symlink-collisions-file', package=package, package_path=package_path, devel_manifest_path=context.package_metadata_path(package), source_devel_path=context.package_devel_space(package), dest_devel_path=context.devel_space_abs, metadata_path=context.metadata_path(), prebuild=prebuild)) # Make install command, if installing if context.install: stages.append( CommandStage('install', [MAKE_EXEC, 'install'], cwd=build_space, logger_factory=CMakeMakeIOBufferProtocol.factory, locked_resource=None if context.isolate_install else 'installspace')) # Copy install manifest stages.append( FunctionStage( 'register', copy_install_manifest, src_install_manifest_path=build_space, dst_install_manifest_path=context.package_metadata_path( package))) return Job(jid=package.name, deps=dependencies, env=job_env, stages=stages)
def create_catkin_build_job(context, package, package_path, dependencies, force_cmake, pre_clean, prebuild=False): """Job class for building catkin packages""" # Package source space path pkg_dir = os.path.join(context.source_space_abs, package_path) # Package build space path build_space = context.package_build_space(package) # Package devel space path devel_space = context.package_devel_space(package) # Package install space path install_space = context.package_install_space(package) # Package metadata path metadata_path = context.package_metadata_path(package) # Create job stages stages = [] # Create package build space stages.append(FunctionStage( 'mkdir', makedirs, path=build_space )) # Create package metadata dir stages.append(FunctionStage( 'mkdir', makedirs, path=metadata_path )) # Copy source manifest stages.append(FunctionStage( 'cache-manifest', copyfiles, source_paths=[os.path.join(context.source_space_abs, package_path, 'package.xml')], dest_path=os.path.join(metadata_path, 'package.xml') )) # Define test results directory catkin_test_results_dir = os.path.join(build_space, 'test_results') # Always override the CATKIN and ROS _TEST_RESULTS_DIR environment variables. # This is in order to avoid cross talk due to parallel builds. # This is only needed for ROS Hydro and earlier (the problem was addressed upstream in Indigo). # See: https://github.com/catkin/catkin_tools/issues/139 ctr_env = { 'CATKIN_TEST_RESULTS_DIR': catkin_test_results_dir, 'ROS_TEST_RESULTS_DIR': catkin_test_results_dir } # Only run CMake if the Makefile doesn't exist or if --force-cmake is given # TODO: This would need to be different with `cmake --build` makefile_path = os.path.join(build_space, 'Makefile') if not os.path.isfile(makefile_path) or force_cmake: # Create an env-hook which clears the catkin and ros test results environment variable. stages.append(FunctionStage( 'ctr-nuke', ctr_nuke, prefix=context.package_dest_path(package) )) # CMake command stages.append(CommandStage( 'cmake', [ CMAKE_EXEC, pkg_dir, '--no-warn-unused-cli', '-DCATKIN_DEVEL_PREFIX=' + devel_space, '-DCMAKE_INSTALL_PREFIX=' + install_space ] + context.cmake_args, cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir), occupy_job=True )) else: # Check buildsystem command stages.append(CommandStage( 'check', [MAKE_EXEC, 'cmake_check_build_system'], cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir), occupy_job=True )) # Filter make arguments make_args = handle_make_arguments( context.make_args + context.catkin_make_args) # Determine if the catkin test results env needs to be overridden env_overrides = ctr_env if 'test' in make_args else {} # Pre-clean command if pre_clean: # TODO: Remove target args from `make_args` stages.append(CommandStage( 'preclean', [MAKE_EXEC, 'clean'] + make_args, cwd=build_space, )) # Make command stages.append(CommandStage( 'make', [MAKE_EXEC] + make_args, cwd=build_space, env_overrides=env_overrides, logger_factory=CMakeMakeIOBufferProtocol.factory )) # Symlink command if using a linked develspace if context.link_devel: stages.append(FunctionStage( 'symlink', link_devel_products, locked_resource='symlink-collisions-file', package=package, package_path=package_path, devel_manifest_path=context.package_metadata_path(package), source_devel_path=context.package_devel_space(package), dest_devel_path=context.devel_space_abs, metadata_path=context.metadata_path(), prebuild=prebuild )) # Make install command, if installing if context.install: stages.append(CommandStage( 'install', [MAKE_EXEC, 'install'], cwd=build_space, logger_factory=CMakeMakeIOBufferProtocol.factory, locked_resource='installspace' )) return Job( jid=package.name, deps=dependencies, env_loader=get_env_loader(package, context), stages=stages)
def create_cmake_build_job(context, package, package_path, dependencies, force_cmake, pre_clean): # Package source space path pkg_dir = os.path.join(context.source_space_abs, package_path) # Package build space path build_space = context.package_build_space(package) # Package metadata path metadata_path = context.package_metadata_path(package) # Environment dictionary for the job, which will be built # up by the executions in the loadenv stage. job_env = dict(os.environ) # Get actual staging path dest_path = context.package_dest_path(package) final_path = context.package_final_path(package) # Create job stages stages = [] # Load environment for job. stages.append( FunctionStage('loadenv', loadenv, locked_resource='installspace', job_env=job_env, package=package, context=context)) # Create package build space stages.append(FunctionStage('mkdir', makedirs, path=build_space)) # Create package metadata dir stages.append(FunctionStage('mkdir', makedirs, path=metadata_path)) # Copy source manifest stages.append( FunctionStage('cache-manifest', copyfiles, source_paths=[ os.path.join(context.source_space_abs, package_path, 'package.xml') ], 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: stages.append( CommandStage( 'cmake', ([ CMAKE_EXEC, pkg_dir, '--no-warn-unused-cli', '-DCMAKE_INSTALL_PREFIX=' + final_path ] + context.cmake_args), cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir))) else: stages.append( CommandStage( 'check', [MAKE_EXEC, 'cmake_check_build_system'], cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir))) # Pre-clean command if pre_clean: make_args = handle_make_arguments(context.make_args + context.catkin_make_args) stages.append( CommandStage( 'preclean', [MAKE_EXEC, 'clean'] + make_args, cwd=build_space, )) require_command('make', MAKE_EXEC) # Make command stages.append( CommandStage('make', [MAKE_EXEC] + handle_make_arguments(context.make_args), cwd=build_space, logger_factory=CMakeMakeIOBufferProtocol.factory)) # Make install command (always run on plain cmake) stages.append( CommandStage('install', [MAKE_EXEC, 'install'], cwd=build_space, logger_factory=CMakeMakeIOBufferProtocol.factory, locked_resource='installspace')) # Copy install manifest stages.append( FunctionStage( 'register', copy_install_manifest, src_install_manifest_path=build_space, dst_install_manifest_path=context.package_metadata_path(package))) # Determine the location where the setup.sh file should be created stages.append( FunctionStage('setupgen', generate_setup_file, context=context, install_target=dest_path)) stages.append( FunctionStage('envgen', generate_env_file, context=context, install_target=dest_path)) return Job(jid=package.name, deps=dependencies, env=job_env, stages=stages)
def create_catkin_build_job(context, package, package_path, dependencies, force_cmake, pre_clean): """Job class for building catkin packages""" # Package source space path pkg_dir = os.path.join(context.source_space_abs, package_path) # Package build space path build_space = context.package_build_space(package) # Package devel space path devel_space = context.package_devel_space(package) # Package install space path install_space = context.package_install_space(package) # Create job stages stages = [] # Create package build space stages.append(FunctionStage( 'mkdir', makedirs, path=build_space)) # Define test results directory catkin_test_results_dir = os.path.join(build_space, 'test_results') # Always override the CATKIN and ROS _TEST_RESULTS_DIR environment variables. # This is in order to avoid cross talk due to parallel builds. # This is only needed for ROS Hydro and earlier (the problem was addressed upstream in Indigo). # See: https://github.com/catkin/catkin_tools/issues/139 ctr_env = { 'CATKIN_TEST_RESULTS_DIR': catkin_test_results_dir, 'ROS_TEST_RESULTS_DIR': catkin_test_results_dir } # Construct CMake command makefile_path = os.path.join(build_space, 'Makefile') if not os.path.isfile(makefile_path) or force_cmake: # Create a shell script which clears the catkin and ros test results environment variable. stages.append(FunctionStage( 'ctr-nuke', ctr_nuke, prefix=(devel_space if not context.install else install_space))) stages.append(CommandStage( 'cmake', ([CMAKE_EXEC, pkg_dir, '--no-warn-unused-cli', '-DCATKIN_DEVEL_PREFIX=' + devel_space, '-DCMAKE_INSTALL_PREFIX=' + install_space] + context.cmake_args), cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir), occupy_job=True) ) else: stages.append(CommandStage( 'check', [MAKE_EXEC, 'cmake_check_build_system'], cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir), occupy_job=True )) # Pre-clean command if pre_clean: make_args = handle_make_arguments( context.make_args + context.catkin_make_args) stages.append(CommandStage( 'preclean', [MAKE_EXEC, 'clean'] + make_args, cwd=build_space, )) # Make command make_args = handle_make_arguments( context.make_args + context.catkin_make_args) stages.append(CommandStage( 'make', [MAKE_EXEC] + make_args, cwd=build_space, env_overrides=ctr_env if 'test' in make_args else {}, logger_factory=CMakeMakeIOBufferProtocol.factory )) # Make install command, if installing if context.install: stages.append(CommandStage( 'install', [MAKE_EXEC, 'install'], cwd=build_space, logger_factory=CMakeMakeIOBufferProtocol.factory, locked_resource='installspace' )) return Job( jid=package.name, deps=dependencies, env_loader=get_env_loader(package, context), stages=stages)
def create_cmake_build_job(context, package, package_path, dependencies, force_cmake, pre_clean): # Package source space path pkg_dir = os.path.join(context.source_space_abs, package_path) # Package build space path build_space = context.package_build_space(package) # Package metadata path metadata_path = context.package_metadata_path(package) # Get actual staging path dest_path = context.package_dest_path(package) final_path = context.package_final_path(package) # Create job stages stages = [] # Create package build space stages.append(FunctionStage( 'mkdir', makedirs, path=build_space )) # Create package metadata dir stages.append(FunctionStage( 'mkdir', makedirs, path=metadata_path )) # Copy source manifest stages.append(FunctionStage( 'cache-manifest', copyfiles, source_paths=[os.path.join(context.source_space_abs, package_path, 'package.xml')], dest_path=os.path.join(metadata_path, 'package.xml') )) # CMake command makefile_path = os.path.join(build_space, 'Makefile') if not os.path.isfile(makefile_path) or force_cmake: stages.append(CommandStage( 'cmake', ([CMAKE_EXEC, pkg_dir, '--no-warn-unused-cli', '-DCMAKE_INSTALL_PREFIX=' + final_path] + context.cmake_args), cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir) )) else: stages.append(CommandStage( 'check', [MAKE_EXEC, 'cmake_check_build_system'], cwd=build_space, logger_factory=CMakeIOBufferProtocol.factory_factory(pkg_dir) )) # Pre-clean command if pre_clean: make_args = handle_make_arguments( context.make_args + context.catkin_make_args) stages.append(CommandStage( 'preclean', [MAKE_EXEC, 'clean'] + make_args, cwd=build_space, )) # Make command stages.append(CommandStage( 'make', [MAKE_EXEC] + handle_make_arguments(context.make_args), cwd=build_space, logger_factory=CMakeMakeIOBufferProtocol.factory )) # Make install command (always run on plain cmake) stages.append(CommandStage( 'install', [MAKE_EXEC, 'install'], cwd=build_space, logger_factory=CMakeMakeIOBufferProtocol.factory, locked_resource='installspace' )) # Copy install manifest stages.append(FunctionStage( 'register', copy_install_manifest, src_install_manifest_path=build_space, dst_install_manifest_path=context.package_metadata_path(package) )) # Determine the location where the setup.sh file should be created stages.append(FunctionStage( 'setupgen', generate_setup_file, context=context, install_target=dest_path )) stages.append(FunctionStage( 'envgen', generate_env_file, context=context, install_target=dest_path )) return Job( jid=package.name, deps=dependencies, env_loader=get_env_loader(package, context), stages=stages)
def get_commands(self): commands = [] # Setup build variables pkg_dir = os.path.join(self.context.source_space_abs, self.package_path) build_space = create_build_space(self.context.build_space_abs, self.package.name) if self.context.isolate_devel: devel_space = os.path.join(self.context.devel_space_abs, self.package.name) else: devel_space = self.context.devel_space_abs if self.context.isolate_install: install_space = os.path.join(self.context.install_space_abs, self.package.name) else: install_space = self.context.install_space_abs install_target = install_space if self.context.install else devel_space # Create an environment file env_cmd = create_env_file(self.package, self.context) # CMake command makefile_path = os.path.join(build_space, 'Makefile') if not os.path.isfile(makefile_path) or self.force_cmake: commands.append(CMakeCommand( env_cmd, [ CMAKE_EXEC, pkg_dir, '-DCMAKE_INSTALL_PREFIX=' + install_target ] + self.context.cmake_args, build_space )) commands[-1].cmd.extend(self.context.cmake_args) else: commands.append(MakeCommand(env_cmd, [MAKE_EXEC, 'cmake_check_build_system'], build_space)) # Make command commands.append(MakeCommand( env_cmd, [MAKE_EXEC] + handle_make_arguments(self.context.make_args), build_space )) # Make install command (always run on plain cmake) commands.append(InstallCommand(env_cmd, [MAKE_EXEC, 'install'], build_space)) # Determine the location of where the setup.sh file should be created if self.context.install: setup_file_path = os.path.join(install_space, 'setup.sh') if not self.context.isolate_install and os.path.exists(setup_file_path): return commands else: # Create it in the devel space setup_file_path = os.path.join(devel_space, 'setup.sh') if not self.context.isolate_devel and os.path.exists(setup_file_path): # Do not replace existing setup.sh if devel space is merged return commands # Create the setup file other packages will source when depending on this package subs = {} subs['cmake_prefix_path'] = install_target + ":" subs['ld_path'] = os.path.join(install_target, 'lib') + ":" pythonpath = os.path.join(install_target, get_python_install_dir()) subs['pythonpath'] = pythonpath + ':' subs['pkgcfg_path'] = os.path.join(install_target, 'lib', 'pkgconfig') subs['pkgcfg_path'] += ":" subs['path'] = os.path.join(install_target, 'bin') + ":" setup_file_directory = os.path.dirname(setup_file_path) if not os.path.exists(setup_file_directory): os.makedirs(setup_file_directory) # Create a temporary file in the setup_file_directory, so os.rename cannot fail tmp_dst_handle, tmp_dst_path = tempfile.mkstemp( dir=setup_file_directory, prefix=os.path.basename(setup_file_path) + '.') # Write the fulfilled template to the file data = """\ #!/usr/bin/env sh # generated from catkin_tools.verbs.catkin_build.job python module # remember type of shell if not already set if [ -z "$CATKIN_SHELL" ]; then CATKIN_SHELL=sh fi # detect if running on Darwin platform _UNAME=`uname -s` IS_DARWIN=0 if [ "$_UNAME" = "Darwin" ]; then IS_DARWIN=1 fi # Prepend to the environment export CMAKE_PREFIX_PATH="{cmake_prefix_path}$CMAKE_PREFIX_PATH" if [ $IS_DARWIN -eq 0 ]; then export LD_LIBRARY_PATH="{ld_path}$LD_LIBRARY_PATH" else export DYLD_LIBRARY_PATH="{ld_path}$DYLD_LIBRARY_PATH" fi export PATH="{path}$PATH" export PKG_CONFIG_PATH="{pkgcfg_path}$PKG_CONFIG_PATH" export PYTHONPATH="{pythonpath}$PYTHONPATH" """.format(**subs) os.write(tmp_dst_handle, data.encode('utf-8')) os.close(tmp_dst_handle) # Do an atomic rename with os.rename os.rename(tmp_dst_path, setup_file_path) return commands
def get_commands(self): commands = [] # Setup build variables pkg_dir = os.path.join(self.context.source_space_abs, self.package_path) build_space = create_build_space(self.context.build_space_abs, self.package.name) if self.context.isolate_devel: devel_space = os.path.join(self.context.devel_space_abs, self.package.name) else: devel_space = self.context.devel_space_abs if self.context.isolate_install: install_space = os.path.join(self.context.install_space_abs, self.package.name) else: install_space = self.context.install_space_abs install_target = install_space if self.context.install else devel_space # Create an environment file env_cmd = create_env_file(self.package, self.context) # CMake command makefile_path = os.path.join(build_space, 'Makefile') if not os.path.isfile(makefile_path) or self.force_cmake: commands.append(CMakeCommand( env_cmd, [ CMAKE_EXEC, pkg_dir, '-DCMAKE_INSTALL_PREFIX=' + install_target ] + self.context.cmake_args, build_space )) commands[-1].cmd.extend(self.context.cmake_args) else: commands.append(MakeCommand(env_cmd, [MAKE_EXEC, 'cmake_check_build_system'], build_space)) # Make command commands.append(MakeCommand( env_cmd, [MAKE_EXEC] + handle_make_arguments(self.context.make_args), build_space )) # Make install command (always run on plain cmake) commands.append(InstallCommand(env_cmd, [MAKE_EXEC, 'install'], build_space)) # Determine the location of where the setup.sh file should be created if self.context.install: setup_file_path = os.path.join(install_space, 'setup.sh') if not self.context.isolate_install and os.path.exists(setup_file_path): return commands else: # Create it in the devel space setup_file_path = os.path.join(devel_space, 'setup.sh') if not self.context.isolate_devel and os.path.exists(setup_file_path): # Do not replace existing setup.sh if devel space is merged return commands # Create the setup file other packages will source when depending on this package arch = self.get_multiarch() subs = {} subs['cmake_prefix_path'] = install_target + ":" subs['ld_path'] = os.path.join(install_target, 'lib') + ":" pythonpath = os.path.join(install_target, get_python_install_dir()) subs['pythonpath'] = pythonpath + ':' subs['pkgcfg_path'] = os.path.join(install_target, 'lib', 'pkgconfig') + ":" subs['path'] = os.path.join(install_target, 'bin') + ":" if arch: subs['ld_path'] += os.path.join(install_target, 'lib', arch) + ":" subs['pkgcfg_path'] += os.path.join(install_target, 'lib', arch, 'pkgconfig') + ":" setup_file_directory = os.path.dirname(setup_file_path) if not os.path.exists(setup_file_directory): os.makedirs(setup_file_directory) # Create a temporary file in the setup_file_directory, so os.rename cannot fail tmp_dst_handle, tmp_dst_path = tempfile.mkstemp( dir=setup_file_directory, prefix=os.path.basename(setup_file_path) + '.') # Write the fulfilled template to the file data = """\ #!/usr/bin/env sh # generated from catkin_tools.verbs.catkin_build.job python module # remember type of shell if not already set if [ -z "$CATKIN_SHELL" ]; then CATKIN_SHELL=sh fi # detect if running on Darwin platform _UNAME=`uname -s` IS_DARWIN=0 if [ "$_UNAME" = "Darwin" ]; then IS_DARWIN=1 fi # Prepend to the environment export CMAKE_PREFIX_PATH="{cmake_prefix_path}$CMAKE_PREFIX_PATH" if [ $IS_DARWIN -eq 0 ]; then export LD_LIBRARY_PATH="{ld_path}$LD_LIBRARY_PATH" else export DYLD_LIBRARY_PATH="{ld_path}$DYLD_LIBRARY_PATH" fi export PATH="{path}$PATH" export PKG_CONFIG_PATH="{pkgcfg_path}$PKG_CONFIG_PATH" export PYTHONPATH="{pythonpath}$PYTHONPATH" """.format(**subs) os.write(tmp_dst_handle, data.encode('utf-8')) os.close(tmp_dst_handle) # Do an atomic rename with os.rename os.rename(tmp_dst_path, setup_file_path) return commands