Esempio n. 1
0
import os, inspect

from buildcommon import *
from basetarget import BaseTarget
from propertysupport import defineOption
from utils.process import call
from pathsets import PathSet, FilteredPathSet
from buildcontext import getBuildInitializationContext
from buildexceptions import BuildException
from utils.outputhandler import ProcessOutputHandler
from utils.fileutils import mkdir

import logging, re

defineOption('csharp.compiler', "")
defineOption('csharp.options', [])

class CSCProcessOutputHandler(ProcessOutputHandler):
	"""
	A ProcessOutputHandler than 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

# functor or constructor taking a process name and returning a new 
Esempio n. 2
0
import os, sys, re, subprocess
from buildcommon import *
from propertysupport import defineOption
from utils.process import call
from utils.outputhandler import ProcessOutputHandler
from utils.flatten import getStringList
from fileutils import deleteDir, mkdir, deleteFile, openForWrite, normLongPath
from utils.consoleformatter import publishArtifact

from 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.

	path: The path in which to create a manifest file

	properties: A map of manifest keys to values

	options: The options to use for creating the manifest (prefix: jar.manifest)

	>>> create_manifest(None, {"Class-path":"foo.jar", "Implementation-name":"Progress Apama"}, {'jar.manifest.defaults':[]}).replace('\\r\\n','\\n')
	'Class-path: foo.jar\\nImplementation-name: Progress Apama\\n'
Esempio n. 3
0
from buildcommon import *
from basetarget import BaseTarget, targetNameToUniqueId
from propertysupport import defineOption
from pathsets import PathSet, FilteredPathSet, BasePathSet
from utils.fileutils import mkdir, deleteDir, openForWrite, normLongPath
from utils.java import jar, javac, create_manifest, javadoc, signjar
from utils.flatten import flatten
from utils.outputhandler import ProcessOutputHandler
from 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
	"""
    def __init__(self,
                 output,
                 jars,
                 keystore,
                 alias=None,
Esempio n. 4
0
import os, inspect, re, string, time

from buildcommon import *
from basetarget import BaseTarget
from propertysupport import defineOption
from utils.process import call
from pathsets import PathSet, BasePathSet
from buildcontext import getBuildInitializationContext
from buildexceptions import BuildException
from propertyfunctors import make_functor, Composable
from utils.fileutils import openForWrite, mkdir, deleteFile, getmtime, exists, normLongPath

class __CompilersNotSpecified(object):
	def __getattr__(self, attr):
		raise Exception('Cannot use native targets until a compiler is configured by setting the native.compilers option')
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', [])
defineOption('native.link.flags', [])

if isWindows():
	defineOption('native.cxx.exenamefn', FilenameStringFormatter("%s.exe"))
	defineOption('native.cxx.libnamefn', FilenameStringFormatter("%s.dll"))
	defineOption('native.cxx.staticlibnamefn', FilenameStringFormatter("%s.lib"))
	defineOption('native.cxx.objnamefn', FilenameStringFormatter("%s.obj"))
else:
	defineOption('native.cxx.exenamefn', FilenameStringFormatter("%s"))
Esempio n. 5
0
import os, inspect

from buildcommon import *
from basetarget import BaseTarget
from propertysupport import defineOption
from utils.process import call
from pathsets import PathSet, FilteredPathSet
from buildcontext import getBuildInitializationContext
from buildexceptions import BuildException
from utils.outputhandler import ProcessOutputHandler
from utils.fileutils import mkdir

import logging, re

defineOption('csharp.compiler', "")
defineOption('csharp.options', [])


class CSCProcessOutputHandler(ProcessOutputHandler):
    """
	A ProcessOutputHandler than 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
Esempio n. 6
0
		"""
		Compiler.__init__(self, environs=environs)
		self.compiler_command = command
		self.compiler_handler = outputHandler or ProcessOutputHandler

	def compile(self, context, output, src, options, flags=None, 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
Esempio n. 7
0
from buildcommon import *
from propertysupport import defineOption
from utils.process import call
from utils.outputhandler import ProcessOutputHandler
from utils.flatten import getStringList
from fileutils import deleteDir, mkdir, deleteFile, openForWrite, normLongPath
from utils.consoleformatter import publishArtifact

from 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.

	path: The path in which to create a manifest file

	properties: A map of manifest keys to values

	options: The options to use for creating the manifest (prefix: jar.manifest)

	>>> create_manifest(None, {"Class-path":"foo.jar", "Implementation-name":"Progress Apama"}, {'jar.manifest.defaults':[]}).replace('\\r\\n','\\n')
Esempio n. 8
0
#

import os, inspect, re, string, time

from buildcommon import *
from basetarget import BaseTarget
from propertysupport import defineOption
from utils.process import call
from pathsets import PathSet, BasePathSet
from buildcontext import getBuildInitializationContext
from buildexceptions import BuildException
from propertyfunctors import make_functor, Composable
from utils.compilers import DefaultCompilers
from utils.fileutils import openForWrite, mkdir, deleteFile, getmtime, exists, normLongPath

defineOption('native.compilers', DefaultCompilers())
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', [])
defineOption('native.link.flags', [])

if isWindows():
	defineOption('native.cxx.exenamefn', FilenameStringFormatter("%s.exe"))
	defineOption('native.cxx.libnamefn', FilenameStringFormatter("%s.dll"))
	defineOption('native.cxx.staticlibnamefn', FilenameStringFormatter("%s.lib"))
	defineOption('native.cxx.objnamefn', FilenameStringFormatter("%s.obj"))
else:
	defineOption('native.cxx.exenamefn', FilenameStringFormatter("%s"))
Esempio n. 9
0
                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
Esempio n. 10
0
        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.encode("UTF-8") + os.linesep)

    def handleEnd(self, returnCode=None):
        ProcessOutputHandler.handleEnd(self, returnCode)


defineOption(ProcessOutputHandler.Options.ignoreReturnCode, False)
defineOption(ProcessOutputHandler.Options.regexIgnore, None)
defineOption(ProcessOutputHandler.Options.factory, ProcessOutputHandler)
Esempio n. 11
0
from buildcommon import *
from basetarget import BaseTarget, targetNameToUniqueId
from propertysupport import defineOption
from pathsets import PathSet, FilteredPathSet, BasePathSet
from utils.fileutils import mkdir, deleteDir, openForWrite, normLongPath
from utils.java import jar, javac, create_manifest, javadoc, signjar
from utils.flatten import flatten
from utils.outputhandler import ProcessOutputHandler
from 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
	"""
	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
Esempio n. 12
0
import os, inspect

from buildcommon import *
from basetarget import BaseTarget
from propertysupport import defineOption
from utils.process import call
from pathsets import PathSet, FilteredPathSet
from buildcontext import getBuildInitializationContext
from buildexceptions import BuildException
from utils.outputhandler import ProcessOutputHandler
from utils.fileutils import mkdir

import logging, re

defineOption('csharp.compiler', "")
defineOption('csharp.options', [])

class CSCProcessOutputHandler(ProcessOutputHandler):
	"""
	A ProcessOutputHandler than 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

# functor or constructor taking a process name and returning a new