Beispiel #1
0
def apply_haxe(self):
    Utils.def_attrs(self,
        target="", classpath="", flags="", libs="", swflib=None);

    classpath = Utils.to_list(self.classpath)
    flags = Utils.to_list(self.flags)
    target = self.target;

    inputs = []
    outputs = [ self.path.get_bld().make_node(target) ]

    if target.endswith(".swf"):
        flags += ["-swf", target, "--flash-strict", "-D", "nativeTrace",
            "-swf-header", "640:480:60:ffffff"]
        if (self.swflib is not None):
            swflib = self.path.get_bld().make_node(self.swflib)
            inputs += [swflib]
            flags += ["-swf-lib", str(swflib)]
    elif target.endswith(".js"):
        if "-debug" in flags:
            outputs += [self.path.get_bld().make_node(target + ".map")]
        flags += ["-js", target, "--js-modern"]
    elif target.endswith(".n"):
        flags += ["-neko", target]
    else:
        raise "Unsupported target file type!"

    for lib in Utils.to_list(self.libs):
        flags += ["-lib", lib]

    task = self.create_task("haxe", inputs, outputs)
    task.classpath = classpath
    task.env.flags = flags
    self.haxe_task = task
Beispiel #2
0
def build_sphinx(self):
    """Builds sphinx sources.
    """
    if not self.env.SPHINX_BUILD:
        self.bld.fatal('Program SPHINX_BUILD not defined.')
    if not getattr(self, 'sphinx_source', None):
        self.bld.fatal('Attribute sphinx_source not defined.')
    if not isinstance(self.sphinx_source, Node):
        self.sphinx_source = self.path.find_node(self.sphinx_source)
    if not self.sphinx_source:
        self.bld.fatal('Can\'t find sphinx_source: %r' % self.sphinx_source)

    Utils.def_attrs(self, sphinx_output_format='html')
    self.env.SPHINX_OUTPUT_FORMAT = self.sphinx_output_format
    self.env.SPHINX_OPTIONS = getattr(self, 'sphinx_options', [])

    for source_file in self.sphinx_source.ant_glob('**/*'):
        self.bld.add_manual_dependency(self.sphinx_source, source_file)

    sphinx_build_task = self.create_task('SphinxBuildingTask')
    sphinx_build_task.set_inputs(self.sphinx_source)
    sphinx_build_task.set_outputs(self.path.get_bld())

    # the sphinx-build results are in <build + output_format> directory
    self.sphinx_output_directory = self.path.get_bld().make_node(
        self.env.SPHINX_OUTPUT_FORMAT)
    self.sphinx_output_directory.mkdir()
    Utils.def_attrs(self, install_path=get_install_path(self))
Beispiel #3
0
def apply_java(self):
	Utils.def_attrs(self,jarname='',classpath='',sourcepath='.',srcdir='.',jar_mf_attributes={},jar_mf_classpath=[])
	nodes_lst=[]
	outdir=getattr(self,'outdir',None)
	if outdir:
		if not isinstance(outdir,Node.Node):
			outdir=self.path.get_bld().make_node(self.outdir)
	else:
		outdir=self.path.get_bld()
	outdir.mkdir()
	self.env['OUTDIR']=outdir.abspath()
	self.javac_task=tsk=self.create_task('javac')
	tmp=[]
	srcdir=getattr(self,'srcdir','')
	if isinstance(srcdir,Node.Node):
		srcdir=[srcdir]
	for x in Utils.to_list(srcdir):
		if isinstance(x,Node.Node):
			y=x
		else:
			y=self.path.find_dir(x)
			if not y:
				self.bld.fatal('Could not find the folder %s from %s'%(x,self.path))
		tmp.append(y)
	tsk.srcdir=tmp
	if getattr(self,'compat',None):
		tsk.env.append_value('JAVACFLAGS',['-source',self.compat])
	if hasattr(self,'sourcepath'):
		fold=[isinstance(x,Node.Node)and x or self.path.find_dir(x)for x in self.to_list(self.sourcepath)]
		names=os.pathsep.join([x.srcpath()for x in fold])
	else:
		names=[x.srcpath()for x in tsk.srcdir]
	if names:
		tsk.env.append_value('JAVACFLAGS',['-sourcepath',names])
Beispiel #4
0
def apply_copy(self):
    Utils.def_attrs(self, fun=copy_func)
    self.default_install_path = 0

    lst = self.to_list(self.source)
    self.meths.remove("process_source")

    for filename in lst:
        node = self.path.find_resource(filename)
        if not node:
            raise Errors.WafError("cannot find input file %s for processing" % filename)

        target = self.target
        if not target or len(lst) > 1:
            target = node.name

        # TODO the file path may be incorrect
        newnode = self.path.find_or_declare(target)

        tsk = self.create_task("copy", node, newnode)
        tsk.fun = self.fun
        tsk.chmod = getattr(self, "chmod", Utils.O644)

        if not tsk.env:
            tsk.debug()
            raise Errors.WafError("task without an environment")
