Skip to content
This repository was archived by the owner on Apr 5, 2020. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e4cfc95

Browse files
committedOct 31, 2013
外部リポジトリは無駄に難しいのでやめた
1 parent 5c51a2f commit e4cfc95

File tree

5 files changed

+305
-3
lines changed

5 files changed

+305
-3
lines changed
 

‎bld.sh

+178-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,179 @@
11
#! /bin/bash
2-
# externalの共通ファイルをそのままincludeして使う。
3-
. $(cd $(dirname $0);pwd)/external/WafHelper/bld.sh
2+
# -*- coding: utf-8 -*-
3+
# Donut-lang
4+
#
5+
# Copyright 2012-2013, PSI
6+
7+
if [ -z $PYTHON ]; then
8+
PYTHON=python
9+
fi
10+
11+
DIRNAME=$(cd $(dirname $0);pwd)
12+
if [ -z $BUILDDIR ]; then
13+
BUILDDIR=$DIRNAME/build
14+
fi
15+
16+
if [ -z $CCACHE ]; then
17+
CCACHE='ccache'
18+
fi
19+
20+
function detectCompiler() {
21+
echo "------------------------------------------------------------"
22+
echo "detecting compiler"
23+
echo "------------------------------------------------------------"
24+
25+
CCACHE_OK=0
26+
if [ -n "$CC" -a -n "$CXX" ]; then
27+
echo "[custom] using $CC and $CXX"
28+
if echo "$CXX" | grep -- "g++" > /dev/null 2>&1; then #gccである
29+
CCACHE_OK=1
30+
fi
31+
elif which clang++ > /dev/null 2>&1; then
32+
echo "[clang] found."
33+
export set CC='clang'
34+
export set CXX='clang++'
35+
elif which g++ > /dev/null 2>&1; then
36+
echo "[gcc] found."
37+
export set CC='gcc'
38+
export set CXX='g++'
39+
CCACHE_OK=1
40+
else
41+
echo "Compiler not found."
42+
exit -1
43+
fi
44+
45+
if test $CCACHE_OK -ne 0 && which $CCACHE > /dev/null 2>&1; then
46+
echo "[ccache] found."
47+
export set CC="$CCACHE $CC"
48+
export set CXX="$CCACHE $CXX"
49+
else
50+
echo "[cchache] not found."
51+
fi
52+
echo "CC =" $CC
53+
echo "CXX =" $CXX
54+
echo "------------------------------------------------------------"
55+
}
56+
57+
function runConfig() {
58+
echo "------------------------------------------------------------"
59+
echo "cleaning"
60+
echo "------------------------------------------------------------"
61+
echo "%" $PYTHON waf distclean
62+
$PYTHON waf distclean
63+
echo "------------------------------------------------------------"
64+
echo "configureing"
65+
echo "------------------------------------------------------------"
66+
if [ "$MSYSTEM" = "MINGW32" -o "$OS" = "Windows_NT" ] ; then
67+
CONFIGURE_CMD="$PYTHON waf configure --out $BUILDDIR $CONF_OPT"
68+
else
69+
CONFIGURE_CMD="$PYTHON waf configure --out $BUILDDIR $CONF_OPT"
70+
fi
71+
echo "%" $CONFIGURE_CMD
72+
$CONFIGURE_CMD
73+
res=$?
74+
echo "------------------------------------------------------------"
75+
return $res
76+
}
77+
78+
function ensureConfigure() {
79+
if test -d $BUILDDIR && $PYTHON ./waf list > /dev/null 2>&1
80+
then
81+
echo "configured"
82+
return 0
83+
fi
84+
echo "not configured"
85+
detectCompiler
86+
runConfig
87+
}
88+
89+
function parse() {
90+
if echo "$1" | grep -- "-.*" > /dev/null 2>&1; then #オプションである
91+
return 1
92+
elif [ "$1" = "debug" ] ; then
93+
MODE=$1
94+
elif [ "$1" = "release" ] ; then
95+
MODE=$1
96+
elif [ "$1" = "build" ] ; then
97+
TARGET=$1
98+
elif [ "$1" = "clean" ] ; then
99+
TARGET=$1
100+
elif [ "$1" = "install" ] ; then
101+
TARGET=$1
102+
elif [ "$1" = "uninstall" ] ; then
103+
TARGET=$1
104+
elif [ "$1" = "all" ] ; then
105+
LAUNCH="all"
106+
elif [ "$1" = "test" ] ; then
107+
LAUNCH="test"
108+
elif [ "$1" = "update" ] ; then
109+
LAUNCH="update"
110+
elif [ ! -z "$1" ]; then
111+
LAUNCH="custom"
112+
return 1
113+
fi
114+
return 0
115+
}
116+
117+
# parsing command line
118+
LAUNCH="normal"
119+
parse $1 && shift
120+
parse $1 && shift
121+
if [ -z "$MODE" ]; then
122+
MODE="debug"
123+
fi
124+
if [ -z "$TARGET" ]; then
125+
TARGET="build"
126+
fi
127+
128+
#launching main task
129+
if [ $LAUNCH = "normal" ]; then
130+
WAF_CMD="$PYTHON ./waf --out $BUILDDIR ${TARGET}_${MODE} $*"
131+
ensureConfigure
132+
if [ $? -eq 0 ]; then
133+
echo "============================================================"
134+
echo "Normal launch"
135+
echo "mode =" $MODE
136+
echo "target =" $TARGET
137+
echo "============================================================"
138+
echo "%" $WAF_CMD
139+
$WAF_CMD
140+
else
141+
echo "build faled to configure."
142+
exit 1
143+
fi
144+
elif [ $LAUNCH = "all" ]; then
145+
WAF_CMD="$PYTHON ./waf --out $BUILDDIR build_debug build_release $*"
146+
ensureConfigure
147+
if [ $? -eq 0 ]; then
148+
echo "============================================================"
149+
echo "all"
150+
echo "mode = build"
151+
echo "target = release, debug"
152+
echo "============================================================"
153+
echo "%" $WAF_CMD
154+
$WAF_CMD
155+
else
156+
echo "build faled to configure."
157+
exit 1
158+
fi
159+
elif [ $LAUNCH = "test" ] ;then
160+
echo "============================================================"
161+
echo "Run test"
162+
echo "============================================================"
163+
if [ -e runtest.sh ] ;then
164+
echo "%" sh runtest.sh
165+
sh runtest.sh
166+
else
167+
echo "runtest.sh not found."
168+
exit 1
169+
fi
170+
elif [ $LAUNCH = "update" ] ;then
171+
git submodule foreach 'git pull --rebase origin master'
172+
elif [ $LAUNCH = "custom" ] ;then
173+
echo "============================================================"
174+
echo "Custom launch"
175+
echo "============================================================"
176+
WAF_CMD="$PYTHON ./waf --out $BUILDDIR $*"
177+
echo "%" $WAF_CMD
178+
$WAF_CMD
179+
fi

