2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-24 18:59:39 +01:00

Made this project build on Linux

This commit is contained in:
Thomas Nagy 2016-01-03 06:53:20 +01:00
parent 8083205b81
commit 69e51290fd
6 changed files with 81 additions and 45 deletions

View File

@ -1,11 +1,16 @@
#! /usr/bin/env python
from cffi import FFI
import os.path
import re
_ffi = FFI()
pat = '%s.dll'
if os.sep == '/':
pat = 'lib%s.so'
_apifile = os.path.join(os.path.dirname(__file__),'funi.h')
_dllname = os.path.join(os.path.split(__file__)[0],'funi.dll')
_dllname = os.path.join(os.path.split(__file__)[0], pat % 'funi')
def _api():
with open(_apifile) as f:
api = f.readlines()

View File

@ -1,18 +1,17 @@
#! /usr/bin/env python
# encoding: utf-8
#vim syntax=python
from build import *
funi = bld.env.dllname
gui = bld.env.guiname+'.exe'
funidll = funi +'.dll'
csdll = bld.env.dllname+'_cs.dll'
bld(rule=stpl,source='funi.c.stpl',target='funi.c')
bld(rule=stpl,source='funi.h.stpl',target='funi.h')
bld(rule=stpl,source='funi_cs.cs.stpl',target='funi_cs.cs')
bld(rule=stpl,source='funi.py.stpl',target='funi.py')
bld(rule=stpl,source='test_funi.py.stpl',target='test_funi.py')
bld(rule=stpl,source='test_funi.cpp.stpl',target='test_funi.cpp')
bld(rule=bld.stpl,source='funi.c.stpl',target='funi.c')
bld(rule=bld.stpl,source='funi.h.stpl',target='funi.h')
bld(rule=bld.stpl,source='funi_cs.cs.stpl',target='funi_cs.cs')
bld(rule=bld.stpl,source='funi.py.stpl',target='funi.py')
bld(rule=bld.stpl,source='test_funi.py.stpl',target='test_funi.py')
bld(rule=bld.stpl,source='test_funi.cpp.stpl',target='test_funi.cpp')
bld.add_group()
@ -24,10 +23,10 @@ bld.shlib(
bld.program(
source = 'test_funi.cpp',
includes = ['.'],
target = 'test_funi.exe',
target = 'test_funi',
use = funi)
bld.add_group()
bld(features='cs',source='funi_cs.cs',gen=csdll,includes='.')
bld(features='cs',source='funi_cs.cs',gen=csdll,includes='.', name='csdll')

View File

@ -1,3 +1,6 @@
#! /usr/bin/env python
# encoding: utf-8
import sys
import os
import codecs
@ -12,11 +15,14 @@ def stpl(tsk):
st=bottle.template(name,template_lookup=[lookup], company = bld.env.company, guiname=bld.env.guiname, version=bld.env.version,
dllname=bld.env.dllname, maxfuni=bld.env.maxfuni)
with codecs.open(pt,mode='w',encoding="utf-8") as f: f.write(st)
os.chmod(pt, 493)
#for files that will be created
def cp(self):
shutil.copy(self.inputs[0].abspath(),self.outputs[0].abspath())
# copy files that already exist
def src2bld(self, filename):
self(features='subst', source=filename, target=filename, is_copy=True)
#for files that already exist
src2bld = lambda bld,x: shutil.copy(bld.path.find_node(x).abspath(), bld.path.get_bld().make_node(x).write('').abspath())
def build(bld):
# clean initialization
bld.src2bld = src2bld
bld.stpl = stpl

View File

@ -1,26 +1,34 @@
#! /usr/bin/env python
# encoding: utf-8
#vim syntax=python
import sys
import shutil
import os
sys.path += [os.getcwd()]
from build import *
import os, sys, shutil
from waflib import Utils
bld.add_group()
funigui = ctx.env.guiname+'.exe'
funidll = ctx.env.dllname+'.dll'
csdll = ctx.env.dllname+'_cs.dll'
funi = bld.path.find_or_declare(funidll)
funi_cs = bld.path.find_or_declare(csdll)
bld(rule=cp, source=bld.path.get_bld().make_node('../api/'+funidll) , target=funi )
bld(rule=cp, source=bld.path.get_bld().make_node('../api/'+csdll) , target=funi_cs)
src2bld(bld,'Resources/Icon1.ico')
# obtain the file names to copy
from waflib import TaskGen
@TaskGen.feature('copy_over')
@TaskGen.before_method('process_subst')
def get_filenames_to_copy_from_task_generators(self):
src = self.bld.get_tgen_by_name(self.from_tg).tasks[-1].outputs[0]
self.source = [src]
self.target = [src.name]
self.is_copy = True
bld(rule=stpl,source='AssemblyInfo.cs.stpl',target='AssemblyInfo.cs')
# just copy the files to this folder
bld(features='copy_over subst', from_tg='funi')
bld(features='copy_over subst', from_tg='csdll')
# copy the same file to the build directory
bld.src2bld(bld, 'Resources/Icon1.ico')
bld(rule=bld.stpl,source='AssemblyInfo.cs.stpl',target='AssemblyInfo.cs')
bld.add_group()
@ -35,6 +43,18 @@ refs = """
System
System.Core
System.Windows.Forms
System.Xml
System.Xml.Linq
System.Data
System.Data.DataSetExtensions
System.Drawing
""".strip().split()
if Utils.is_win32:
refs = """
System
System.Core
System.Windows.Forms
System.Linq
System.RunTime.InteropServices
System.Xml
@ -53,9 +73,10 @@ def csflag(x):
CSFLAGS+=[x]
csflag(r'/platform:x64')
csflag(r'/errorreport:prompt')
csflag(r'/errorendlocation')
csflag(r'/preferreduilang:en-US')
csflag(r'/highentropyva-')
if Utils.is_win32:
csflag(r'/errorendlocation')
csflag(r'/preferreduilang:en-US')
csflag(r'/highentropyva-')
csflag(r'/debug:pdbonly')
csflag(r'/filealign:512')
csflag(r'/define:'+ctx.env.guiname[1:]) #EstimPRO or EstimRESEARCH
@ -77,4 +98,5 @@ bld(features='cs',source=src,gen=funigui,csflags=CSFLAGS,use=[r+'.dll' for r in
bld.add_group()
bld(features='satellite_assembly',source='Resources/resources.fr.txt',gen=funigui)
bld(features='satellite_assembly',source='Resources/resources.fr.txt', gen=funigui)

View File

@ -10,14 +10,16 @@
# - GUI localization via satellite assemblies
# - Wrapper for Python
#
# Python libs required: bottle, cffi
# Python libs required: bottle, cffi, pytest
#
# This project requires plenty of applications and libraries such as:
# gcc, mono-devel, pytest, cffi
# LD_LIBRARY_PATH=$PWD/../build/api/: PATH=$PATH:$LD_LIBRARY_PATH waf configure build test --stubs
#
import sys
import os
import os.path
import shutil
sys.path += [os.getcwd()]
from waflib import Utils
import sys, os, shutil
APPNAME = "funigui"
DLLNAME = "funi"
@ -37,7 +39,7 @@ PYTEST = ''
def configure (ctx):
global PYTEST
try:
PYTEST = ctx.find_program('py.test') [0]
PYTEST = ctx.find_program('py.test')[0]
except:
PYTEST = ctx.find_program('py.test',path_list=[r'C:\Python35\Scripts']) [0]
@ -48,7 +50,7 @@ def configure (ctx):
ctx.env.append_value('DEFINES',['NDEBUG'])
ctx.load('compiler_c compiler_cxx cs resx satellite_assembly')
if sys.platform != 'linux':
if Utils.is_win32:
ctx.load('wix')
if ctx.env['CC_NAME'] == 'msvc':
@ -71,17 +73,19 @@ def configure (ctx):
ctx.env.dllname = DLLNAME
ctx.env.maxfuni = MAXFUNI
ctx.env.company = COMPANY
ctx.load('print_commands')
def build(ctx):
ctx.load('build', tooldir='.') # additional stuff
ctx.recurse('api')
ctx.recurse('gui')
if sys.platform != 'linux':
if Utils.is_win32:
ctx.recurse('msi')
def test(ctx):
if ctx.options.stubs:
cwd = ctx.path.find_node('../build/api').abspath()
print('running test in ',cwd)
ctx.cmd_and_log(os.path.join(cwd,'test_funi.exe'),cwd=cwd)
ctx.cmd_and_log(os.path.join(cwd,'test_funi'),cwd=cwd)
ctx.cmd_and_log(PYTEST+' test_funi.py',cwd=cwd)

View File

@ -76,7 +76,7 @@ def wix_bin_path():
for i in range(cnt-1,-1,-1):
thiskey = winreg.EnumKey(query,i)
if 'WiX' in thiskey:
break;
break
winreg.CloseKey(query)
return os.path.normpath(winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, basekey+r'\\'+thiskey)+'..\\bin')