Beispiel #5
0
def apply_java(self):
    Utils.def_attrs(
        self, jarname="", classpath="", sourcepath=".", srcdir=".", jar_mf_attributes={}, jar_mf_classpath=[]
    )
    nodes_lst = []
    if not self.classpath:
        if not self.env["CLASSPATH"]:
            self.env["CLASSPATH"] = ".." + os.pathsep + "."
    else:
        self.env["CLASSPATH"] = self.classpath
    if isinstance(self.srcdir, self.path.__class__):
        srcdir_node = self.srcdir
    else:
        srcdir_node = self.path.find_dir(self.srcdir)
    if not srcdir_node:
        raise Errors.WafError("could not find srcdir %r" % self.srcdir)
    self.env["OUTDIR"] = [srcdir_node.get_src().srcpath()]
    self.javac_task = tsk = self.create_task("javac")
    tsk.srcdir = srcdir_node
    if getattr(self, "compat", None):
        tsk.env.append_value("JAVACFLAGS", ["-source", self.compat])
    if hasattr(self, "sourcepath"):
        fold = [
            isinstance(x, self.path.__class__) and x or self.path.find_dir(x) for x in self.to_list(self.sourcepath)
        ]
        names = os.pathsep.join([x.srcpath() for x in fold])
    else:
        names = srcdir_node.srcpath()
    if names:
        tsk.env.append_value("JAVACFLAGS", ["-sourcepath", names])
Beispiel #6
0
def init_cmd_output(self):
    Utils.def_attrs(
        self,
        stdin=None,
        stdout=None,
        stderr=None,
        # the command to execute
        command=None,
        # whether it is an external command; otherwise it is assumed
        # to be an executable binary or script that lives in the
        # source or build tree.
        command_is_external=False,
        # extra parameters (argv) to pass to the command (excluding
        # the command itself)
        argv=[],
        # dependencies to other objects -> this is probably not what you want (ita)
        # values must be 'task_gen' instances (not names!)
        dependencies=[],
        # dependencies on env variable contents
        dep_vars=[],
        # input files that are implicit, i.e. they are not
        # stdin, nor are they mentioned explicitly in argv
        hidden_inputs=[],
        # output files that are implicit, i.e. they are not
        # stdout, nor are they mentioned explicitly in argv
        hidden_outputs=[],
        # change the subprocess to this cwd (must use obj.input_dir() or output_dir() here)
        cwd=None,
        # OS environment variables to pass to the subprocess
        # if None, use the default environment variables unchanged
        os_env=None,
    )
Beispiel #7
0
def apply_haxe(self):
    Utils.def_attrs(self,
        target="", classpath="", flags="", libs="", swflib=None);

    classpath = Utils.to_list(self.classpath)
    flags = Utils.to_list(self.flags)
    target = self.target;

    inputs = []

    if target.endswith(".swf"):
        flags += ["-swf", target, "--flash-strict", "-D", "nativeTrace"]
        if (self.swflib is not None):
            swflib = self.path.get_bld().make_node(self.swflib)
            inputs += [swflib]
            flags += ["-swf-lib", str(swflib)]
    elif target.endswith(".js"):
        flags += ["-js", target]
    elif target.endswith(".n"):
        flags += ["-neko", target]
    else:
        raise "Unsupported target file type!"

    for lib in Utils.to_list(self.libs):
        flags += ["-lib", lib]

    task = self.create_task("haxe", inputs, self.path.get_bld().make_node(target))
    task.classpath = [self.path.find_node(cp) for cp in classpath]
    task.env.flags = flags
    self.haxe_task = task
Beispiel #8
0
def apply_scalac(self):

	Utils.def_attrs(self, jarname='', classpath='',
		sourcepath='.', srcdir='.',
		jar_mf_attributes={}, jar_mf_classpath=[])

	outdir = getattr(self, 'outdir', None)
	if outdir:
		if not isinstance(outdir, Node.Node):
			outdir = self.path.get_bld().make_node(self.outdir)
	else:
		outdir = self.path.get_bld()
	outdir.mkdir()
	self.env['OUTDIR'] = outdir.abspath()

	self.scalac_task = tsk = self.create_task('scalac')
	tmp = []

	srcdir = getattr(self, 'srcdir', '')
	if isinstance(srcdir, Node.Node):
		srcdir = [srcdir]
	for x in Utils.to_list(srcdir):
		if isinstance(x, Node.Node):
			y = x
		else:
			y = self.path.find_dir(x)
			if not y:
				self.bld.fatal('Could not find the folder %s from %s' % (x, self.path))
		tmp.append(y)
	tsk.srcdir = tmp
