javaw¶
Java support
Javac is one of the few compilers that behaves very badly:
- it outputs files where it wants to (-d is only for the package root)
- it recompiles files silently behind your back
- it outputs an undefined amount of files (inner classes)
Remember that the compilation can be performed using Jython[1] rather than regular Python. Instead of running one of the following commands:
./waf configure
python waf configure
You would have to run:
java -jar /path/to/jython.jar waf configure
-
waflib.Tools.javaw.
apply_java
(self)[source]¶ Task generator method
Create a javac task for compiling .java files. There can be only one javac task by task generator.
Feature: javac
-
waflib.Tools.javaw.
use_javac_files
(self)[source]¶ Task generator method
Process the use attribute referring to other java compilations
Feature: javac
-
waflib.Tools.javaw.
set_classpath
(self)[source]¶ Task generator method
Set the CLASSPATH value on the javac task previously created.
Feature: javac
-
waflib.Tools.javaw.
jar_files
(self)[source]¶ Task generator method
Create a jar task. There can be only one jar task by task generator.
Feature: jar
-
waflib.Tools.javaw.
use_jar_files
(self)[source]¶ Task generator method
Process the use attribute to set the build order on the tasks created by another task generator.
Feature: jar
-
class
waflib.Tools.javaw.
jar_create
(*k, **kw)[source]¶ Bases:
waflib.Task.Task
Create a jar file
-
color
= 'GREEN'¶
-
runnable_status
()[source]¶ Wait for dependent tasks to be executed, then read the files to update the list of inputs.
-
__doc__
= '\n\tCreate a jar file\n\t'¶
-
__module__
= 'waflib.Tools.javaw'¶
-
hcode
= '${JAR} ${JARCREATE} ${TGT} ${JAROPTS}'¶
-
orig_run_str
= '${JAR} ${JARCREATE} ${TGT} ${JAROPTS}'¶
-
vars
= ['JAR', 'JARCREATE', 'JAROPTS']¶
-
-
class
waflib.Tools.javaw.
javac
(*k, **kw)[source]¶ Bases:
waflib.Task.Task
Compile java files
-
color
= 'BLUE'¶
-
vars
= ['CLASSPATH', 'JAVACFLAGS', 'JAVAC', 'OUTDIR']¶ The javac task will be executed again if the variables CLASSPATH, JAVACFLAGS, JAVAC or OUTDIR change.
-
runnable_status
()[source]¶ Wait for dependent tasks to be complete, then read the file system to find the input nodes.
-
__doc__
= '\n\tCompile java files\n\t'¶
-
__module__
= 'waflib.Tools.javaw'¶
-
hcode
= '\tdef run(self):\n\t\t"""\n\t\tExecute the javac compiler\n\t\t"""\n\t\tenv = self.env\n\t\tgen = self.generator\n\t\tbld = gen.bld\n\t\twd = bld.bldnode.abspath()\n\t\tdef to_list(xx):\n\t\t\tif isinstance(xx, str): return [xx]\n\t\t\treturn xx\n\t\tcmd = []\n\t\tcmd.extend(to_list(env[\'JAVAC\']))\n\t\tcmd.extend([\'-classpath\'])\n\t\tcmd.extend(to_list(env[\'CLASSPATH\']))\n\t\tcmd.extend([\'-d\'])\n\t\tcmd.extend(to_list(env[\'OUTDIR\']))\n\t\tcmd.extend(to_list(env[\'JAVACFLAGS\']))\n\n\t\tfiles = [a.path_from(bld.bldnode) for a in self.inputs]\n\n\t\t# workaround for command line length limit:\n\t\t# http://support.microsoft.com/kb/830473\n\t\ttmp = None\n\t\ttry:\n\t\t\tif len(str(files)) + len(str(cmd)) > 8192:\n\t\t\t\t(fd, tmp) = tempfile.mkstemp(dir=bld.bldnode.abspath())\n\t\t\t\ttry:\n\t\t\t\t\tos.write(fd, \'\\n\'.join(files).encode())\n\t\t\t\tfinally:\n\t\t\t\t\tif tmp:\n\t\t\t\t\t\tos.close(fd)\n\t\t\t\tif Logs.verbose:\n\t\t\t\t\tLogs.debug(\'runner: %r\' % (cmd + files))\n\t\t\t\tcmd.append(\'@\' + tmp)\n\t\t\telse:\n\t\t\t\tcmd += files\n\n\t\t\tret = self.exec_command(cmd, cwd=wd, env=env.env or None)\n\t\tfinally:\n\t\t\tif tmp:\n\t\t\t\tos.remove(tmp)\n\t\treturn ret\n'¶
-
-
waflib.Tools.javaw.
create_javadoc
(self)[source]¶ Task generator method
Creates a javadoc task (feature ‘javadoc’)
Feature: javadoc
-
waflib.Tools.javaw.
check_java_class
(self, classname, with_classpath=None)[source]¶ Configuration Method bound to
waflib.Configure.ConfigurationContext
Check if the specified java class exists
Parameters: - classname (string) – class to check, like java.util.HashMap
- with_classpath (string) – additional classpath to give
-
waflib.Tools.javaw.
conf
(f)¶ Decorator: attach new configuration functions to
waflib.Build.BuildContext
andwaflib.Configure.ConfigurationContext
. The methods bound will accept a parameter named ‘mandatory’ to disable the configuration errors:def configure(conf): conf.find_program('abc', mandatory=False)
Parameters: f (function) – method to bind
-
waflib.Tools.javaw.
feature
(*k)¶ Decorator: register a task generator method that will be executed when the object attribute ‘feature’ contains the corresponding key(s):
from waflib.Task import feature @feature('myfeature') def myfunction(self): print('that is my feature!') def build(bld): bld(features='myfeature')
Parameters: k (list of string) – feature names
-
waflib.Tools.javaw.
before_method
(*k)[source]¶ Decorator: register a task generator method which will be executed before the functions of given name(s):
from waflib.TaskGen import feature, before @feature('myfeature') @before_method('fun2') def fun1(self): print('feature 1!') @feature('myfeature') def fun2(self): print('feature 2!') def build(bld): bld(features='myfeature')
Parameters: k (list of string) – method names
-
waflib.Tools.javaw.
after_method
(*k)[source]¶ Decorator: register a task generator method which will be executed after the functions of given name(s):
from waflib.TaskGen import feature, after @feature('myfeature') @after_method('fun2') def fun1(self): print('feature 1!') @feature('myfeature') def fun2(self): print('feature 2!') def build(bld): bld(features='myfeature')
Parameters: k (list of string) – method names
-
waflib.Tools.javaw.
check_jni_headers
(conf)[source]¶ Configuration Method bound to
waflib.Configure.ConfigurationContext
Check for jni headers and libraries. On success the conf.env variables xxx_JAVA are added for use in C/C++ targets:
def options(opt): opt.load('compiler_c') def configure(conf): conf.load('compiler_c java') conf.check_jni_headers() def build(bld): bld.shlib(source='a.c', target='app', use='JAVA')
Features defined in this module: