Beispiel #1
0
    def __init__(self,
                 target,
                 command=None,
                 dependencies=[],
                 cwd=None,
                 redirectStdOutToTarget=False,
                 env=None,
                 stdout=None,
                 stderr=None,
                 commands=None):
        BaseTarget.__init__(self, target, dependencies)

        assert not (command
                    and commands), 'Cannot specify both command= and commands='
        self.command = command
        self.commands = commands
        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')
Beispiel #2
0
    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#')
Beispiel #3
0
    def __init__(self, name, time, dependencies=None):
        """
		name: the output filename
		time: the length of time to sleep (in seconds)
		"""
        BaseTarget.__init__(self, name, dependencies or [])
        self.time = float(time)
Beispiel #4
0
	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
Beispiel #5
0
	def __init__(self, archive, inputs):
		"""
		@param archive: The archive to be created, ending with ``.zip``. 

		@param inputs: The files (usually pathsets) to be included in the archive.

		"""
		self.inputs = PathSet(inputs)
		BaseTarget.__init__(self, archive, self.inputs)
Beispiel #6
0
    def __init__(self,
                 name,
                 getContents,
                 dependencies=None,
                 mode=None,
                 executable=False,
                 encoding=None,
                 args=None,
                 kwargs=None):
        """
		Example usage:: 
		
			WriteFile('${OUTPUT_DIR}/foo.txt', lambda context: '\\n'.join(['Foo:', context.expandPropertyValues('${FOO}')]))
		
		@param name: the output filename
		
		@param getContents: 
			a unicode character string (which will be subject to expansion), 
			or binary bytes, or a function that accepts a context as input 
			followed optionally by any specified 'args') and returns 
			the string/bytes that should be written to the file, using ``\\n`` for newlines 
			(not ``os.linesep`` - any occurrences of the newline character ``\\n`` in 
			the provided string will be replaced automatically with the 
			OS-specific line separator unless bytes are provided).
			
			The function will be evaluated during the dependency resolution 
			phase (before the build phase commences). 
			
		@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 encoding: The encoding to use for converting the str to bytes; 
			if not specified the ``common.fileEncodingDecider`` option is used. 

		@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
        self.__encoding = encoding
        self.addHashableImplicitInputOption('common.fileEncodingDecider')
Beispiel #7
0
    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')
Beispiel #8
0
	def __init__(self, jar, compile, classpath, manifest, options=None, package=None, preserveManifestFormatting=False):
		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, str) else None])
			
		for k,v in (options or {}).items(): self.option(k, v)
		self.preserveManifestFormatting = preserveManifestFormatting
Beispiel #9
0
    def __init__(self,
                 object,
                 source,
                 includes=None,
                 flags=None,
                 dependencies=None,
                 options=None):
        """
		@param object: the object file to generate; see L{objectname}.
		@param source: a (list of) source files
		
		@param includes: a (list of) include directories, as strings or PathSets, 
			each with a trailing slash; the directories in the `native.include` 
			option are also added.
			
			If this target depends on some include files that are generated by another target, 
			make sure it's a directory target since all include directories must either 
			exist before the build starts or be targets themselves. 
			If specifying a subdirectory of a generated directory, do this using DirGeneratedByTarget. 
			If you have a composite generated directory made up of several 
			file targets, wrap them in TargetsWithinDir before passing as the includes parameter. 
		
		@param flags: a list of compiler flags in addition to those in the 
			`native.cxx.flags`/`native.c.flags` option. 
		
		@param dependencies: a list of additional dependencies that need to be built 
			before this target. Usually this is not needed. 
		
		@param options: DEPRECATED; use .option() instead
		"""
        self.source = PathSet(source)

        # currently we don't bother adding the native include dirs here as they're probably always going to be there
        # for time being, explicitly cope with missing slashes, though really build authors should avoid this
        self.includes = _AddTrailingDirectorySlashesPathSet(PathSet(includes))
        self.flags = flatten([flags]) or []

        # nb: do not include any individual header files in main target deps even if we've already
        # got cached makedepends from a previous build,
        # because it's possible they are no longer needed and no longer exist (and we don't want spurious
        # build failures); this also has the advantage that it doesn't enlarge and slow down the stat cache
        # during dep resolution of non-native targets, since it'll only be populated once we're into
        # the up to date checking phase

        BaseTarget.__init__(self, object,
                            PathSet([dependencies, source, self.includes]))

        for k, v in (options or {}).items():
            self.option(k, v)
        self.tags('native')
Beispiel #10
0
	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)
Beispiel #11
0
    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)
Beispiel #12
0
	def __init__(self, dest, src, relative=True):
		"""
		dest: the link to be created
		src: what it points at
		"""
		if isinstance(dest, str) 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')
Beispiel #13
0
	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])
		if options is not None:
			for k,v in options.items(): self.option(k, v)
Beispiel #14
0
    def __init__(self, dest, src, 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). 
		
		To create new empty directories that are not present in the source (mkdir), 
		you can use this simple trick which utilizes the fact that the current 
		directory ``.`` definitely exists. It doesn't copy anything from inside 
		(just copies only its 'existence') and uses a SingletonDestRenameMapper PathSet 
		to provide the destination::
		
			SingletonDestRenameMapper('my-new-dest-directory/', './'),
		
		@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. 
		"""
        src = PathSet(src)
        BaseTarget.__init__(self, dest, [src, implicitDependencies])
        self.src = src
        self.mode = None  # not yet supported, but may be if it turns out to be useful
        self.addHashableImplicitInputOption('Copy.symlinks')
Beispiel #15
0
	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])
Beispiel #16
0
    def __init__(self,
                 bin,
                 objects,
                 libs=None,
                 libpaths=None,
                 shared=False,
                 options=None,
                 flags=None,
                 dependencies=None):
        """
		@param bin: the output binary. See L{exename}, L{libname}, L{staticlibname}. 

		@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')
Beispiel #17
0
    def __init__(self,
                 imagename,
                 inputs,
                 depimage=None,
                 dockerfile=None,
                 buildArgs=None,
                 dockerArgs=None):
        """
		imagename: the name/tag of the image to build
		"""
        self.imagename = imagename
        self.depimage = depimage
        self.dockerfile = dockerfile
        self.buildArgs = buildArgs
        self.dockerArgs = dockerArgs
        self.stampfile = '${BUILD_WORK_DIR}/targets/docker/.%s' % self.imageNameToFileName(
            imagename)
        self.depstampfile = '${BUILD_WORK_DIR}/targets/docker/.%s' % self.imageNameToFileName(
            depimage) if depimage else None
        self.inputs = PathSet(inputs)
        BaseTarget.__init__(
            self, self.stampfile,
            inputs + ([self.depstampfile] if self.depstampfile else []))
Beispiel #18
0
    def __init__(self, path):
        """
		@param path: the output filename. 
		"""
        BaseTarget.__init__(self, path, [])