def apply_scalac(self):

    Utils.def_attrs(self,
                    jarname='',
                    classpath='',
                    sourcepath='.',
                    srcdir='.',
                    jar_mf_attributes={},
                    jar_mf_classpath=[])

    outdir = getattr(self, 'outdir', None)
    if outdir:
        if not isinstance(outdir, Node.Node):
            outdir = self.path.get_bld().make_node(self.outdir)
    else:
        outdir = self.path.get_bld()
    outdir.mkdir()
    self.env['OUTDIR'] = outdir.abspath()

    self.scalac_task = tsk = self.create_task('scalac')
    tmp = []

    srcdir = getattr(self, 'srcdir', '')
    if isinstance(srcdir, Node.Node):
        srcdir = [srcdir]
    for x in Utils.to_list(srcdir):
        if isinstance(x, Node.Node):
            y = x
        else:
            y = self.path.find_dir(x)
            if not y:
                self.bld.fatal('Could not find the folder %s from %s' %
                               (x, self.path))
        tmp.append(y)
    tsk.srcdir = tmp
Beispiel #10
0
def apply_copy(self):
    Utils.def_attrs(self, fun=copy_func)
    self.default_install_path = 0

    lst = self.to_list(self.source)
    self.meths.remove('process_source')

    for filename in lst:
        node = self.path.find_resource(filename)
        if not node:
            raise Errors.WafError('cannot find input file %s for processing' %
                                  filename)

        target = self.target
        if not target or len(lst) > 1: target = node.name

        # TODO the file path may be incorrect
        newnode = self.path.find_or_declare(target)

        tsk = self.create_task('copy', node, newnode)
        tsk.fun = self.fun
        tsk.chmod = getattr(self, 'chmod', Utils.O644)

        if not tsk.env:
            tsk.debug()
            raise Errors.WafError('task without an environment')
def apply_java(self):
    """
    Create a javac task for compiling *.java files*. There can be
    only one javac task by task generator.
    """
    Utils.def_attrs(
        self,
        jarname="",
        classpath="",
        sourcepath=".",
        srcdir=".",
        jar_mf_attributes={},
        jar_mf_classpath=[],
    )

    outdir = getattr(self, "outdir", None)
    if outdir:
        if not isinstance(outdir, Node.Node):
            outdir = self.path.get_bld().make_node(self.outdir)
    else:
        outdir = self.path.get_bld()
    outdir.mkdir()
    self.outdir = outdir
    self.env.OUTDIR = outdir.abspath()

    self.javac_task = tsk = self.create_task("javac")
    tmp = []

    srcdir = getattr(self, "srcdir", "")
    if isinstance(srcdir, Node.Node):
        srcdir = [srcdir]
    for x in Utils.to_list(srcdir):
        if isinstance(x, Node.Node):
            y = x
        else:
            y = self.path.find_dir(x)
            if not y:
                self.bld.fatal(
                    f"Could not find the folder {x} from {self.path}")
        tmp.append(y)

    tsk.srcdir = tmp

    if getattr(self, "compat", None):
        tsk.env.append_value("JAVACFLAGS", ["-source", str(self.compat)])

    if hasattr(self, "sourcepath"):
        fold = [
            isinstance(x, Node.Node) and x or self.path.find_dir(x)
            for x in self.to_list(self.sourcepath)
        ]
        names = os.pathsep.join([x.srcpath() for x in fold])
    else:
        names = [x.srcpath() for x in tsk.srcdir]

    if names:
        tsk.env.append_value("JAVACFLAGS", ["-sourcepath", names])
Beispiel #12
0
Datei: javaw.py Projekt: zsx/waf
def apply_java(self):
	Utils.def_attrs(self, jarname='', jaropts='', classpath='',
		sourcepath='.', srcdir='.', source_re='**/*.java',
		jar_mf_attributes={}, jar_mf_classpath=[])

	nodes_lst = []

	if not self.classpath:
		if not self.env['CLASSPATH']:
			self.env['CLASSPATH'] = '..' + os.pathsep + '.'
	else:
		self.env['CLASSPATH'] = self.classpath

	srcdir_node = self.path.find_dir(self.srcdir)
	if not srcdir_node:
		raise Errors.WafError('could not find srcdir %r' % self.srcdir)

	src_nodes = srcdir_node.ant_glob(self.source_re)
	bld_nodes = [x.change_ext('.class') for x in src_nodes]
	for x in src_nodes:
		x.sig = Utils.h_file(x.abspath())

	self.env['OUTDIR'] = [srcdir_node.get_bld().abspath()]

	tsk = self.create_task('javac')
	tsk.set_inputs(src_nodes)
	tsk.set_outputs(bld_nodes)

	if getattr(self, 'compat', None):
		tsk.env.append_value('JAVACFLAGS', ['-source', self.compat])

	if hasattr(self, 'sourcepath'):
		fold = [self.path.find_dir(x) for x in self.to_list(self.sourcepath)]
		names = os.pathsep.join([x.srcpath() for x in fold])
	else:
		names = srcdir_node.srcpath()

	if names:
		tsk.env.append_value('JAVACFLAGS', ['-sourcepath', names])

	if self.jarname:
		tsk = self.create_task('jar_create')
		tsk.set_outputs(self.path.find_or_declare(self.jarname))

		if not self.env['JAROPTS']:
			if self.jaropts:
				self.env['JAROPTS'] = self.jaropts
			else:
				dirs = '.'
				self.env['JAROPTS'] = ['-C', ''.join(self.env['OUTDIR']), dirs]
