scons on windows その2(tolua++のSConstructを読む)

tolua++がSConstructを使っているので読んでみる。
とりあえずビルドしてみる。
Visual studio コマンドプロンプト」で開始。

> cd \work\tolua++-1.0.93
> scons
scons: Reading SConscript files ...

scons: warning: The Options class is deprecated; use the Variables class instead
.
File "C:\work\tolua++-1.0.93\SConstruct", line 19, in <module>
('********* tolua is ', 'bin\\tolua++_bootstrap.exe')

scons: warning: The env.Copy() method is deprecated; use the env.Clone() method
instead.
File "C:\work\tolua++-1.0.93\src\tests\SCsub", line 2, in <module>
scons: done reading SConscript files.
scons: Building targets ...
gcc -o src\bin\tolua.o -c -O2 -ansi -Wall -Iinclude src\bin\tolua.c
'gcc' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。
scons: *** [src\bin\tolua.o] Error 1
scons: building terminated because of errors.

見難いのでwarningをどける。
SConstruct
Options -> Variables
src/tests/SCsub
Copy -> Clone


再度

> scons
scons: Reading SConscript files ...
('********* tolua is ', 'bin\\tolua++_bootstrap.exe')
scons: done reading SConscript files.
scons: Building targets ...
gcc -o src\bin\tolua.o -c -O2 -ansi -Wall -Iinclude src\bin\tolua.c
'gcc' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。
scons: *** [src\bin\tolua.o] Error 1
scons: building terminated because of errors.

gccが無いと言われる。MinGWが期待されているわけですな。しかし、config_msvc.pyというファイルもあるのでmsvcでもビルドできそう。
SConstructの冒頭に

import sys;
import os

tools = ['default']
if os.name == 'nt':
	tools = ['mingw']

env = Environment(tools = tools)

という記述があった。おぉ、mingw決め打ちだ。
コメントアウトしてみる。

#if os.name == 'nt':
#	tools = ['mingw']

実行

scons: Reading SConscript files ...
('********* tolua is ', 'bin\\tolua++_bootstrap.exe')
scons: done reading SConscript files.
scons: Building targets ...
cl /Fosrc\bin\tolua.obj /c src\bin\tolua.c /nologo /Iinclude
tolua.c
include\tolua++.h(46) : fatal error C1083: include ファイルを開けません。'lua.h'
: No such file or directory
scons: *** [src\bin\tolua.obj] Error 2
scons: building terminated because of errors.

ちゃんとcl.exeを使うようになった。

ビルド通す

luaのソースを展開してビルドする。

> cd \work\lua-5.1.4
> etc\luavs.bat

custom.py

CCFLAGS = ['-I../lua-5.1.4/src']
LIBPATH = ['../../../lua-5.1.4/src']
LIBS = ['lua51']
> cd \work\tolua++-1.0.93
> copy ..\lua-5.1.4\src\lua51.dll .
>scons
〜省略〜
lib /nologo /OUT:lib\tolua++.lib src\lib\tolua_event.obj src\lib\tolua_is.obj sr
c\lib\tolua_map.obj src\lib\tolua_push.obj src\lib\tolua_to.obj
link /nologo /OUT:bin\tolua++.exe /LIBPATH:lib /LIBPATH:C:\work\lua-
5.1.4\src tolua++.lib lua51.lib src\bin\tolua.obj src\bin\toluabind.obj
scons: done building targets.

メモ

tolua++のSConstructはけっこう盛りだくさんなのだった・・・

env生成
Variablesでオプション定義
Help
custom.py
サブディレクトリの
src/lib/SCsub
src/bin/SCsub
src/tests/SCsub
を読み込み
Alias
Default
Command