‎external/WafHelper

-1
This file was deleted.

‎external/WafHelper/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__
2+
*.pyc

‎external/WafHelper/Util.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Donut
4+
#
5+
# Copyright 2012-2013, PSI
6+
7+
import os
8+
import sys
9+
from waflib.Configure import conf
10+
11+
def enum(dirname, exclude=[], exts=['.cpp','.c']):
12+
'''
13+
指定したディレクトリ以下のファイルを列挙する
14+
'''
15+
dirname = os.path.join(*(dirname.split('/')))
16+
f = []
17+
for root,dirs,files in os.walk(dirname):
18+
matched = False
19+
for e in exclude:
20+
if root.startswith(e):
21+
matched = True
22+
break
23+
if matched:
24+
continue
25+
for fitem in files:
26+
fabs = os.path.join(root, fitem)
27+
_, ext = os.path.splitext(fabs)
28+
if ext in exts:
29+
f.append(os.path.relpath(fabs))
30+
return f
31+
32+
# from http://docs.waf.googlecode.com/git/book_16/single.html#_custom_build_outputs
33+
from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext
34+
for x in 'debug release'.split():
35+
for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
36+
name = y.__name__.replace('Context','').lower()
37+
class tmp(y):
38+
cmd = name + '_' + x
39+
variant = x