Beispiel #13
0
def apply_java(self):
    """
	Create a javac task for compiling *.java files*. There can be
	only one javac task by task generator.
	"""
    Utils.def_attrs(
        self, jarname="", classpath="", sourcepath=".", srcdir=".", jar_mf_attributes={}, jar_mf_classpath=[]
    )

    nodes_lst = []

    outdir = getattr(self, "outdir", None)
    if outdir:
        if not isinstance(outdir, Node.Node):
            outdir = self.path.get_bld().make_node(self.outdir)
    else:
        outdir = self.path.get_bld()
    outdir.mkdir()
    self.outdir = outdir
    self.env["OUTDIR"] = outdir.abspath()

    self.javac_task = tsk = self.create_task("javac")
    tmp = []

    srcdir = getattr(self, "srcdir", "")
    if isinstance(srcdir, Node.Node):
        srcdir = [srcdir]
    for x in Utils.to_list(srcdir):
        if isinstance(x, Node.Node):
            y = x
        else:
            y = self.path.find_dir(x)
            if not y:
                self.bld.fatal("Could not find the folder %s from %s" % (x, self.path))
        tmp.append(y)
    tsk.srcdir = tmp

    if getattr(self, "compat", None):
        tsk.env.append_value("JAVACFLAGS", ["-source", self.compat])

    if hasattr(self, "sourcepath"):
        fold = [isinstance(x, Node.Node) and x or self.path.find_dir(x) for x in self.to_list(self.sourcepath)]
        names = os.pathsep.join([x.srcpath() for x in fold])
    else:
        names = [x.srcpath() for x in tsk.srcdir]

    if names:
        tsk.env.append_value("JAVACFLAGS", ["-sourcepath", names])
Beispiel #14
0
def init_ml(self):
	Utils.def_attrs(self,
		type = 'all',
		incpaths_lst = [],
		bld_incpaths_lst = [],
		mlltasks = [],
		mlytasks = [],
		mlitasks = [],
		native_tasks = [],
		bytecode_tasks = [],
		linktasks = [],
		bytecode_env = None,
		native_env = None,
		compiled_tasks = [],
		includes = '',
		uselib = '',
		are_deps_set = 0)
Beispiel #15
0
def init_ml(self):
    Utils.def_attrs(self,
                    type='all',
                    incpaths_lst=[],
                    bld_incpaths_lst=[],
                    mlltasks=[],
                    mlytasks=[],
                    mlitasks=[],
                    native_tasks=[],
                    bytecode_tasks=[],
                    linktasks=[],
                    bytecode_env=None,
                    native_env=None,
                    compiled_tasks=[],
                    includes='',
                    uselib='',
                    are_deps_set=0)
Beispiel #16
0
def init_cmd_output(self):
    Utils.def_attrs(
        self,
        stdin=None,
        stdout=None,
        stderr=None,
        # the command to execute
        command=None,

        # whether it is an external command; otherwise it is assumed
        # to be an executable binary or script that lives in the
        # source or build tree.
        command_is_external=False,

        # extra parameters (argv) to pass to the command (excluding
        # the command itself)
        argv=[],

        # dependencies to other objects -> this is probably not what you want (ita)
        # values must be 'task_gen' instances (not names!)
        dependencies=[],

        # dependencies on env variable contents
        dep_vars=[],

        # input files that are implicit, i.e. they are not
        # stdin, nor are they mentioned explicitly in argv
        hidden_inputs=[],

        # output files that are implicit, i.e. they are not
        # stdout, nor are they mentioned explicitly in argv
        hidden_outputs=[],

        # change the subprocess to this cwd (must use obj.input_dir() or output_dir() here)
        cwd=None,

        # OS environment variables to pass to the subprocess
        # if None, use the default environment variables unchanged
        os_env=None)
Beispiel #17
0
def apply_subst(self):
    Utils.def_attrs(self, fun=subst_func)
    lst = self.to_list(self.source)
    self.meths.remove('process_source')

    self.dict = getattr(self, 'dict', {})

    for filename in lst:
        node = self.path.find_resource(filename)
        if not node:
            raise Errors.WafError('cannot find input file %s for processing' %
                                  filename)

        if self.target:
            newnode = self.path.find_or_declare(self.target)
        else:
            newnode = node.change_ext('')

        try:
            self.dict = self.dict.get_merged_dict()
        except AttributeError:
            pass

        if self.dict and not self.env['DICT_HASH']:
            self.env = self.env.derive()
            keys = list(self.dict.keys())
            keys.sort()
            lst = [self.dict[x] for x in keys]
            self.env['DICT_HASH'] = str(Utils.h_list(lst))

        tsk = self.create_task('copy', node, newnode)
        tsk.fun = self.fun
        tsk.dict = self.dict
        tsk.dep_vars = ['DICT_HASH']
        tsk.chmod = getattr(self, 'chmod', Utils.O644)

        if not tsk.env:
            tsk.debug()
            raise Errors.WafError('task without an environment')
