def _common_cmake_on_build(self, should_run_configure, context, prefix, extra_cmake_args): # Execute the configure step # (either cmake or the cmake_check_build_system make target) if should_run_configure: cmake_args = [context.source_space] cmake_args.extend(extra_cmake_args) cmake_args += ["-DCMAKE_INSTALL_PREFIX=" + context.install_space] if IS_WINDOWS: vsv = get_visual_studio_version() if vsv is None: sys.stderr.write( 'VisualStudioVersion is not set, ' 'please run within a Visual Studio Command Prompt.\n') raise VerbExecutionError('Could not determine Visual Studio Version') supported_vsv = { '14.0': 'Visual Studio 14 2015 Win64', } if vsv not in supported_vsv: raise VerbExecutionError('Unknown / unsupported VS version: ' + vsv) cmake_args += ['-G', supported_vsv[vsv]] if CMAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'cmake' executable") yield BuildAction(prefix + [CMAKE_EXECUTABLE] + cmake_args) elif not IS_WINDOWS: # Check for reconfigure if available. if MAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'make' executable") cmd = prefix + [MAKE_EXECUTABLE, 'cmake_check_build_system'] yield BuildAction(cmd) # Now execute the build step if not IS_WINDOWS: if MAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'make' executable") yield BuildAction(prefix + [MAKE_EXECUTABLE] + context.make_flags) else: if MSBUILD_EXECUTABLE is None: raise VerbExecutionError("Could not find 'msbuild' executable") solution_file = solution_file_exists_at( context.build_space, context.package_manifest.name) cmd = prefix + [MSBUILD_EXECUTABLE] if '-j1' in context.make_flags: cmd += ['/m'] cmd += [ '/p:Configuration=%s' % self._get_visual_studio_configuration(context), solution_file] yield BuildAction(cmd)
def _common_cmake_on_build(self, should_run_configure, context, prefix, extra_cmake_args): # Execute the configure step # (either cmake or the cmake_check_build_system make target) if should_run_configure: cmake_args = [context.source_space] cmake_args.extend(extra_cmake_args) cmake_args += ["-DCMAKE_INSTALL_PREFIX=" + context.install_space] if IS_WINDOWS: vsv = get_visual_studio_version() if vsv is None: print("VisualStudioVersion is not set, please run within " "a VS2013 or VS2015 Command Prompt.") raise VerbExecutionError( "Could not determine Visual Studio Version.") generator = None if vsv == '12.0': generator = 'Visual Studio 12 2013 Win64' elif vsv == '14.0': generator = 'Visual Studio 14 2015 Win64' else: raise VerbExecutionError("Unknown VS version: " + vsv) cmake_args += ['-G', generator] if CMAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'cmake' executable") yield BuildAction(prefix + [CMAKE_EXECUTABLE] + cmake_args) elif not IS_WINDOWS: # Check for reconfigure if available. cmd = prefix + [MAKE_EXECUTABLE, 'cmake_check_build_system'] yield BuildAction(cmd) # Now execute the build step if not IS_WINDOWS: if MAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'make' executable") yield BuildAction(prefix + [MAKE_EXECUTABLE] + context.make_flags) else: if MSBUILD_EXECUTABLE is None: raise VerbExecutionError("Could not find 'msbuild' executable") solution_file = solution_file_exists_at( context.build_space, context.package_manifest.name) if '-j1' in context.make_flags: yield BuildAction(prefix + [MSBUILD_EXECUTABLE, solution_file]) else: yield BuildAction(prefix + [MSBUILD_EXECUTABLE, '/m', solution_file])
def _common_cmake_on_build(self, should_run_configure, context, prefix, extra_cmake_args): # Execute the configure step # (either cmake or the cmake_check_build_system make target) if should_run_configure: cmake_args = [context.source_space] cmake_args.extend(extra_cmake_args) cmake_args += ["-DCMAKE_INSTALL_PREFIX=" + context.install_space] if IS_WINDOWS: vsv = get_visual_studio_version() if vsv is None: print("VisualStudioVersion is not set, please run within " "a VS2013 or VS2015 Command Prompt.") raise VerbExecutionError( "Could not determine Visual Studio Version.") generator = None if vsv == '12.0': generator = 'Visual Studio 12 2013 Win64' elif vsv == '14.0': generator = 'Visual Studio 14 2015 Win64' else: raise VerbExecutionError("Unknown VS version: " + vsv) cmake_args += ['-G', generator] if CMAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'cmake' executable") yield BuildAction(prefix + [CMAKE_EXECUTABLE] + cmake_args) elif not IS_WINDOWS: # Check for reconfigure if available. cmd = prefix + [MAKE_EXECUTABLE, 'cmake_check_build_system'] yield BuildAction(cmd) # Now execute the build step if not IS_WINDOWS: if MAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'make' executable") yield BuildAction(prefix + [MAKE_EXECUTABLE] + context.make_flags) else: if MSBUILD_EXECUTABLE is None: raise VerbExecutionError("Could not find 'msbuild' executable") solution_file = solution_file_exists_at( context.build_space, context.package_manifest.name) if '-j1' in context.make_flags: yield BuildAction(prefix + [MSBUILD_EXECUTABLE, solution_file]) else: yield BuildAction(prefix + [MSBUILD_EXECUTABLE, '/m', solution_file])
def _common_cmake_on_build(self, should_run_configure, context, prefix, extra_cmake_args): # Execute the configure step # (either cmake or the cmake_check_build_system make target) if should_run_configure: cmake_args = [context.source_space] cmake_args.extend(extra_cmake_args) cmake_args += ['-DCMAKE_INSTALL_PREFIX=' + context.install_space] if IS_WINDOWS: vsv = get_visual_studio_version() if vsv is None: sys.stderr.write( 'VisualStudioVersion is not set, ' 'please run within a Visual Studio Command Prompt.\n') raise VerbExecutionError( 'Could not determine Visual Studio Version') supported_vsv = { '14.0': 'Visual Studio 14 2015 Win64', '15.0': 'Visual Studio 15 2017 Win64', } if vsv not in supported_vsv: raise VerbExecutionError( 'Unknown / unsupported VS version: ' + vsv) cmake_args += ['-G', supported_vsv[vsv]] elif IS_MACOSX: if context.use_xcode or self._using_xcode_generator(context): cmake_args += ['-G', 'Xcode'] else: cmake_args += ['-G', 'Unix Makefiles'] if CMAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'cmake' executable") yield BuildAction(prefix + [CMAKE_EXECUTABLE] + cmake_args) elif IS_LINUX: # Check for reconfigure if available. if MAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'make' executable") cmd = prefix + [MAKE_EXECUTABLE, 'cmake_check_build_system'] yield BuildAction(cmd) # Now execute the build step if IS_LINUX: yield self._make_or_ninja_build(context, prefix) elif IS_WINDOWS: if MSBUILD_EXECUTABLE is None: raise VerbExecutionError("Could not find 'msbuild' executable") solution_file = solution_file_exists_at( context.build_space, context.package_manifest.name) cmd = prefix + [MSBUILD_EXECUTABLE] env = None # Convert make parallelism flags into msbuild flags msbuild_flags = [ x.replace('-j', '/m:') for x in context.make_flags if x.startswith('-j') ] if msbuild_flags: cmd += msbuild_flags # If there is a parallelism flag in msbuild_flags and it's not /m1, # then turn on /MP for the compiler (intra-project parallelism) if any(x.startswith('/m') for x in msbuild_flags) and \ '/m:1' not in msbuild_flags: env = dict(os.environ) if 'CL' in env: # make sure env['CL'] doesn't include an /MP already if not any( x.startswith('/MP') for x in env['CL'].split(' ')): env['CL'] += ' /MP' else: # CL not in environment; let's add it with our flag env['CL'] = '/MP' cmd += [ '/p:Configuration=%s' % self._get_configuration_from_cmake(context), solution_file ] yield BuildAction(cmd, env=env) elif IS_MACOSX: if self._using_xcode_generator(context): if XCODEBUILD_EXECUTABLE is None: raise VerbExecutionError( "Could not find 'xcodebuild' executable") cmd = prefix + [XCODEBUILD_EXECUTABLE] cmd += ['build'] xcodebuild_flags = [] for flag in context.make_flags: if flag.startswith('-j'): xcodebuild_flags.append( flag.replace( '-j', '-IDEBuildOperationMaxNumberOfConcurrentCompileTasks=' )) elif not flag.startswith('-l'): xcodebuild_flags.append(flag) xcodebuild_flags += ['-configuration'] xcodebuild_flags += [ self._get_configuration_from_cmake(context) ] cmd.extend(xcodebuild_flags) yield BuildAction(cmd) else: yield self._make_or_ninja_build(context, prefix) else: raise VerbExecutionError('Could not determine operating system')
def _common_cmake_on_build(self, should_run_configure, context, prefix, extra_cmake_args): # Execute the configure step # (either cmake or the cmake_check_build_system make target) if should_run_configure: cmake_args = [context.source_space] cmake_args.extend(extra_cmake_args) cmake_args += ["-DCMAKE_INSTALL_PREFIX=" + context.install_space] if IS_WINDOWS: vsv = get_visual_studio_version() if vsv is None: sys.stderr.write( 'VisualStudioVersion is not set, ' 'please run within a Visual Studio Command Prompt.\n') raise VerbExecutionError( 'Could not determine Visual Studio Version') supported_vsv = { '14.0': 'Visual Studio 14 2015 Win64', } if vsv not in supported_vsv: raise VerbExecutionError( 'Unknown / unsupported VS version: ' + vsv) cmake_args += ['-G', supported_vsv[vsv]] if CMAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'cmake' executable") yield BuildAction(prefix + [CMAKE_EXECUTABLE] + cmake_args) elif not IS_WINDOWS: # Check for reconfigure if available. if MAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'make' executable") cmd = prefix + [MAKE_EXECUTABLE, 'cmake_check_build_system'] yield BuildAction(cmd) # Now execute the build step if not IS_WINDOWS: if context.use_ninja: if NINJA_EXECUTABLE is None: raise VerbExecutionError( "Could not find 'make' executable") yield BuildAction(prefix + [NINJA_EXECUTABLE] + context.make_flags) else: if MAKE_EXECUTABLE is None: raise VerbExecutionError( "Could not find 'make' executable") yield BuildAction(prefix + [MAKE_EXECUTABLE] + context.make_flags) else: if MSBUILD_EXECUTABLE is None: raise VerbExecutionError("Could not find 'msbuild' executable") solution_file = solution_file_exists_at( context.build_space, context.package_manifest.name) cmd = prefix + [MSBUILD_EXECUTABLE] env = None # Convert make parallelism flags into msbuild flags msbuild_flags = [ x.replace('-j', '/m:') for x in context.make_flags if x.startswith('-j') ] if msbuild_flags: cmd += msbuild_flags # If there is a parallelism flag in msbuild_flags and it's not /m1, # then turn on /MP for the compiler (intra-project parallelism) if any([x.startswith('/m') for x in msbuild_flags]) and \ '/m:1' not in msbuild_flags: env = dict(os.environ) if 'CL' in env: # make sure env['CL'] doesn't include an /MP already if not any([ x.startswith('/MP') for x in env['CL'].split(' ') ]): env['CL'] += ' /MP' else: # CL not in environment; let's add it with our flag env['CL'] = '/MP' cmd += [ '/p:Configuration=%s' % self._get_visual_studio_configuration(context), solution_file ] yield BuildAction(cmd, env=env)
def _common_cmake_on_build(self, should_run_configure, context, prefix, extra_cmake_args): # Execute the configure step # (either cmake or the cmake_check_build_system make target) if should_run_configure: cmake_args = list(extra_cmake_args) cmake_args += ['-DCMAKE_INSTALL_PREFIX=' + context.install_space] if IS_WINDOWS: vsv = get_visual_studio_version() if vsv is None: sys.stderr.write( 'VisualStudioVersion is not set, ' 'please run within a Visual Studio Command Prompt.\n') raise VerbExecutionError('Could not determine Visual Studio Version') supported_vsv = { '14.0': 'Visual Studio 14 2015 Win64', '15.0': 'Visual Studio 15 2017 Win64', } if vsv not in supported_vsv: raise VerbExecutionError('Unknown / unsupported VS version: ' + vsv) cmake_args += ['-G', supported_vsv[vsv]] elif IS_MACOSX: if context.use_xcode or self._using_xcode_generator(context): cmake_args += ['-G', 'Xcode'] else: cmake_args += ['-G', 'Unix Makefiles'] cmake_args += [context.source_space] if CMAKE_EXECUTABLE is None: raise VerbExecutionError( "Could not find 'cmake' executable, try setting the " 'environment variable' + CMAKE_EXECUTABLE_ENV) yield BuildAction(prefix + [CMAKE_EXECUTABLE] + cmake_args) elif IS_LINUX: # Check for reconfigure if available. if MAKE_EXECUTABLE is None: raise VerbExecutionError("Could not find 'make' executable") cmd = prefix + [MAKE_EXECUTABLE, 'cmake_check_build_system'] yield BuildAction(cmd) # Now execute the build step if IS_LINUX: yield self._make_or_ninja_build(context, prefix) elif IS_WINDOWS: if MSBUILD_EXECUTABLE is None: raise VerbExecutionError("Could not find 'msbuild' executable") solution_file = solution_file_exists_at( context.build_space, context.package_manifest.name) cmd = prefix + [MSBUILD_EXECUTABLE] env = None # Convert make parallelism flags into msbuild flags msbuild_flags = [ x.replace('-j', '/m:') for x in context.make_flags if x.startswith('-j') ] if msbuild_flags: cmd += msbuild_flags # If there is a parallelism flag in msbuild_flags and it's not /m1, # then turn on /MP for the compiler (intra-project parallelism) if any(x.startswith('/m') for x in msbuild_flags) and \ '/m:1' not in msbuild_flags: env = dict(os.environ) if 'CL' in env: # make sure env['CL'] doesn't include an /MP already if not any(x.startswith('/MP') for x in env['CL'].split(' ')): env['CL'] += ' /MP' else: # CL not in environment; let's add it with our flag env['CL'] = '/MP' cmd += [ '/p:Configuration=%s' % self._get_configuration_from_cmake(context), solution_file] yield BuildAction(cmd, env=env) elif IS_MACOSX: if self._using_xcode_generator(context): if XCODEBUILD_EXECUTABLE is None: raise VerbExecutionError("Could not find 'xcodebuild' executable") cmd = prefix + [XCODEBUILD_EXECUTABLE] cmd += ['build'] xcodebuild_flags = [] for flag in context.make_flags: if flag.startswith('-j'): xcodebuild_flags.append(flag.replace( '-j', '-IDEBuildOperationMaxNumberOfConcurrentCompileTasks=')) elif not flag.startswith('-l'): xcodebuild_flags.append(flag) xcodebuild_flags += ['-configuration'] xcodebuild_flags += [self._get_configuration_from_cmake(context)] cmd.extend(xcodebuild_flags) yield BuildAction(cmd) else: yield self._make_or_ninja_build(context, prefix) else: raise VerbExecutionError('Could not determine operating system')