2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-12-25 02:35:04 +01:00

Merge pull request #1566 from yag00/master

swig tool can handle -outdir parameter
This commit is contained in:
ita1024 2015-05-03 19:30:05 +02:00
commit a3b8ba5d03
2 changed files with 20 additions and 21 deletions

View File

@ -92,10 +92,10 @@ def build(bld):
from waflib.extras import swig
srcdir = bld.path.get_bld().make_node('extend/java/hmm') # destination for generated java file (without the packages!)
srcdir = bld.path.get_bld().make_node('extend/java') # destination for generated java file
#""" # BEGIN BLOCK 1
d = bld.path.make_node('extend/java')
d = bld.path.make_node('extend/java/foo/bar/pouet')
javanodes = [d.find_or_declare(x) for x in 'A.java test_swig_waf.java test_swig_wafJNI.java'.split()]
dec = bld.tools['swig'].swigf
#@dec <- python 2.3 does not support the @decorator notation
@ -106,23 +106,17 @@ def build(bld):
#"""# do not remove
bld(
features = 'cxx cxxshlib',
source = 'extend/java/test_swig_waf.i',
target = 'extend/java/_test_swig_waf',
swig_flags = '-c++ -java -package foo.bar.pouet',
swig_flags = '-c++ -java -package foo.bar.pouet -outdir extend/java/foo/bar/pouet',
includes = 'extend',
vnum = '1.2.3',
uselib = 'JAVA',
use = 'mylib')
#""" # BEGIN BLOCK 2
for x in javanodes:
bld(rule='cp ${SRC} ${TGT}', source=x,
target=srcdir.make_node('foo/bar/pouet/' + x.name), before=['javac'], after=['swig'])
""" # END BLOCK 2
def move_java_files(task):
@ -130,22 +124,18 @@ def build(bld):
from waflib import Utils
node = srcdir.make_node('foo/bar/pouet/')
node.mkdir()
orig = task.inputs[0].parent.get_bld().abspath()
files = Utils.listdir(orig)
files = Utils.listdir(node.abspath())
for x in files:
if x.endswith('.java'):
# create a node in the directory we want to
j = node.make_node(x) # create a node
shutil.copy2(orig + os.sep + x, j.abspath()) # create the physical file for the node
j.sig = Utils.h_file(j.abspath()) # update the node signature
# depend on the .i file to make sure the .java files are copied after swig is executed
bld(name='move_and_read', rule=move_java_files, source='extend/java/test_swig_waf.i', after=['swig'], before=['javac'])
#"""
bld(rule='cp ${SRC} ${TGT}', source=bld.path.find_resource('extend/java/Foo.java'),
target=srcdir.make_node('foo/bar/pouet/Foo.java'), before=['javac'], after=['swig'])
bld(rule='cp ${SRC} ${TGT}', source=bld.path.find_resource('extend/java/Foo.java'), target=srcdir.make_node('foo/bar/pouet/Foo.java'), before=['javac'], after=['swig'])
tmp = bld.path.get_bld().make_node('maha')

View File

@ -130,12 +130,18 @@ def swig_c(self):
@swigf
def swig_python(tsk):
tsk.set_outputs(tsk.inputs[0].parent.find_or_declare(tsk.module + '.py'))
node = tsk.inputs[0].parent
if tsk.outdir:
node = tsk.outdir
tsk.set_outputs(node.find_or_declare(tsk.module+'.py'))
@swigf
def swig_ocaml(tsk):
tsk.set_outputs(tsk.inputs[0].parent.find_or_declare(tsk.module + '.ml'))
tsk.set_outputs(tsk.inputs[0].parent.find_or_declare(tsk.module + '.mli'))
node = tsk.inputs[0].parent
if tsk.outdir:
node = tsk.outdir
tsk.set_outputs(node.find_or_declare(tsk.module+'.ml'))
tsk.set_outputs(node.find_or_declare(tsk.module+'.mli'))
@extension(*SWIG_EXTS)
def i_file(self, node):
@ -147,9 +153,12 @@ def i_file(self, node):
flags = self.to_list(getattr(self, 'swig_flags', []))
tsk.env.append_value('SWIGFLAGS', flags)
# looks like this is causing problems
#if not '-outdir' in flags:
# tsk.env.append_value('SWIGFLAGS', ['-outdir', node.parent.abspath()])
tsk.outdir = None
if '-outdir' in flags:
outdir = flags[flags.index('-outdir')+1]
outdir = tsk.generator.bld.bldnode.make_node(outdir)
outdir.mkdir()
tsk.outdir = outdir
@conf
def check_swig_version(self):