Beispiel #18
0
def init_cmd_output(self):
	Utils.def_attrs(self,
		stdin = None,
		stdout = None,
		stderr = None,
		
		command = None,

		
		
		
		command_is_external = False,

		
		
		argv = [],

		
		
		dependencies = [],

		
		dep_vars = [],

		
		
		hidden_inputs = [],

		
		
		hidden_outputs = [],

		
		cwd = None,

		
		
		os_env = None)
Beispiel #19
0
def apply_subst(self):
    Utils.def_attrs(self, fun=subst_func)
    lst = self.to_list(self.source)
    self.meths.remove("process_source")

    self.dict = getattr(self, "dict", {})

    for filename in lst:
        node = self.path.find_resource(filename)
        if not node:
            raise Errors.WafError("cannot find input file %s for processing" % filename)

        if self.target:
            newnode = self.path.find_or_declare(self.target)
        else:
            newnode = node.change_ext("")

        try:
            self.dict = self.dict.get_merged_dict()
        except AttributeError:
            pass

        if self.dict and not self.env["DICT_HASH"]:
            self.env = self.env.derive()
            keys = list(self.dict.keys())
            keys.sort()
            lst = [self.dict[x] for x in keys]
            self.env["DICT_HASH"] = str(Utils.h_list(lst))

        tsk = self.create_task("copy", node, newnode)
        tsk.fun = self.fun
        tsk.dict = self.dict
        tsk.dep_vars = ["DICT_HASH"]
        tsk.chmod = getattr(self, "chmod", Utils.O644)

        if not tsk.env:
            tsk.debug()
            raise Errors.WafError("task without an environment")
