Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for variants #53

Merged
merged 1 commit into from
Oct 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 23 additions & 50 deletions waf_tools/sferes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,31 @@
print "WARNING simplejson not found some function may not work"

import glob
#import xml.etree.cElementTree as etree



def create_variants(bld, source, use, target,
uselib, variants, includes=". ../../",
def create_variants(bld, source, use,
uselib, variants, includes=". ../ ../../",
cxxflags='',
json=''):
# the basic one
# tgt = bld.new_task_gen('cxx', 'program')
# tgt.source = source
# tgt.includes = includes
# tgt.uselib_local = uselib_local
# tgt.uselib = uselib
# tgt.target = target
# the variants
if not target:
tmp = source.replace('.cpp', '')
else:
tmp = target
bld.program(features='cxx',
source=source,
target=tmp,
includes=includes,
uselib=uselib,
use=use)
c_src = bld.path.abspath() + '/'
for v in variants:
# create file
suff = ''
for d in v.split(' '):
suff += d.lower() + '_'
src_fname = tmp + '_' + suff[0:len(suff) - 1] + '.cpp'
bin_fname = tmp + '_' + suff[0:len(suff) - 1]
f = open(c_src + src_fname, 'w')
f.write("// THIS IS A GENERATED FILE - DO NOT EDIT\n")
for d in v.split(' '):
f.write("#define " + d + "\n")
f.write("#line 1 \"" + c_src + source + "\"\n")
code = open(c_src + source, 'r')
for line in code:
f.write(line)
bin_name = src_fname.replace('.cpp', '')
bin_name = os.path.basename(bin_name)
# create build
bld.program(features='cxx',
source=src_fname,
target=bin_fname,
includes=includes,
uselib=uselib,
use=use)

target=''):
source_list = source.split()
if not target:
tmp = source_list[0].replace('.cpp', '')
else:
tmp = target
for v in variants:
deff = []
suff = ''
for d in v.split(' '):
suff += d.lower() + '_'
deff.append(d)
bin_fname = tmp + '_' + suff[0:len(suff) - 1]
bld.program(features='cxx',
source=source,
target=bin_fname,
includes=includes,
uselib=uselib,
cxxflags=cxxflags,
use=use,
defines=deff)

def create_exp(name):
ws_tpl = """
Expand Down