hammer/src/bindings/dotnet/SConscript
2014-01-04 23:13:35 +01:00

53 lines
2.5 KiB
Python

# -*- python -*-
import os.path
Import("env libhammer_shared testruns targets")
dotnetenv = env.Clone()
dotnetenv.Append(CCFLAGS=["-fpic", '-DSWIG', '-Wno-all',
'-Wno-extra', '-Wno-error',
'-DHAMMER_INTERNAL__NO_STDARG_H'],
CPPPATH=["../.."],
LIBS=['hammer'],
LIBPATH=["../.."],
SWIGFLAGS=["-DHAMMER_INTERNAL__NO_STDARG_H",
"-Isrc/", "-csharp",
"-dllimport","hammer_dotnet",
"-namespace", "Hammer.Internal"])
import os
swig = ['hammer.i']
thisdir = os.path.join(os.path.dirname(str(libhammer_shared[0])), "bindings","dotnet")
csfiles = os.path.join(thisdir, "*.cs")
# These AlwaysBuilds are annoying, but alas there doesn't seem to be a
# better way. I'd love to be corrected. Send PRs!
# This also generates a bunch of .cs files, which we'll just use this
# target to stand in for.
hammer_wrap = AlwaysBuild(dotnetenv.Command(['hammer_wrap.c'], swig,
["rm %s/*.cs || true" % (thisdir,),
"swig $SWIGFLAGS $SOURCE"]))
libhammer_dotnet = dotnetenv.SharedLibrary(['hammer_dotnet'], hammer_wrap)
hammer_dll = AlwaysBuild(dotnetenv.Command(['hammer.dll'], Glob('ext/*.cs'),
'$CSC -t:library -unsafe -out:$TARGET %s/*.cs $SOURCE' %(thisdir,)))
Depends(hammer_dll, hammer_wrap)
#hammer_dll = dotnetenv.CLILibrary('hammer.dll', hammer.cs)
Default(libhammer_dotnet, hammer_dll)
dotnettestenv = dotnetenv.Clone()
#dotnettestenv['ENV']['LD_LIBRARY_PATH'] = os.path.dirname(str(libhammer_shared[0]))
#dotnettests = ['t/hammer.t']
dotnettestenv.Append(CILLIBS=['/usr/lib/cli/nunit.core-2.6/nunit.core.dll','/usr/lib/cli/nunit.util-2.6/nunit.util.dll','/usr/lib/cli/nunit.framework-2.6/nunit.framework.dll','/usr/lib/cli/nunit.core.interfaces-2.6/nunit.core.interfaces.dll', "src/bindings/dotnet/hammer.dll"])
dotnettestlib = dotnettestenv.CLILibrary('hammer_test.dll', Glob('test/*.cs'))
Depends(dotnettestlib, hammer_dll)
dotnettestexec = dotnettestenv.Command(None, dotnettestlib, "nunit-console $SOURCE")
dotnettest = Alias("testdotnet", [dotnettestexec], dotnettestexec)
AlwaysBuild(dotnettestexec)
testruns.append(dotnettestlib)
#dotnetinstallexec = dotnetenv.Command(None, libhammer_dotnet, "make install -C " + targetdir)
#dotnetinstall = Alias("installdotnet", [dotnetinstallexec], dotnetinstallexec)
#targets.append(dotnetinstall)