Beispiel #20
0
def apply_java(self):
	Utils.def_attrs(self, jarname='', classpath='',
		sourcepath='.', srcdir='.',
		jar_mf_attributes={}, jar_mf_classpath=[])

	nodes_lst = []

	if not self.classpath:
		if not self.env['CLASSPATH']:
			self.env['CLASSPATH'] = '..' + os.pathsep + '.'
	else:
		self.env['CLASSPATH'] = self.classpath

	if isinstance(self.srcdir, self.path.__class__):
		srcdir_node = self.srcdir
	else:
		srcdir_node = self.path.find_dir(self.srcdir)
	if not srcdir_node:
		raise Errors.WafError('could not find srcdir %r' % self.srcdir)

	self.env['OUTDIR'] = [srcdir_node.get_src().srcpath()]

	self.javac_task = tsk = self.create_task('javac')
	tsk.srcdir = srcdir_node

	if getattr(self, 'compat', None):
		tsk.env.append_value('JAVACFLAGS', ['-source', self.compat])

	if hasattr(self, 'sourcepath'):
		fold = [isinstance(x, self.path.__class__) and x or self.path.find_dir(x) for x in self.to_list(self.sourcepath)]
		names = os.pathsep.join([x.srcpath() for x in fold])
	else:
		names = srcdir_node.srcpath()

	if names:
		tsk.env.append_value('JAVACFLAGS', ['-sourcepath', names])

	"""
Beispiel #21
0
def ping(self):
	Utils.def_attrs(self,srcglob='**')
	srcdir=getattr(self,'srcdir',None)	
	if srcdir:
		if isinstance(srcdir,Node.Node):
			srcnode=srcdir
		else:
			srcnode=self.path.find_node(srcdir)
	else:
		self.bld.fatal("You must specifiy a source dir")
	if not srcnode:
		self.bld.fatal("Invalid source directory: %s" % srcdir)
	
	outdir=getattr(self,'outdir',None)	
	if outdir:
		if not isinstance(outdir,Node.Node):
			outdir=self.path.get_bld().make_node(self.outdir)
	else:
		outdir=self.path.get_bld()
	for input in srcnode.ant_glob(self.srcglob):
		tsk = self.create_task('Copy')
		output=outdir.find_or_declare(input.path_from(srcnode))
		tsk.set_inputs(input)
		tsk.set_outputs(output)
def apply_scalac(self):

    Utils.def_attrs(
        self,
        jarname="",
        classpath="",
        sourcepath=".",
        srcdir=".",
        jar_mf_attributes={},
        jar_mf_classpath=[],
    )

    outdir = getattr(self, "outdir", None)
    if outdir:
        if not isinstance(outdir, Node.Node):
            outdir = self.path.get_bld().make_node(self.outdir)
    else:
        outdir = self.path.get_bld()
    outdir.mkdir()
    self.env["OUTDIR"] = outdir.abspath()

    self.scalac_task = tsk = self.create_task("scalac")
    tmp = []

    srcdir = getattr(self, "srcdir", "")
    if isinstance(srcdir, Node.Node):
        srcdir = [srcdir]
    for x in Utils.to_list(srcdir):
        if isinstance(x, Node.Node):
            y = x
        else:
            y = self.path.find_dir(x)
            if not y:
                self.bld.fatal(f"Could not find the folder {x} from {self.path}")
        tmp.append(y)
    tsk.srcdir = tmp
Beispiel #23
0
def halide(self):
	Utils.def_attrs(self,
	 args=[],
	 halide_env={},
	)

	bld = self.bld

	env = self.halide_env
	try:
		if isinstance(env, str):
			env = dict(x.split('=') for x in env.split())
		elif isinstance(env, list):
			env = dict(x.split('=') for x in env)
		assert isinstance(env, dict)
	except Exception as e:
		if not isinstance(e, ValueError) \
		 and not isinstance(e, AssertionError):
			raise
		raise Errors.WafError(
		 "halide_env must be under the form" \
		 " {'HL_x':'a', 'HL_y':'b'}" \
		 " or ['HL_x=y', 'HL_y=b']" \
		 " or 'HL_x=y HL_y=b'")

	src = self.to_nodes(self.source)
	assert len(src) == 1, "Only one source expected"
	src = src[0]

	args = Utils.to_list(self.args)

	def change_ext(src, ext):
		# Return a node with a new extension, in an appropriate folder
		name = src.name
		xpos = src.name.rfind('.')
		if xpos == -1:
			xpos = len(src.name)
		newname = name[:xpos] + ext
		if src.is_child_of(bld.bldnode):
			node = src.get_src().parent.find_or_declare(newname)
		else:
			node = bld.bldnode.find_or_declare(newname)
		return node

	def to_nodes(self, lst, path=None):
		tmp = []
		path = path or self.path
		find = path.find_or_declare

		if isinstance(lst, self.path.__class__):
			lst = [lst]

		for x in Utils.to_list(lst):
			if isinstance(x, str):
				node = find(x)
			else:
				node = x
			tmp.append(node)
		return tmp

	tgt = to_nodes(self, self.target)
	if not tgt:
		tgt = [change_ext(src, '.o'), change_ext(src, '.h')]
	cwd = tgt[0].parent.abspath()
	task = self.create_task('run_halide_gen', src, tgt, cwd=cwd)
	task.env.append_unique('HALIDE_ARGS', args)
	if task.env.env == []:
		task.env.env = {}
	task.env.env.update(env)
	task.env.HALIDE_ENV = " ".join(("%s=%s" % (k,v)) for (k,v) in sorted(env.items()))
	task.env.HALIDE_ARGS = args

	try:
		self.compiled_tasks.append(task)
	except AttributeError:
		self.compiled_tasks = [task]
	self.source = []
def halide(self):
    Utils.def_attrs(
        self,
        args=[],
        halide_env={},
    )

    bld = self.bld

    env = self.halide_env
    try:
        if isinstance(env, str):
            env = dict(x.split("=") for x in env.split())
        elif isinstance(env, list):
            env = dict(x.split("=") for x in env)
        assert isinstance(env, dict)
    except Exception as e:
        if not isinstance(e, ValueError) and not isinstance(e, AssertionError):
            raise
        raise Errors.WafError("halide_env must be under the form"
                              " {'HL_x':'a', 'HL_y':'b'}"
                              " or ['HL_x=y', 'HL_y=b']"
                              " or 'HL_x=y HL_y=b'")

    src = self.to_nodes(self.source)
    assert len(src) == 1, "Only one source expected"
    src = src[0]

    args = Utils.to_list(self.args)

    def change_ext(src, ext):
        # Return a node with a new extension, in an appropriate folder
        name = src.name
        xpos = src.name.rfind(".")
        if xpos == -1:
            xpos = len(src.name)
        newname = name[:xpos] + ext
        if src.is_child_of(bld.bldnode):
            node = src.get_src().parent.find_or_declare(newname)
        else:
            node = bld.bldnode.find_or_declare(newname)
        return node

    def to_nodes(self, lst, path=None):
        tmp = []
        path = path or self.path
        find = path.find_or_declare

        if isinstance(lst, self.path.__class__):
            lst = [lst]

        for x in Utils.to_list(lst):
            if isinstance(x, str):
                node = find(x)
            else:
                node = x
            tmp.append(node)
        return tmp

    tgt = to_nodes(self, self.target)
    if not tgt:
        tgt = [change_ext(src, ".o"), change_ext(src, ".h")]
    cwd = tgt[0].parent.abspath()
    task = self.create_task("run_halide_gen", src, tgt, cwd=cwd)
    task.env.append_unique("HALIDE_ARGS", args)
    if task.env.env == []:
        task.env.env = {}
    task.env.env.update(env)
    task.env.HALIDE_ENV = " ".join(
        (f"{k}={v}") for (k, v) in sorted(env.items()))
    task.env.HALIDE_ARGS = args

    try:
        self.compiled_tasks.append(task)
    except AttributeError:
        self.compiled_tasks = [task]
    self.source = []
Beispiel #25
0
def init_command(self):
	Utils.def_attrs(self,
					# other variables that can be used in the command: ${VARIABLE}
					variables = None,
					rule='')
Beispiel #26
0
def process_aar(self):
    '''
    Find the Android library and unpack it so it's resources can be used by other modules
    '''
    def _could_not_find_lib_error():
        raise Errors.WafError('[ERROR] Could not find Android library %r' %
                              self.name)

    bld = self.bld
    platform = bld.env['PLATFORM']

    # the android studio project generation also requires this to run in order for the
    # aar dependencies to get added to gradle correctly
    if not (bld.is_android_platform(platform) or bld.cmd == 'android_studio'):
        Logs.debug('android_library: Skipping the reading of the aar')
        return

    Utils.def_attrs(
        self,
        manifest=None,
        package='',
        classpath=[],
        native_libs=[],
        aapt_assets=None,
        aapt_resources=None,
    )

    group = self.group_id
    version = self.version
    search_paths = self.paths

    android_cache = bld.get_android_cache_node()
    aar_cache = android_cache.make_node('aar')
    aar_cache.mkdir()

    Logs.debug('android_library: Processing Android library %s', self.name)
    lib_node = None

    if search_paths:
        aar_filename = '{}.aar'.format(self.name)

        for path in search_paths:
            if not isinstance(path, Node.Node):
                path = bld.root.find_node(path) or self.path.find_node(path)
                if not path:
                    Logs.debug(
                        'android_library: Unable to find node for path %s',
                        path)
                    continue

            Logs.debug('android_library: Searching path {}'.format(
                path.abspath()))
            lib_node = path.find_node(aar_filename)
            if lib_node:
                break
        else:
            _could_not_find_lib_error()

        self.android_studio_name = 'file:{}'.format(
            lib_node.abspath()).replace('\\', '/')

    else:
        file_url, aar_filename = search_maven_repos(bld, self.name, group,
                                                    version)

        if not (file_url and aar_filename):
            _could_not_find_lib_error()

        if file_url.startswith('file:'):
            local_path = file_url[5:]

            lib_node = bld.root.find_node(local_path)
            if not lib_node:
                _could_not_find_lib_error()

        else:
            lib_node = aar_cache.find_node(aar_filename)
            if not lib_node:
                lib_node = aar_cache.make_node(aar_filename)
                Logs.debug('android_library: Downloading %s => %s', file_url,
                           lib_node.abspath())

                try:
                    url_opener = urllib.FancyURLopener()
                    url_opener.retrieve(file_url, filename=lib_node.abspath())
                except:
                    bld.Fatal(
                        '[ERROR] Failed to download Android library {} from {}.'
                        .format(self.name, file_url))

        if not version:
            version = os.path.splitext(aar_filename)[0].split('-')[-1]

        self.android_studio_name = '{}:{}:{}'.format(group, self.name, version)

    lib_node.sig = Utils.h_file(lib_node.abspath())

    folder_name = os.path.splitext(aar_filename)[0]
    extraction_node = aar_cache.make_node(folder_name)
    if os.path.exists(extraction_node.abspath()):
        extraction_node.delete()
    extraction_node.mkdir()

    aar_file = zipfile.ZipFile(file=lib_node.abspath())
    aar_file.extractall(path=extraction_node.abspath())
    Logs.debug('android_library: AAR contents = {}'.format(
        aar_file.namelist()))

    # required entries from the aar
    main_jar_file = extraction_node.find_node('classes.jar')
    if not main_jar_file:
        self.bld.fatal(
            '[ERROR] Unable to find the required classes.jar from {}'.format(
                lib_name))

    self.manifest = extraction_node.find_node('AndroidManifest.xml')
    if not self.manifest:
        self.bld.fatal(
            '[ERROR] Unable to find the required AndroidManifest.xml from {}'.
            format(lib_name))

    self.package = get_package_name(self.manifest.abspath())
    if not self.package:
        self.bld.fatal(
            '[ERROR] Failed to extract the package name from AndroidManifest.xml in {}'
            .format(lib_name))

    self.aapt_resources = extraction_node.find_dir('res')
    if not self.aapt_resources:
        self.bld.fatal(
            '[ERROR] Unable to find the required resources directory - res - from {}'
            .format(lib_name))

    # optional entries from the aar
    self.aapt_assets = extraction_node.find_dir('assets')

    java_libs = extraction_node.find_dir('libs')
    if java_libs:
        self.classpath = java_libs.ant_glob('**/*.jar')

    native_lib_path = 'jni/{}'.format(self.bld.env['ANDROID_ARCH'])
    native_libs = extraction_node.find_dir(native_lib_path)
    if native_libs:
        self.native_libs_root = native_libs
        self.native_libs = native_libs.ant_glob('**/*.so')

    # create the fake tasks
    self.jar_task = self.create_task('fake_jar', [], main_jar_file)
    self.aar_task = self.create_task('fake_aar', [], lib_node)

    # task chaining
    self.aar_task.set_run_after(self.jar_task)
Beispiel #27
0
def process_aar(self):
    """
    Find the Android library and unpack it so it's resources can be used by other modules
    """
    if self.bld.env['PLATFORM'] not in ('android_armv7_clang', 'android_armv7_gcc', 'project_generator'):
        Logs.debug('android_library: Skipping the reading of the aar')
        return

    Utils.def_attrs(
        self,

        manifest = None,
        package = '',

        classpath = [],

        native_libs = [],

        aapt_assets = None,
        aapt_resources = None,
    )

    lib_node = None
    search_paths = []

    if self.is_android_support_lib:
        android_api_level = str(self.env['ANDROID_SDK_VERSION_NUMBER'])
        Logs.debug('android_library: Searching for support library - %s - built with API %s', self.name, android_api_level)

        for path in self.lib_paths:
            if os.path.exists(path):
                entries = os.listdir(path)
                Logs.debug('android_library: All API versions installed {}'.format(entries))

                api_versions = sorted([ entry for entry in entries if entry.startswith(android_api_level) ])
                Logs.debug('android_library: Found versions {}'.format(api_versions))
                highest_useable_version = api_versions[-1]

                search_paths.append(os.path.join(path, highest_useable_version))

                self.android_studio_name = 'com.android.support:{}:{}'.format(self.name, highest_useable_version)
                lib_name = '{}-{}.aar'.format(self.name, highest_useable_version)
                break
        else:
            raise Errors.WafError('Unable to detect a valid useable version for Android support library  %r' % self.name)

    else:
        lib_name = '{}.aar'.format(self.name)
        search_paths = self.lib_paths + [ self.path ]

    for path in search_paths:
        Logs.debug('android_library: Searching path {}'.format(path))

        if not isinstance(path, Node.Node):
            path = self.bld.root.find_node(path) or self.path.find_node(path)
            if not path:
                Logs.debug('android_library: Unable to find node for path')
                continue

        lib_node = path.find_node(lib_name)
        if lib_node:
            lib_node.sig = Utils.h_file(lib_node.abspath())
            break

    else:
        raise Errors.WafError('Could not find Android library %r' % self.name)

    android_cache = self.bld.get_android_cache_node()

    extraction_node = android_cache.make_node([ 'aar', self.name ])
    if os.path.exists(extraction_node.abspath()):
        extraction_node.delete()
    extraction_node.mkdir()

    aar_file = zipfile.ZipFile(file = lib_node.abspath())
    aar_file.extractall(path = extraction_node.abspath())
    Logs.debug('android_library: AAR contents = {}'.format(aar_file.namelist()))

    # required entries from the aar
    main_jar_file = extraction_node.find_node('classes.jar')
    if not main_jar_file:
        self.bld.fatal('[ERROR] Unable to find the required classes.jar from {}'.format(lib_name))

    self.manifest = extraction_node.find_node('AndroidManifest.xml')
    if not self.manifest:
        self.bld.fatal('[ERROR] Unable to find the required AndroidManifest.xml from {}'.format(lib_name))

    self.package = get_package_name(self.manifest.abspath())
    if not self.package:
        self.bld.fatal('[ERROR] Failed to extract the package name from AndroidManifest.xml in {}'.format(lib_name))

    self.aapt_resources = extraction_node.find_dir('res')
    if not self.aapt_resources:
        self.bld.fatal('[ERROR] Unable to find the required resources directory - res - from {}'.format(lib_name))

    # optional entries from the aar
    self.aapt_assets = extraction_node.find_dir('assets')

    java_libs = extraction_node.find_dir('libs')
    if java_libs:
        self.classpath = java_libs.ant_glob('**/*.jar')

    native_lib_path = 'jni/{}'.format(self.bld.env['ANDROID_ARCH'])
    native_libs = extraction_node.find_dir(native_lib_path)
    if native_libs:
        self.native_libs_root = native_libs
        self.native_libs = native_libs.ant_glob('**/*.so')

    # create the fake tasks
    self.jar_task = self.create_task('fake_jar', [], main_jar_file)
    self.aar_task = self.create_task('fake_aar', [], lib_node)

    # task chaining
    self.aar_task.set_run_after(self.jar_task)
Beispiel #28
0
def init_command(self):
	Utils.def_attrs(self,
					# other variables that can be used in the command: ${VARIABLE}
					variables = None,
					rule='')