‎external/WafHelper/cinamo.py

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Donut
4+
#
5+
# Copyright 2012-2013, PSI
6+
7+
import os
8+
from waflib.Configure import conf
9+
10+
def options(opt):
11+
opt.add_option('--with-cinamo', type='string', default='', dest='cinamo', help='''path to cinamo project dir''')
12+
13+
@conf
14+
def check_cinamo(ctx, *k ,**kw):
15+
mandatory = kw.get('mandatory', True)
16+
cpath = None
17+
if ctx.options.cinamo != '':
18+
cpath = ctx.options.cinamo
19+
elif 'cinamo' in kw:
20+
cpath=kw['cinamo']
21+
else:
22+
cpath=None
23+
store = kw.get('uselib_store', 'CINAMO')
24+
25+
have_cinamo=False
26+
if cpath:
27+
cpath=ctx.options.cinamo;
28+
# まずブーストを使っているかどうかを先にチェック
29+
useboost = ctx.check(features='cxx cxxprogram',
30+
compile_filename='tmp.cpp',
31+
cxxflags=['-I'+os.path.join(cpath, 'build', ctx.variant)],
32+
mandatory=False,
33+
execute=True,
34+
use=store,
35+
msg='checking whether cinamo is built with boost',
36+
code='''
37+
#include <config.h>
38+
int main(){
39+
return !HAVE_BOOST;
40+
}
41+
''');
42+
if useboost:
43+
ctx.env.append_value('CXXFLAGS', ['-DBOOST_THREAD_USE_LIB=1'])
44+
ctx.check_boost(lib='system thread chrono', uselib_store=store, mandatory=True)
45+
# そして残りのチェック
46+
lib = ctx.check(features='cxx cxxprogram',
47+
lib=['cinamo'],
48+
linkflags=['-L'+os.path.join(cpath, 'build', ctx.variant)],
49+
mandatory=False,
50+
uselib_store=store,
51+
msg='checking cinamo libs')
52+
header = ctx.check(features='cxx cxxprogram',
53+
header_name='cinamo/Cinamo.h',
54+
cxxflags=['-I'+os.path.join(cpath, 'include'), '-I'+os.path.join(cpath, 'external', 'tinyxml2')],
55+
mandatory=False,
56+
msg='checking cinamo header',
57+
uselib_store=store)
58+
ctx.check(features='cxx cxxprogram',
59+
header_name='tinyxml2.h',
60+
cxxflags=['-I'+os.path.join(cpath, 'external', 'tinyxml2')],
61+
mandatory=False,
62+
msg='checking cinamo tinyxml2 header',
63+
uselib_store=store)
64+
cfg = ctx.check(features='cxx cxxprogram',
65+
header_name='config.h',
66+
cxxflags=['-I'+os.path.join(cpath, 'build', ctx.variant)],
67+
mandatory=False,
68+
msg='checking cinamo config header',
69+
uselib_store=store)
70+
exlib = ctx.check_cfg(
71+
package='icu-uc icu-i18n',
72+
uselib_store=store,
73+
mandatory=False,
74+
args='--cflags --libs')
75+
if header and lib and cfg and exlib:
76+
have_cinamo=True
77+
ctx.define(ctx.have_define(store), 1 if have_cinamo else 0)
78+
if (not have_cinamo) and ctx.check_cfg(package='cinamo', uselib_store=store, mandatory=False, args='--cflags --libs'):
79+
have_cinamo=True
80+
if (not have_cinamo) and mandatory:
81+
ctx.fatal('Failed to find cinamo!')
82+
return have_cinamo
83+
84+
def configure(ctx):
85+
pass
86+

0 commit comments

Comments
 (0)
This repository has been archived.