def BuildPackage(self, package): """Build a single package. Assumes dependencies of the package have been built. Args: package: Package to build. """ package_info = self._packages[package] # Validate the package description. if 'type' not in package_info: raise Exception('package %s does not have a type' % package) type_text = package_info['type'] if type_text not in ('source', 'build'): raise Exception('package %s has unrecognized type: %s' % (package, type_text)) is_source_target = type_text == 'source' if 'commands' not in package_info: raise Exception('package %s does not have any commands' % package) # Source targets are the only ones to run when doing sync-only. if not is_source_target and self._options.sync_sources_only: logging.debug('Build skipped: not running commands for %s' % package) return # Source targets do not run when skipping sync. if is_source_target and not ( self._options.sync_sources or self._options.sync_sources_only): logging.debug('Sync skipped: not running commands for %s' % package) return pynacl.log_tools.WriteAnnotatorLine( '@@@BUILD_STEP %s (%s)@@@' % (package, type_text)) logging.debug('Building %s package %s' % (type_text, package)) dependencies = package_info.get('dependencies', []) # Collect a dict of all the inputs. inputs = {} # Add in explicit inputs. if 'inputs' in package_info: for key, value in package_info['inputs'].iteritems(): if key in dependencies: raise Exception('key "%s" found in both dependencies and inputs of ' 'package "%s"' % (key, package)) inputs[key] = value elif type_text != 'source': # Non-source packages default to a particular input directory. inputs['src'] = os.path.join(self._options.source, package) # Add in each dependency by package name. for dependency in dependencies: inputs[dependency] = self.GetOutputDir(dependency, True) # Each package generates intermediate into output/<PACKAGE>_work. # Clobbered here explicitly. work_dir = os.path.join(self._options.output, package + '_work') if self._options.clobber: logging.debug('Clobbering working directory %s' % work_dir) pynacl.file_tools.RemoveDirectoryIfPresent(work_dir) pynacl.file_tools.MakeDirectoryIfAbsent(work_dir) output = self.GetOutputDir(package, False) output_subdir = self.GetOutputDir(package, True) if not is_source_target or self._options.clobber_source: logging.debug('Clobbering output directory %s' % output) pynacl.file_tools.RemoveDirectoryIfPresent(output) os.makedirs(output_subdir) commands = package_info.get('commands', []) # Create a command option object specifying current build. cmd_options = command_options.CommandOptions( work_dir=work_dir, clobber_working=self._options.clobber, clobber_source=self._options.clobber_source, trybot=self._options.trybot, buildbot=self._options.buildbot) # Do it. self._build_once.Run( package, inputs, output, commands=commands, cmd_options=cmd_options, working_dir=work_dir, memoize=not is_source_target, signature_file=self._signature_file, subdir=output_subdir) if not is_source_target and self._options.install: install = pynacl.platform.CygPath(self._options.install) logging.debug('Installing output to %s' % install) pynacl.file_tools.CopyTree(output, install)
def BuildPackage(self, package): """Build a single package. Assumes dependencies of the package have been built. Args: package: Package to build. """ package_info = self._packages[package] # Validate the package description. if 'type' not in package_info: raise BuildError('package %s does not have a type' % package) type_text = package_info['type'] if type_text not in ('source', 'build', 'build_noncanonical', 'work'): raise BuildError('package %s has unrecognized type: %s' % (package, type_text)) is_source_target = type_text == 'source' is_build_target = type_text in ('build', 'build_noncanonical') build_signature_key_extra = '' if type_text == 'build_noncanonical': build_signature_key_extra = '_' + pynacl.gsd_storage.LegalizeName( pynacl.platform.PlatformTriple()) if 'commands' not in package_info: raise BuildError('package %s does not have any commands' % package) # Source targets are the only ones to run when doing sync-only. if not is_source_target and self._options.sync_sources_only: logging.debug('Build skipped: not running commands for %s' % package) return # Source targets do not run when skipping sync. if is_source_target and not (self._options.sync_sources or self._options.sync_sources_only): logging.debug('Sync skipped: not running commands for %s' % package) return if type_text == 'build_noncanonical' and self._options.canonical_only: logging.debug('Non-canonical build of %s skipped' % package) return pynacl.log_tools.WriteAnnotatorLine('@@@BUILD_STEP %s (%s)@@@' % (package, type_text)) logging.debug('Building %s package %s' % (type_text, package)) dependencies = package_info.get('dependencies', []) # Collect a dict of all the inputs. inputs = {} # Add in explicit inputs. if 'inputs' in package_info: for key, value in package_info['inputs'].iteritems(): if key in dependencies: raise BuildError( 'key "%s" found in both dependencies and inputs of ' 'package "%s"' % (key, package)) inputs[key] = value elif type_text != 'source': # Non-source packages default to a particular input directory. inputs['src'] = os.path.join(self._options.source, package) # Add in each dependency by package name. for dependency in dependencies: inputs[dependency] = self.GetOutputDir(dependency, True) # Each package generates intermediate into output/<PACKAGE>_work. # Clobbered here explicitly. work_dir = os.path.join(self._options.output, package + '_work') if self._options.clobber: logging.debug('Clobbering working directory %s' % work_dir) pynacl.file_tools.RemoveDirectoryIfPresent(work_dir) pynacl.file_tools.MakeDirectoryIfAbsent(work_dir) output = self.GetOutputDir(package, False) output_subdir = self.GetOutputDir(package, True) if not is_source_target or self._options.clobber_source: logging.debug('Clobbering output directory %s' % output) pynacl.file_tools.RemoveDirectoryIfPresent(output) os.makedirs(output_subdir) commands = package_info.get('commands', []) # Create a command option object specifying current build. cmd_options = command_options.CommandOptions( work_dir=work_dir, clobber_working=self._options.clobber, clobber_source=self._options.clobber_source, trybot=self._options.trybot, buildbot=self._options.buildbot) # Do it. try: self._build_once.Run(package, inputs, output, commands=commands, cmd_options=cmd_options, working_dir=work_dir, memoize=is_build_target, signature_file=self._signature_file, subdir=output_subdir, bskey_extra=build_signature_key_extra) except subprocess.CalledProcessError as e: raise BuildError('Error building %s: %s' % (package, str(e))) if not is_source_target and self._options.install: install = pynacl.platform.CygPath(self._options.install) logging.debug('Installing output to %s' % install) pynacl.file_tools.CopyTree(output, install)
def BuildPackage(self, package): """Build a single package. Assumes dependencies of the package have been built. Args: package: Package to build. """ package_info = self._packages[package] # Validate the package description. if "type" not in package_info: raise BuildError("package %s does not have a type" % package) type_text = package_info["type"] if type_text not in ("source", "build", "build_noncanonical", "work"): raise BuildError("package %s has unrecognized type: %s" % (package, type_text)) is_source_target = type_text == "source" is_build_target = type_text in ("build", "build_noncanonical") build_signature_key_extra = "" if type_text == "build_noncanonical": build_signature_key_extra = "_" + pynacl.gsd_storage.LegalizeName(pynacl.platform.PlatformTriple()) if "commands" not in package_info: raise BuildError("package %s does not have any commands" % package) # Source targets are the only ones to run when doing sync-only. if not is_source_target and self._options.sync_sources_only: logging.debug("Build skipped: not running commands for %s" % package) return # Source targets do not run when skipping sync. if is_source_target and not (self._options.sync_sources or self._options.sync_sources_only): logging.debug("Sync skipped: not running commands for %s" % package) return if type_text == "build_noncanonical" and self._options.canonical_only: logging.debug("Non-canonical build of %s skipped" % package) return pynacl.log_tools.WriteAnnotatorLine("@@@BUILD_STEP %s (%s)@@@" % (package, type_text)) logging.debug("Building %s package %s" % (type_text, package)) dependencies = package_info.get("dependencies", []) # Collect a dict of all the inputs. inputs = {} # Add in explicit inputs. if "inputs" in package_info: for key, value in package_info["inputs"].iteritems(): if key in dependencies: raise BuildError( 'key "%s" found in both dependencies and inputs of ' 'package "%s"' % (key, package) ) inputs[key] = value elif type_text != "source": # Non-source packages default to a particular input directory. inputs["src"] = os.path.join(self._options.source, package) # Add in each dependency by package name. for dependency in dependencies: inputs[dependency] = self.GetOutputDir(dependency, True) # Each package generates intermediate into output/<PACKAGE>_work. # Clobbered here explicitly. work_dir = os.path.join(self._options.output, package + "_work") if self._options.clobber: logging.debug("Clobbering working directory %s" % work_dir) pynacl.file_tools.RemoveDirectoryIfPresent(work_dir) pynacl.file_tools.MakeDirectoryIfAbsent(work_dir) output = self.GetOutputDir(package, False) output_subdir = self.GetOutputDir(package, True) if not is_source_target or self._options.clobber_source: logging.debug("Clobbering output directory %s" % output) pynacl.file_tools.RemoveDirectoryIfPresent(output) os.makedirs(output_subdir) commands = package_info.get("commands", []) # Create a command option object specifying current build. cmd_options = command_options.CommandOptions( work_dir=work_dir, clobber_working=self._options.clobber, clobber_source=self._options.clobber_source, trybot=self._options.trybot, buildbot=self._options.buildbot, ) # Do it. try: self._build_once.Run( package, inputs, output, commands=commands, cmd_options=cmd_options, working_dir=work_dir, memoize=is_build_target, signature_file=self._signature_file, subdir=output_subdir, bskey_extra=build_signature_key_extra, ) except subprocess.CalledProcessError as e: raise BuildError("Error building %s: %s" % (package, str(e))) if not is_source_target and self._options.install: install = pynacl.platform.CygPath(self._options.install) logging.debug("Installing output to %s" % install) pynacl.file_tools.CopyTree(output, install)
def BuildPackage(self, package): """Build a single package. Assumes dependencies of the package have been built. Args: package: Package to build. """ package_info = self._packages[package] # Validate the package description. if 'type' not in package_info: raise Exception('package %s does not have a type' % package) type_text = package_info['type'] if type_text not in ('source', 'build'): raise Execption('package %s has unrecognized type: %s' % (package, type_text)) is_source_target = type_text == 'source' if 'commands' not in package_info: raise Exception('package %s does not have any commands' % package) # Source targets are the only ones to run when doing sync-only. if not is_source_target and self._options.sync_sources_only: logging.debug('Build skipped: not running commands for %s' % package) return # Source targets do not run when skipping sync. if is_source_target and not (self._options.sync_sources or self._options.sync_sources_only): logging.debug('Sync skipped: not running commands for %s' % package) return PrintFlush('@@@BUILD_STEP %s (%s)@@@' % (package, type_text)) logging.debug('Building %s package %s' % (type_text, package)) dependencies = package_info.get('dependencies', []) # Collect a dict of all the inputs. inputs = {} # Add in explicit inputs. if 'inputs' in package_info: for key, value in package_info['inputs'].iteritems(): if key in dependencies: raise Exception( 'key "%s" found in both dependencies and inputs of ' 'package "%s"' % (key, package)) inputs[key] = value else: inputs['src'] = os.path.join(self._options.source, package) # Add in each dependency by package name. for dependency in dependencies: inputs[dependency] = self.GetOutputDir(dependency, True) # Each package generates intermediate into output/<PACKAGE>_work. # Clobbered here explicitly. work_dir = os.path.join(self._options.output, package + '_work') if self._options.clobber: logging.debug('Clobbering working directory %s' % work_dir) pynacl.file_tools.RemoveDirectoryIfPresent(work_dir) pynacl.file_tools.MakeDirectoryIfAbsent(work_dir) output = self.GetOutputDir(package, False) output_subdir = self.GetOutputDir(package, True) if not is_source_target or self._options.clobber_source: logging.debug('Clobbering output directory %s' % output) pynacl.file_tools.RemoveDirectoryIfPresent(output) os.makedirs(output_subdir) commands = package_info.get('commands', []) if not self._options.clobber and len(os.listdir(work_dir)) > 0: commands = [ cmd for cmd in commands if not (hasattr(cmd, 'skip_for_incremental') and cmd.skip_for_incremental) ] # Do it. self._build_once.Run(package, inputs, output, commands=commands, working_dir=work_dir, memoize=not is_source_target, signature_file=self._signature_file, subdir=output_subdir) if not is_source_target and self._options.install: logging.debug('Installing output to %s' % self._options.install) pynacl.file_tools.CopyTree(output, self._options.install)