class Options: """ Options for customizing the behaviour of all targets. To set an option on a specific target call `xpybuild.basetarget.BaseTarget.option` or to se a global default use `xpybuild.propertysupport.setGlobalOption`. """ failureRetries = defineOption("Target.failureRetries", 0) """ The "Target.failureRetries" option can be set on any target (or globally), and specifies how many times to retry the target's build if it fails. The default is 0, which is recommended for normal developer builds. There is an exponentially increasing backoff pause between each attempt - first 15s, then 30s, then 60s etc. See `xpybuild.buildcommon.registerBuildLoadPostProcessor` which can be used to customize this option for targets based on user-defined criteria such as target type. """ failureRetriesInitialBackoffSecs = defineOption( 'Target.failureRetriesInitialBackoffSecs', 15) # undocumented as there should be no reason to change this
r = super(Copy, self).getHashableImplicitInputs(context) # include source representation of deps list, so that changes to the list get reflected # this way of doing property expansion on the repr is a convenient # shortcut (we want to expand property values to detect changes in # versions etc that should trigger a rebuild, but just not do any # globbing/searches here) # This is slightly dodgy in case any object in src uses the "{" char which would map as a property substitution, but fairly unlikely r.append('src: ' + context.expandPropertyValues('%s' % self.src)) if self.mode: r.append('mode: %s' % self.mode) return r defineOption('Copy.symlinks', False) """ If True, symbolic links in the source are represented as symbolic links (either absolute or relative) in the destination. If False (the default), symbolic links are handled by copying the contents of the linked files. """ class FilteredCopy(Copy): """ Target that copies one or more input text file(s) to an output file or directory, filtering each line through the specified line mappers. The parent directory will be created if it doesn't exist already. Any source files determines to be binary/non-text by `ExtensionBasedFileEncodingDecider.BINARY` are copied without any mappers
from xpybuild.utils.buildexceptions import BuildException from xpybuild.utils.fileutils import openForWrite, mkdir, deleteFile, cached_getmtime, cached_exists, toLongPathSafe, cached_stat class __CompilersNotSpecified(object): def __getattr__(self, attr): raise Exception( 'Cannot use native targets until a compiler is configured by setting the native.compilers option' ) def __repr__(self): return '<native.compilers option is not configured>' # these options all need documenting defineOption('native.compilers', __CompilersNotSpecified()) defineOption('native.libs', []) defineOption('native.libpaths', []) defineOption('native.c.flags', None) # defaults to native.cxx.flags if not set defineOption('native.cxx.flags', []) defineOption('native.cxx.path', []) defineOption('native.include', []) """List of include dirs to be added (each ending in a slash). """ defineOption('native.include.upToDateCheckIgnoreRegex', '') """Any include files which this regular expression matches are ignored for dependency checking purposes. This can be used to speed up up-to-date checking by avoiding locations whose contents never change. However be careful not to put any paths that might change into this regular expression, otherwise your targets may not rebuild as expected when their dependencies change. Paths must use forward slashes no backslashes for separating directories.
includes=None): args = [self.compiler_command, '-c', '-o', os.path.basename(output)] args.extend([ '-I%s' % _checkDirExists(x, 'Cannot find include directory ``%s"') for x in (includes or []) ]) args.extend(flags or []) args.extend(src) self.call(context, args, outputHandler=self.compiler_handler, cwd=os.path.dirname(output), options=options) defineOption('native.link.wholearchive', None) class UnixLinker(Linker): """ A linker using standard Unix linker arguments/syntax """ def __init__(self, command, outputHandler=None, environs=None): """ command: The path to the linker outputHandler: a ProcessOutputHandler to parse the output of the linker """ Linker.__init__(self, environs=environs) self.linker_command = command self.linker_handler = outputHandler or ProcessOutputHandler
from xpybuild.buildcommon import * from xpybuild.propertysupport import defineOption from xpybuild.utils.process import call from xpybuild.utils.outputhandler import ProcessOutputHandler from xpybuild.utils.flatten import getStringList from xpybuild.utils.fileutils import deleteDir, mkdir, deleteFile, openForWrite, normLongPath from xpybuild.utils.consoleformatter import publishArtifact from xpybuild.utils.buildexceptions import BuildException import logging log = logging.getLogger('utils.java') # General java options defineOption('java.home', None) # Options for creating manifests defineOption('jar.manifest.defaults', {}) def create_manifest(path, properties, options): """ Create a manifest file in path from the map properties. @param path: The absolute path in which to create a manifest file. If None is specified, no file is written but a byte string containing the file contents is returned. @param properties: A map of manifest keys to values (unicode character strings). Must follow java jar file format specification, e.g. headers cannot contain spaces. @param options: The options to use for creating the manifest (prefix: jar.manifest)
def __init__(self, path): """ @param path: The path to expand, which is a string. """ self.path = path def __repr__(self): """ Returns a string including this class name and the path """ return 'ResolvePath<%s>' % self.path def resolve(self, context, baseDir): """ Resolves the path using the specified context and baseDir """ return context.getFullPath(self.path, defaultDir=baseDir) defineOption('CustomCommand.outputHandlerFactory', None) class CustomCommand(BaseTarget): """ A custom target that builds a single file or directory of content by running one or more command line processes. The command line *must* not reference any generated paths unless they are explicitly listed in deps. Supported target options include: - ``.option("process.timeout")`` to control the maximum number of seconds the command can run before being cancelled. - ``.option("common.processOutputEncodingDecider")`` to determine the encoding
This can be overridden to add support for stripping timestamps, thread ids, unwanted indentation, etc. """ return line.strip() def getErrors(self): return self._errors def getWarnings(self): return self._warnings def getLastOutputLine(self): return self._preprocessLine(self._lastLine) class StdoutRedirector(ProcessOutputHandler): """ Redirects stdout to a file verbatim and reports errors on stderr """ def __init__(self, name, fd, **kwargs): """ fd is a binary-mode writable file descriptor """ ProcessOutputHandler.__init__(self, name, True, **kwargs) self.fd = fd def handleLine(self, line, isstderr=False): if isstderr: ProcessOutputHandler.handleLine(self, line, isstderr) else: self.fd.write((line+os.linesep).encode("UTF-8")) def handleEnd(self, returnCode=None): ProcessOutputHandler.handleEnd(self, returnCode) defineOption(ProcessOutputHandler.Options.ignoreReturnCode, False) defineOption(ProcessOutputHandler.Options.regexIgnore, None) defineOption(ProcessOutputHandler.Options.factory, ProcessOutputHandler)
import os, inspect from xpybuild.buildcommon import * from xpybuild.basetarget import BaseTarget from xpybuild.propertysupport import defineOption from xpybuild.utils.process import call from xpybuild.pathsets import PathSet, FilteredPathSet from xpybuild.buildcontext import getBuildInitializationContext from xpybuild.utils.buildexceptions import BuildException from xpybuild.utils.outputhandler import ProcessOutputHandler from xpybuild.utils.fileutils import mkdir import logging, re defineOption('csharp.compiler', "") defineOption('csharp.options', []) class CSCProcessOutputHandler(ProcessOutputHandler): """ A ProcessOutputHandler that can parse the output of the CSC compiler. """ def _parseLocationFromLine(self, line): m = re.match("(.*)[(](\d+)(,\d+)?[)]: (.*)", line) # allow line,col if m: return m.group(1), m.group(2), m.group(3)[1:] if m.group( 3) else None, m.group(4) + ' - ' + m.group(1) else: return None, None, None, line
from xpybuild.buildcommon import * from xpybuild.basetarget import BaseTarget, targetNameToUniqueId from xpybuild.propertysupport import defineOption from xpybuild.pathsets import PathSet, FilteredPathSet, BasePathSet from xpybuild.utils.fileutils import mkdir, deleteDir, openForWrite, normLongPath from xpybuild.utils.java import jar, javac, create_manifest, javadoc, signjar from xpybuild.utils.flatten import flatten from xpybuild.utils.outputhandler import ProcessOutputHandler from xpybuild.utils.buildexceptions import BuildException import logging import zipfile import collections # Options specific to this target defineOption('jar.manifest.classpathAppend', []) defineOption('javac.logs', '${BUILD_WORK_DIR}/javac_logs') def _isJavaFile(p): return p.lower().endswith('.java') class SignJars(BaseTarget): """ Copy jars into a target directory and sign them with the supplied keystore, optionally also updating their manifests. Additional command line arguments can be passed to ``signjars`` using the option ``jarsigner.options`` (default ``[]``). """ def __init__(self, output, jars, keystore, alias=None, storepass=None, manifestDefaults=None): """ @param output: The output directory in which to put the signed jars @param jars: The list (or PathSet) of input jars to copy and sign