waf

FORK: waf with some random patches
git clone https://git.neptards.moe/neptards/waf.git
Log | Files | Refs | README

wscript (2505B)


      1 #! /usr/bin/env python
      2 # encoding: utf-8
      3 # Federico Pellegrin, 2019 (fedepell)
      4 
      5 #
      6 # Simple script to demonstrate integration of Java Unit testing inside
      7 # standard waf_unit_test using either TestNG or JUnit
      8 #
      9 
     10 def test_results(bld):
     11 	"""
     12 	Custom post- function that prints out test results.
     13 	"""
     14 	lst = getattr(bld, 'utest_results', [])
     15 	if not lst:
     16 		return
     17 	for (f, code, out, err) in lst:
     18 		print(out.decode('utf-8'))
     19 		print(err.decode('utf-8'))
     20 
     21 
     22 def options(opt):
     23 	opt.load('java waf_unit_test javatest')
     24 	opt.load('compiler_c')
     25 
     26 def configure(conf):
     27 	conf.load('java javatest')
     28 	conf.load('compiler_c')
     29 	conf.check_jni_headers()
     30 
     31 def build(bld):
     32 	bld(features = 'javac',
     33 		name = 'mainprog',
     34 		srcdir     = 'src/', # folder containing the sources to compile
     35 		outdir     = 'src', # folder where to output the classes (in the build directory)
     36 		sourcepath = ['src'],
     37 		basedir    = 'src', # folder containing the classes and other files to package (must match outdir)
     38 	)
     39 
     40 
     41 	bld(features = 'javac javatest',
     42 		srcdir     = 'test/', # folder containing the sources to compile
     43 		outdir     = 'test', # folder where to output the classes (in the build directory)
     44 		sourcepath = ['test'],
     45 		classpath  = [ 'src' ],
     46 		basedir    = 'test', # folder containing the classes and other files to package (must match outdir)
     47 		use = ['JAVATEST', 'mainprog'],
     48 		ut_str = 'java -cp ${CLASSPATH} ${JTRUNNER} ${SRC}',
     49 		jtest_source = bld.path.ant_glob('test/*.xml'),
     50 		# For JUnit do first JUnit configuration and no need to use jtest_source:
     51 		# ut_str = 'java -cp ${CLASSPATH} ${JTRUNNER} [TestClass]',
     52 	)
     53 
     54 
     55 	# Demonstrate correct handling also of dependency to non-java tasks (see !2257)
     56 	bld(name='stjni', features='javac jar', srcdir='jni/java', outdir='jni/java', basedir='jni/java', destfile='stringUtils.jar')
     57 
     58 	bld.shlib(source   = 'jni/jni/source/StringUtils.c',
     59 		includes = 'jni/jni/include',
     60 		target   = 'jni/stringUtils',
     61 		uselib   = 'JAVA')
     62 
     63 	bld(features = 'javac javatest',
     64 		srcdir     = 'jni/test/', # folder containing the sources to compile
     65 		outdir     = 'jni/test', # folder where to output the classes (in the build directory)
     66 		sourcepath = ['jni/test'],
     67 		classpath  = [ 'jni/src' ],
     68 		basedir    = 'jni/test', # folder containing the classes and other files to package (must match outdir)
     69 		use = ['JAVATEST', 'stjni', 'jni/stringUtils'],
     70 		ut_str = 'java -cp ${CLASSPATH} ${JTRUNNER} ${SRC}',
     71 		jtest_source = bld.path.ant_glob('jni/test/*.xml'),
     72 	)
     73 
     74 
     75 	bld.add_post_fun(test_results)
     76