def __init__(self, bin, objects, libs=None, libpaths=None, shared=False, options=None, flags=None, dependencies=None): """ @param bin: the output binary @param objects: a (list of) input object @param libs: a (list of) libraries linked against (optional) in platform-neutral format. Can include list properties like '${FOO_LIB_NAMES[]}'. @param libpaths: a (list of) additional library search directories (optional) @param shared: if true compiles to a shared object (.dll or .so) (optional, defaults to false) @param flags: a list of additional linker flags @param options: [DEPRECATED - use .option() instead] @param dependencies: a list of additional dependencies (targets or files) """ self.objects = PathSet(objects) self.libs = libs or [] self.libpaths = PathSet(libpaths or []) self.shared=shared self.flags = flags or [] BaseTarget.__init__(self, bin, PathSet(self.objects, (dependencies or []))) for k,v in (options or {}).items(): self.option(k, v) self.tags('native')
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 @param keystore: The path to the keystore @param alias: The alias for the keystore (optional) @param storepass: The password for the store file (optional) @param manifestDefaults: a dictionary of manifest entries to add to the existing manifest.mf file of each jar before signing. Entries in this dictionary will be ignored if the same entry is found in the original manifest.mf file already. """ self.jars = PathSet(jars) self.keystore = keystore self.alias = alias self.storepass = storepass self.manifestDefaults = manifestDefaults BaseTarget.__init__(self, output, [self.jars, self.keystore])
def __init__(self, bin, objects, libs=None, libpaths=None, shared=False, options=None, flags=None, dependencies=None): """ @param bin: the output binary @param objects: a (list of) input object @param libs: a (list of) libraries linked against (optional) in platform-neutral format. Can include list properties like '${FOO_LIB_NAMES[]}'. @param libpaths: a (list of) additional library search directories (optional) @param shared: if true compiles to a shared object (.dll or .so) (optional, defaults to false) @param flags: a list of additional linker flags @param options: a map of options to the underlying operation specific to this target (optional) @param dependencies: a list of additional dependencies (targets or files) """ self.objects = PathSet(objects) self.libs = libs or [] self.libpaths = PathSet(libpaths or []) self.shared=shared self.options = options self.flags = flags or [] BaseTarget.__init__(self, bin, PathSet(self.objects, (dependencies or []))) self.tags('native')
def __init__(self, object, source, includes=None, flags=None, options=None, dependencies=None): """ @param object: the object file to generate @param source: a (list of) source files @param includes: a (list of) include directories @param flags: a list of additional compiler flags @param dependencies: a list of additional dependencies that need to be built before this target @param options: [DEPRECATED - use .option() instead] """ self.source = PathSet(source) self.includes = PathSet(includes or []) self.flags = flags or [] self.makedepend = CompilerMakeDependsPathSet(self, self.source, flags=self.flags, includes=self.includes) BaseTarget.__init__(self, object, [dependencies or [], self.makedepend]) for k, v in (options or {}).items(): self.option(k, v) self.tags('native')
def __init__(self, dest, archives): """ @param dest: the output directory (ending with a "/"). Never specify a dest directory that is also written to by another target (e.g. do not specify a build 'output' directory here). @param archives: the input archives to be unpacked, which may be any combination of strings, PathSets, FilteredArchiveContents and lists of these. If these PathSets include mapping information, this will be used to define where (under the dest directory) each file from within that archive is copied (but cannot be used to change the archive-relative path of each item). For advanced cases, FilteredArchiveContents can be used to provide customized mapping and filtering of the archive contents, including manipulation of the destinations encoded within the archive itself. """ if not dest.endswith('/'): raise BuildException('Unpack target destination must be a directory (ending with "/"), not: "%s"'%dest) # NB: we could also support copying in non-archived files into the directory future too # we should preserve the specified order of archives since it may # affect what happens when they contain the same files and must # overwrite each other archives = [a if (isinstance(a, BasePathSet) or isinstance(a, FilteredArchiveContents)) else PathSet(a) for a in flatten(archives)] BaseTarget.__init__(self, dest, [ (a.getDependency() if isinstance(a, FilteredArchiveContents) else a) for a in archives]) self.archives = archives
def __init__(self, jar, compile, classpath, manifest, options=None, package=None, preserveManifestFormatting=False): """ @param jar: path to jar to create @param compile: PathSet (or list) of things to compile @param classpath: PathSet (or list) of things to be on the classpath; destination mapping indicates how they will appear in the manifest @param manifest: map of manifest entries, OR a string with the filename to use OR None to disable manifest generation and just produce a normal zip @param options: generic target options map @param package: PathSet (or list) of other files to include in the jar; destination mapping indicates where they will appear in the jar @param preserveManifestFormatting: an advanced option that prevents the jar tool from reformatting the specified manifest file to comply with Java conventions (also prevents manifest merging if jar already exists) """ self.compile = FilteredPathSet(_isJavaFile, PathSet(compile)) if compile else None self.classpath = PathSet(classpath) self.package = PathSet(package) self.manifest = manifest BaseTarget.__init__(self, jar, [self.compile,self.classpath,self.package, manifest if isinstance(manifest, basestring) else None]) self.options = options self.preserveManifestFormatting = preserveManifestFormatting
def __init__(self, output, compile, main=None, libs=None, flags=None, dependencies=None, resources=None): """ @param output: the resulting .exe or .dll @param compile: the input PathSet, path or list of .cs file(s) @param main: The main class to execute if an exe is to be built. If this is set then an executable will be created. Otherwise this target will build a library. @param libs: a list of input libraries (or a PathSet) """ self.compile = FilteredPathSet(_isDotNetFile, PathSet(compile)) self.main = main self.flags = flags or [] self.libs = PathSet(libs or []) self.resources = resources or [] BaseTarget.__init__(self, output, [ self.compile, self.libs, [x for (x, y) in self.resources], dependencies or [] ]) self.tags('c#')
def __init__(self, archive, inputs): """ archive: the archive to be created inputs: the files (usually pathsets) to be included in the archive. """ self.inputs = PathSet(inputs) BaseTarget.__init__(self, archive, self.inputs)
def __init__(self, bin, objects): """ @param bin: the output library @param objects: a (list of) input objects """ self.objects = PathSet(objects) BaseTarget.__init__(self, bin, self.objects) self.tags('native')
def __init__(self, imagename, inputs, depimage=None, dockerfile=None, buildArgs=None): """ imagename: the name/tag of the image to build """ self.imagename = imagename self.depimage = depimage self.dockerfile = dockerfile self.buildArgs = buildArgs self.stampfile = '${BUILD_WORK_DIR}/targets/docker/.%s' % re.sub(r'[\\/]', '_', imagename) self.depstampfile = '${BUILD_WORK_DIR}/targets/docker/.%s' % re.sub(r'[\\/]', '_', depimage) if depimage else None self.inputs = PathSet(inputs) BaseTarget.__init__(self, self.stampfile, inputs + ([self.depstampfile] if self.depstampfile else []))
def __init__(self, imagename, mode, inputs, depimage=None, dockerfile=None, buildArgs=None): """ imagename: the name/tag of the image to build """ self.imagename = imagename self.depimage = depimage self.mode = mode self.dockerfile = dockerfile self.buildArgs = buildArgs self.stampfile = '${BUILD_WORK_DIR}/targets/docker/.%s' % re.sub(r'[\\/]', '_', imagename) self.depstampfile = '${BUILD_WORK_DIR}/targets/docker/.%s' % re.sub(r'[\\/]', '_', depimage) if depimage else None self.inputs = PathSet(inputs) BaseTarget.__init__(self, self.stampfile, inputs + ([self.depstampfile] if self.depstampfile else []))
def __init__(self, destdir, source, classpath, options): """ @param destdir: directory to create docs in @param source: a set of files to build from @param classpath: a list of jars needed for the classpath @param options: javadoc.-prefixed options map """ self.sources = PathSet(source) self.classpath = PathSet(classpath) BaseTarget.__init__(self, destdir, [self.sources, self.classpath]) self.options = options
def __init__(self, target, deps, fn, cleanfn=None): """ @param target: The target file/directory that will be built @param deps: The list of dependencies of this target (paths, pathsets or lists) @param fn: The functor used to build this target @param cleanfn: The functor used to clean this target (optional, defaults to removing the target file/dir) """ BaseTarget.__init__(self, target, deps) self.fn = fn self.cleanfn = cleanfn self.deps = PathSet(deps)
def __init__(self, destdir, source, classpath, options): """ @param destdir: directory to create docs in @param source: a set of files to build from @param classpath: a list of jars needed for the classpath @param options: [DEPRECATED - use .option() instead] """ self.sources = PathSet(source) self.classpath = PathSet(classpath) BaseTarget.__init__(self, destdir, [self.sources, self.classpath]) for k, v in (options or {}).items(): self.option(k, v)
def __init__(self, jar, compile, classpath, manifest, options=None, package=None, preserveManifestFormatting=False): """ To add additional entries to the manifest's classpath which are needed at runtime but not during compilation, use .option('jar.manifest.classpathAppend', [...]) @param jar: path to jar to create @param compile: PathSet (or list) of things to compile @param classpath: PathSet (or list) of things to be on the classpath; destination mapping indicates how they will appear in the manifest @param manifest: map of manifest entries, OR a string with the filename to use OR None to disable manifest generation and just produce a normal zip @param options: [DEPRECATED - use .option() instead] @param package: PathSet (or list) of other files to include in the jar; destination mapping indicates where they will appear in the jar @param preserveManifestFormatting: an advanced option that prevents the jar tool from reformatting the specified manifest file to comply with Java conventions (also prevents manifest merging if jar already exists) """ self.compile = FilteredPathSet(_isJavaFile, PathSet(compile)) if compile else None self.classpath = PathSet(classpath) self.package = PathSet(package) self.manifest = manifest BaseTarget.__init__(self, jar, [ self.compile, self.classpath, self.package, manifest if isinstance(manifest, basestring) else None ]) for k, v in (options or {}).items(): self.option(k, v) self.preserveManifestFormatting = preserveManifestFormatting
def __init__(self, name, getContents, dependencies=None, mode=None, executable=False, args=None, kwargs=None): """ Constructor. @param name: the output filename @param getContents: a string (which will be subject to expansion) or a function that accepts a context as input followed optionally by any specified 'args') and returns the string that should be written to the file. The file is written in binary mode, but any occurrences of the newline character \\n in the provided string will be replaced automatically with the OS-specific line separator. The function will be evaluated during the dependency resolution phase. @param mode: unix permissions to set with chmod on the destination files. If not specified, default mode is used. Ignored on Windows platforms. @param executable: set to True to add Unix executable permissions (simpler alternative to setting using mode) @param args: optional tuple containing arguments that should be passed to the getContents function, after the context argument (first arg) @param kwargs: optional dictionary containing kwargs that should be passed to the getContents function. @param dependencies: any targets which need to be built in order to run this target """ BaseTarget.__init__(self, name, dependencies or []) self.getContents = getContents self.__args = args or () self.__kwargs = kwargs or {} self.__resolved = None self.__mode = mode self.__executable = executable
def __init__(self, object, source, includes=None, flags=None, options=None, dependencies=None): """ @param object: the object file to generate @param source: a (list of) source files @param includes: a (list of) include directories @param flags: a list of additional compiler flags @param dependencies: a list of additional dependencies that need to be built before this target """ self.source = PathSet(source) self.includes = PathSet(includes or []) self.flags = flags or [] self.makedepend = CompilerMakeDependsPathSet(self, self.source, flags=self.flags, includes=self.includes) BaseTarget.__init__(self, object, [dependencies or [], self.makedepend]) self.options = options or {} self.tags('native')
def __init__(self, output, compile, classpath, options=None): """ @param output: output dir for class files @param compile: PathSet (or list) of things to compile @param classpath: PathSet (or list) of things to be on the classpath; @param options: generic target options map for passing options to the underlying operation (optional) """ self.compile = FilteredPathSet(_isJavaFile, PathSet(compile)) self.classpath = PathSet(classpath) BaseTarget.__init__(self, output, [self.compile,self.classpath]) self.options = options
def __init__(self, output, compile, classpath, options=None): """ @param output: output dir for class files @param compile: PathSet (or list) of things to compile @param classpath: PathSet (or list) of things to be on the classpath; @param options: [DEPRECATED - use .option() instead] """ self.compile = FilteredPathSet(_isJavaFile, PathSet(compile)) self.classpath = PathSet(classpath) BaseTarget.__init__(self, output, [self.compile, self.classpath]) for k, v in (options or {}).items(): self.option(k, v)
def __init__(self, output, compile, main=None, libs=None, flags=None, dependencies=None, resources=None): """ @param output: the resulting .exe or .dll @param compile: the input PathSet, path or list of .cs file(s) @param main: The main class to execute if an exe is to be built. If this is set then an executable will be created. Otherwise this target will build a library. @param libs: a list of input libraries (or a PathSet) """ self.compile = FilteredPathSet(_isDotNetFile, PathSet(compile)) self.main = main self.flags = flags or [] self.libs = PathSet(libs or []) self.resources = resources or [] BaseTarget.__init__(self, output, [self.compile, self.libs, [x for (x, y) in self.resources], dependencies or []]) self.tags('c#')
def __init__(self, dest, src, relative=True): """ dest: the link to be created src: what it points at """ if isinstance(dest, basestring) and dest.endswith('/'): raise BuildException( 'SymLink target can only be used for files, not directories' ) # for now if not hasattr(os, 'symlink'): raise BuildException( 'SymLink target is not supported on this platform') self.src = PathSet(src) self.relative = relative BaseTarget.__init__(self, dest, [self.src]) # technically we don't need to depend on the contents of src at all, # but in practice it might be useful to have other targets depending on the # link in which case it's a good idea to recreate the link when the # thing it points to is rebuild - and it's a very quick operation anyway self.tags('native')
def __init__(self, dest, archives): """ @param dest: the output directory (ending with a "/"). Never specify a dest directory that is also written to by another target (e.g. do not specify a build 'output' directory here). @param archives: the input archives to be unpacked, which may be any combination of strings, PathSets, FilteredArchiveContents and lists of these. If these PathSets include mapping information, this will be used to define where (under the dest directory) each file from within that archive is copied (but cannot be used to change the archive-relative path of each item). For advanced cases, FilteredArchiveContents can be used to provide customized mapping and filtering of the archive contents, including manipulation of the destinations encoded within the archive itself. """ if not dest.endswith('/'): raise BuildException( 'Unpack target destination must be a directory (ending with "/"), not: "%s"' % dest) # NB: we could also support copying in non-archived files into the directory future too # we should preserve the specified order of archives since it may # affect what happens when they contain the same files and must # overwrite each other archives = [ a if (isinstance(a, BasePathSet) or isinstance(a, FilteredArchiveContents)) else PathSet(a) for a in flatten(archives) ] BaseTarget.__init__(self, dest, [(a.getDependency() if isinstance( a, FilteredArchiveContents) else a) for a in archives]) self.archives = archives
def __init__(self, dest, src, mode=None, implicitDependencies=None): """ @param dest: the output directory (ending with a "/") or file. Never specify a dest directory that is also written to by another target (e.g. do not specify an output directory here). If you need to write multiple files to a directory, use separate Copy targets for each, with file (rather than directory) target dest names. @param src: the input, which may be any combination of strings, PathSets and lists of these. If these PathSets include mapping information, this will be used to define where (under the dest directory) each file is copied. Note that only src files will be copied, any directory in the src list will be created but its contents will not be copied across - the only way to copy a directory is to use a FindPaths (or FindPaths(DirGeneratedByTarget('...'))) for the src, which has the ability to find its contents on disk (this is necessary to prevent complex race conditions and build errors arising from implicit directory walking during the execution phase - if all dir walking happens during dependency resolution then such errors can be easily detected before they cause a problem). @param mode: unix permissions to set with chmod on the destination files. If not specified, mode is simply copied from source file. @param implicitDependencies: provides a way to add additional implicit dependencies that will not be part of src but may affect the copy process (e.g. filtering in); this is intended for use by subclasses, do not set this explicitly. """ if mode: raise Exception(dest) src = PathSet(src) BaseTarget.__init__(self, dest, [src, implicitDependencies]) self.src = src self.mode = mode
def __init__(self, name): """ name: the output filename """ BaseTarget.__init__(self, name, [])
def __init__(self, target, command, dependencies, cwd=None, redirectStdOutToTarget=False, env=None, stdout=None, stderr=None): """ The command line MUST not reference any generated paths unless they are explicitly listed in deps. @param target: the file or directory to be built. Will be cleaned, and its parent dir created, before target runs. @param dependencies: an optional list of dependencies; it is essential that ALL dependencies generated by the build process are explicitly listed here @param command: a function or a list. If command is a list, items may be: - a string (which will be run through expandPropertyValues prior to execution); must not be used for representing arguments that are paths - a PathSet (which must resolve to exactly one path - see joinPaths property functor if multiple paths are required) - a property functor such as joinPaths (useful for constructing Java classpaths), basename, etc - an arbitrary function taking a single context argument - CustomCommand.TARGET - a special value that is resolved to the output path of this target - CustomCommand.DEPENDENCIES - a special value that is resolved to a list of this target's dependencies - [deprecated] a ResolvePath(path) object, indicating a path that should be resolved and resolved at execution time (this is equivalent to using a PathSet, which is probably a better approach). If command is a function, must have signature (resolvedTargetDirPath, resolvedDepsList, context), and return the command line as a list of strings. resolvedDepsList will be an ordered, flattened list of resolved paths from deps. Command lines MUST NOT depend in any way on the current source or output directory, always use a PathSet wrapper around such paths. @param cwd: the working directory to run it from (almost always this should be left blank, meaning use output dir) @param env: a dictionary of environment overrides, or a function that returns one given a context. Values in the dictionary will be expanded using the same rules as for the command (see above). Consider using propertyfunctors.joinPaths for environment variables containing a list of paths. @param redirectStdOutToTarget: usually, any stdout is treated as logging and the command is assumed to create the target file itself, but set this to True for commands where the target file contents are generated by the stdout of the command being executed. @param stdout: usually a unique name is auto-generated for .out for this target, but use this if requried to send output to a specific location. @param stderr: usually a unique name is auto-generated for .err for this target, but use this if requried to send output to a specific location. """ BaseTarget.__init__(self, target, dependencies) self.command = command self.cwd = cwd self.deps = PathSet(dependencies) self.redirectStdOutToTarget = redirectStdOutToTarget if redirectStdOutToTarget and isDirPath(target): raise BuildException('Cannot set redirectStdOutToTarget and specify a directory for the target name - please specify a file instead: %s'%target) self.env = env self.stdout, self.stderr = stdout, stderr if stdout and redirectStdOutToTarget: raise BuildException('Cannot set both redirectStdOutToTarget and stdout')
def __init__(self, target, command, dependencies, cwd=None, redirectStdOutToTarget=False, env=None, stdout=None, stderr=None): """ The command line MUST not reference any generated paths unless they are explicitly listed in deps. Use .option("process.timeout") to control the maximum number of seconds the command can run before being cancelled. @param target: the file or directory to be built. Will be cleaned, and its parent dir created, before target runs. @param dependencies: an optional list of dependencies; it is essential that ALL dependencies required by this command and generated by the build processare explicitly listed here, in addition to any files/directories used by this command that might change between builds. @param command: a function or a list. If command is a list, items may be: - a string (which will be run through expandPropertyValues prior to execution); must not be used for representing arguments that are paths - a PathSet (which must resolve to exactly one path - see joinPaths property functor if multiple paths are required). Any PathSets used in the arguments should usually be explicitly listed in dependencies too, especially if they are generated by another part of this build. - a property functor such as joinPaths (useful for constructing Java classpaths), basename, etc - an arbitrary function taking a single context argument - CustomCommand.TARGET - a special value that is resolved to the output path of this target - CustomCommand.DEPENDENCIES - a special value that is resolved to a list of this target's dependencies - [deprecated] a ResolvePath(path) object, indicating a path that should be resolved and resolved at execution time (this is equivalent to using a PathSet, which is probably a better approach). If command is a function, must have signature (resolvedTargetDirPath, resolvedDepsList, context), and return the command line as a list of strings. resolvedDepsList will be an ordered, flattened list of resolved paths from deps. Command lines MUST NOT depend in any way on the current source or output directory, always use a PathSet wrapper around such paths. @param cwd: the working directory to run it from (almost always this should be left blank, meaning use output dir) @param env: a dictionary of environment overrides, or a function that returns one given a context. Values in the dictionary will be expanded using the same rules as for the command (see above). Consider using propertyfunctors.joinPaths for environment variables containing a list of paths. @param redirectStdOutToTarget: usually, any stdout is treated as logging and the command is assumed to create the target file itself, but set this to True for commands where the target file contents are generated by the stdout of the command being executed. @param stdout: usually a unique name is auto-generated for .out for this target, but use this if required to send output to a specific location. @param stderr: usually a unique name is auto-generated for .err for this target, but use this if required to send output to a specific location. """ BaseTarget.__init__(self, target, dependencies) self.command = command self.cwd = cwd self.deps = PathSet(dependencies) self.redirectStdOutToTarget = redirectStdOutToTarget if redirectStdOutToTarget and isDirPath(target): raise BuildException( 'Cannot set redirectStdOutToTarget and specify a directory for the target name - please specify a file instead: %s' % target) self.env = env self.stdout, self.stderr = stdout, stderr if stdout and redirectStdOutToTarget: raise BuildException( 'Cannot set both redirectStdOutToTarget and stdout')