waf ãã¥ã¼ããªã¢ã«
waf - The flexible build system http://code.google.com/p/waf/
wafã¨ãããã®ãæè¿ç¥ãä¸ç®æããã¦ãã¾ã£ãã®ã§ãç´¹ä»è¨äºãæ¸ãã¾ããã¦ã¼ã¶ã¼ãå¢ããã¨å¬ãããªã
wafã¨ã¯ä½ãï¼ç¹å¾´ã»å©ç¹ã»ä½¿ãã¹ãçç±
wafã¯Pythonãã¼ã¹ã®ãã«ãã·ã¹ãã ã§ããåæ§ã®ãã¨ãè¡ããã¼ã«ã¨ãã¦ãAutotoolsãSconsãCMakeãAntãªã©ãããã¾ããSconsããã®æ´¾çã§ãæ¯è¼çæ°ããã½ããã¦ã§ã¢ã§ãã
- åããããã
Pythonã§æ¸ããã¦ãããã¹ã¯ãªãããPythonã§è¨è¿°ãã¾ããã·ã§ã«ã¹ã¯ãªããã¨è¬ã®ãã¯ããå ¥ãæ··ããAutotoolsããç¬èªè¨èªã®CMakeãªã©ã«æ¯ã¹ã¦æ±ãæãã§ããPythonãç¥ã£ã¦ããã°é常ã«ãããªãã¨ä½¿ãããªããã¨ãåºæ¥ã¾ããPythonãç¥ããªãã¦ããä»ã®ç¬èªè¨èªãè¦ããããã¯å®ãããããã¨æãã¾ããPythonã§è¨è¿°ãã¾ãã®ã§ãèªåã§æ©è½ãæ¡å¼µãããã¨ãé常ã«ç°¡åã«ã§ãã¾ãããã®ãããã¯Autotoolsã«è¦ãããããçµé¨ã®ããæ¹ãªãæãæåãªä¹ãæãçç±ã«ãªãã¨æãã¾ãã
- é å¸ãããã
Pythonã§æ¸ããã¦ããã®ã§ãPythonã®ã¤ã³ã¹ãã¼ã«ããã¦ããã·ã¹ãã ã§ãªãã©ãã§ãåä½ãã¾ããå¹ åºããã¼ã¸ã§ã³ã®Pythonã§åä½ãã¾ããä»ãPythonã¯ã»ã¨ãã©ã®Linuxã«ããã©ã«ãã§ã¤ã³ã¹ãã¼ã«ããã¦ãã¾ãããWindowsãMacãªã©ã§ãPythonãå ¥ã£ã¦ããã°åä½ããããã¨ãã§ãã¾ããwafã¯80KBç¨åº¦ã®åä¸ã®Pythonã¹ã¯ãªããã§ãBSDã©ã¤ã»ã³ã¹ãªã®ã§ãããã¸ã§ã¯ãã«å«ãã¦é å¸ãããã¨ã容æã§ããwafãå梱ãã¦é å¸ãããã¨ã«ããAutotoolsãªã©ã§ã¯èµ·ãããã¡ãªãã¼ã¸ã§ã³åé¡ãèµ·ããã¾ããï¼Autotoolsã§ã¯configureã§é å¸ããã¨ã¯æãã¾ããï¼ãconfigureã¹ã¯ãªããã®ã©ãããããã®ã§ããããç¨ããã¨ãLinuxæåã§ã®æ¨æºçãªã½ããã¦ã§ã¢ã®ã¤ã³ã¹ãã¼ã«æ¹æ³ã§ãã configure; make; make install ã«ãç°¡åã«å¯¾å¿ãããã¨ãã§ãã¾ãã
- é«éã«åä½ãã
configureãé常ã«é«éã«è¡ããã¾ããccacheã®ãããªãªãã¸ã§ã¯ããã£ãã·ã¥ã並åã³ã³ãã¤ã«ã®æ¨æºãµãã¼ãã«ãããã³ã³ãã¤ã«ãé«éã§ãã
- å¤ãã®è¨èªã®çµã¿è¾¼ã¿ãµãã¼ã
CãC++ãDãJavaãOCamlããªã©ã®ããã°ã©ãã³ã°è¨èªã®ã³ã³ãã¤ã«ãä¾å解æãå®è¡ããµãã¼ãããã¦ãã¾ããæ°ããè¨èªã®ãµãã¼ããæ¯è¼ç容æã§ãã
- åºåãåããããã
åºåãã«ã©ã¼ã§ã失æããã¨èµ¤ã表示ãããã®ã§ãã³ã³ãã¤ã«çµæãããããããã§ããã¾ããã³ã³ãã¤ã«ãã¹ããã¡ã¤ã«ãããã¤æã£ã¦ãç¾å¨ä½åç®ã®ãã¡ã¤ã«ãã³ã³ãã¤ã«ãã¦ãããã表示ãããã®ã§ãã³ã³ãã¤ã«ã®é²æç¶æ³ãããããããã§ããã³ã³ãã¤ã«ã®é²æãããã°ã¬ã¹ãã¼ã§è¡¨ç¤ºããæ©è½ããã£ã¦ãè¦ã¦ãã¦æ¥½ããã§ãã
wafã®æ©è½
- configure, build, install, uninstall
- ããã±ã¼ã¸ä½æ
- ã¦ããããã¹ãæ¯æ´
- ãã£ã¬ã¯ããªç£è¦ã«ããèªååã³ã³ãã¤ã«
ãªã©ãæ¨æºã§ãµãã¼ãããã¦ãã¾ããä¸éãæã£ã¦ããã¨æãã¾ãããã«ããã§ã¼ãºã追å ãããã¨ã容æã§ãã
ã¤ã³ã¹ãã¼ã«
wafãã¤ã³ã¹ãã¼ã«ããã®ã¯ä»¥ä¸ã®çç±ããæ¨å¥¨ããã¾ããã
- adminãè¦ãã»ããã©ã
- ãã¼ã¸ã§ã³åé¡
- wafãå梱ããªãçç±ããªã
- Windowsã«ã¯ã¤ã³ã¹ãã¼ã«ã§ããªã
wafã¹ã¯ãªãããããã¸ã§ã¯ãã«å«ãã¦ãã¾ãã®ãä¸è¬çã§ãã
wafã®ãã¼ã¸ãããææ°çã®wafããã¦ã³ãã¼ããã¦ä½¿ãã¾ãã
$ wget http://waf.googlecode.com/files/waf-1.5.11 $ mv waf-1.5.11 waf $ chmod +x waf $ ./waf Waf: Please run waf from a directory containing a file named "wscript" or run distclean
wafã使ãã«ã¯wscriptã¨ãããã¡ã¤ã«ãæ¸ãå¿ è¦ãããã®ã§ãä»ã®ã¨ããã¯ã¨ã©ã¼ãåºã¾ããwafã¯å®è¡ã®éã«èªèº«ãã«ã¬ã³ããã£ã¬ã¯ããªã«å±éããã®ã§ãæ¸ãè¾¼ã¿å¯è½ãªãã£ã¬ã¯ããªã§å®è¡ããªããã°ãªããªããã¨ã«æ³¨æãã¦ãã ããã
ããã¸ã§ã¯ãä½æã®åº¦ã«wafããã¦ã³ãã¼ãããããªããå®è¡ã®éã«./ãä»ããã®ãå«ãªã©ãäºç´°ãªç¹ãæ°ã«ãªããªãã°ãä¸è¨ãã¡ãªãããç解ããä¸ã§ã¤ã³ã¹ãã¼ã«ãããã¨ãå¯è½ã§ãããã®éã«ã¯wafã®ãã¼ã¸ãããã©ãããwaf bookã® http://freehackers.org/~tnagy/wafbook/ch01s03.html ã®ããããåèã«ãªãã¨æãã¾ãã
wafã¯åä¸ã¹ã¯ãªããã ãã§ãªããtar.bz2çãé å¸ããã¦ãã¾ããããã«ã¯ããããããªãµã³ãã«ããã¸ã§ã¯ãããAutotoolsããã®ç§»è¡ãã¼ã«ããbash-completionãwafã®ã½ã¼ã¹ãªã©ãå«ã¾ãã¦ãã¾ãã®ã§ãwafã使ã£ã¦ãããã¨ããå ´åã«ã¯ä¸åº¦ç¢ºèªããããã¨ããããããã¾ãã
wscriptã®åºæ¬çãªæ¸ãæ¹
wafã¯wscriptã¨ãããã¡ã¤ã«ã«ããã«ãã«å¿
è¦ãªæ
å ±ãæ¸ããã¿ã¾ããããã¯æ®éã®Pythonããã°ã©ã ã¨ãã¦è¨è¿°ãã¾ãã以ä¸ã«éå½¢ã示ãã¾ãã
APPNAME = 'test-project' VERSION = '1.0.0' srcdir = '.' blddir = 'build' def set_options(opt): # ããã¸ã§ã¯ãã®ãªãã·ã§ã³ãè¨å®ãã # æåã«å¼ã°ãã pass def configure(conf): # ã©ã¤ãã©ãªã®ãã§ãã¯ãªã© # waf configure æã«å¼ã°ãã pass def build(bld): # ãã«ãã®æ å ±ãæ¸ã # waf build æã«å¼ã°ãã pass def shutdown(ctx): # çµäºæã«ä½ããããããã¨ã # æå¾ã«å¼ã°ãã pass
ã¾ããå¤æ°ãåã¤å®ç¾©ãã¾ããAPPNAMEã¨VERSIONã¯ããã°ã©ã ã®ååã¨ãã¼ã¸ã§ã³ãæå®ãã¾ããsrcdirã¨blddirã¯ã½ã¼ã¹ã®å ´æã¨ãã³ã³ãã¤ã«æã®ä¸æãã¡ã¤ã«ãç½®ããã£ã¬ã¯ããªãæå®ãã¾ãããããã®å¤æ°ã¯çç¥ããã¨ããããã'noname'ã'1.0'ã'.'ã'build'ã使ããã¾ãã
ãã®ã¾ã¾ã§ã¯å®è¡ãã¦ãä½ãèµ·ãããªãã®ã§ã次ã®ããã«æ¸ãã¦ã¿ã¾ãã
APPNAME = 'test-project' VERSION = '1.0.0' srcdir = '.' blddir = 'build' def set_options(opt): print "set_options" def configure(conf): print "configure" def build(bld): print "build" def shutdown(ctx): print "shutdown"
$ ./waf configure set_options configure 'configure' finished successfully (0.002s) shutdown $ ./waf build set_options Waf: Entering directory `/home/hideyuki/project/waf_test/build' build Waf: Leaving directory `/home/hideyuki/project/waf_test/build' 'build' finished successfully (0.003s) shutdown
configureãbuildå®è¡æã«ããããã対å¿ããé¢æ°ãå¼ã°ãã¦ããã®ãåããã¾ããããã«ããããå¿ è¦ãªãã¨ãæ¸ãã¦ãããã¨ã«ãªãã¾ãã
C/C++ããã°ã©ã ã®ã³ã³ãã¤ã«
C++ããã°ã©ã ãã³ã³ãã¤ã«ããä¾ã示ãã¾ãã
def set_options(opt): opt.tool_options('compiler_cxx') def configure(conf): conf.check_tool('compiler_cxx') def build(bld): bld(features = 'cxx cprogram', source = 'main.cpp', target = 'main')
ã¾ããset_optionsã§ãC++ã³ã³ãã¤ã©ç¨ã®ãªãã·ã§ã³ã使ããããã«ãã¾ãã'compiler_cxx'ã¯C++ã³ã³ãã¤ã©ç¨ã®è¨å®ã§ããCã³ã³ãã¤ã©ã使ããªãã'compiler_cc'ãæå®ãã¾ãã次ã«ãconfigureã§C++ã³ã³ãã¤ã©ã®ãã§ãã¯ããã¾ããæå¾ã«buildã«ãã«ãã«ã¼ã«ãæ¸ãã¾ããfeaturesã«ã¯ãããã°ã©ã ãã©ããã£ã¦ã³ã³ãã¤ã«ããããæ¸ãã¾ããããã§ã¯ãcxxã¨cprogramãæå®ãã¦ãã¾ããããã¯ã空ç½åºåã§æå®ãã¦ãããã§ããã['cxx', 'cprogram']ã®ããã«æååã®ãªã¹ãã渡ãã¦ãããã§ããããã¯ä»¥éåºã¦ããæååãè¤æ°ãã¦ããæã§ããã¹ã¦å ±éã®ä»æ§ã§ããcxxã¯ãC++ã®ã³ã³ãã¤ã©ã§ã³ã³ãã¤ã«ããã¨è¨ãæå®ãcprogramã¯å®è¡ãã¡ã¤ã«ãä½ãã¨è¨ãæå®ã§ããä»ã«cshlibãcstaticlibãªã©ãããã¾ããsourceã«ã¯ã½ã¼ã¹ãã¡ã¤ã«ãæå®ãã¾ããtargetã«ã¯çæããå®è¡ãã¡ã¤ã«ã®ååãæå®ãã¾ãã
ãã«ããå®è¡ããã¨æ¬¡ã®ããã«ãªãã¾ãã
$ cat main.cpp #include <iostream> using namespace std; int main() { cout<<"Hello, waf waf world!"<<endl; return 0; } $ ./waf configure Checking for program g++,c++ : ok /usr/bin/g++ Checking for program cpp : ok /usr/bin/cpp Checking for program ar : ok /usr/bin/ar Checking for program ranlib : ok /usr/bin/ranlib Checking for g++ : ok 'configure' finished successfully (0.049s) $ ./waf build Waf: Entering directory `/home/hideyuki/project/waf_test/build' [1/2] cxx: main.cpp -> build/default/main_1.o [2/2] cxx_link: build/default/main_1.o -> build/default/main Waf: Leaving directory `/home/hideyuki/project/waf_test/build' 'build' finished successfully (0.348s) $ build/default/main Hello, waf waf world!
configureã§ãC++ã³ã³ãã¤ã©ã®åå¨ããã§ãã¯ãããbuildã§main.cppãã³ã³ãã¤ã«ãããbuild/default/mainã«å®è¡ãã¡ã¤ã«ããªã³ã¯ããã¾ãããã«ãã®éã«çæããããã®ã¯ãã¹ã¦build(blddirã§æå®ãããã£ã¬ã¯ããª)以ä¸ã«ç½®ããã¾ãã
ãªããwaf buildã®ã¨ãã®buildã¯çç¥ã§ããã®ã§ãåã«wafã¨å®è¡ããã°buildã§ãã¾ãã
ãã¡ã¤ã«è¤æ°ãããªãããã°ã©ã ã¯sourceã«è¤æ°ãã¡ã¤ã«ãæå®ããã°ã§ãã¾ãã
def build(bld): bld(features = 'cxx cprogram', source = 'main.cpp foo.cpp', target = 'main', includes = '.')
includesã«ããããã¡ã¤ã«ã®ãããã£ã¬ã¯ããªãæå®ãã¾ãããããæ¸ãã°ãããã«å«ã¾ãããããã®ä¾åé¢ä¿ãèªåã§è§£æãã¦ããã¾ãã
$ cat main.cpp #include <iostream> using namespace std; #include "foo.h" int main() { cout<<foo(123)<<endl; return 0; } $ cat foo.cpp #include "foo.h" int foo(int n) { return n*n; } $ cat foo.h int foo(int n); $ ./waf configure Checking for program g++,c++ : ok /usr/bin/g++ Checking for program cpp : ok /usr/bin/cpp Checking for program ar : ok /usr/bin/ar Checking for program ranlib : ok /usr/bin/ranlib Checking for g++ : ok 'configure' finished successfully (0.048s) $ ./waf Waf: Entering directory `/home/hideyuki/project/waf_test/build' [1/3] cxx: main.cpp -> build/default/main_1.o [2/3] cxx: foo.cpp -> build/default/foo_1.o [3/3] cxx_link: build/default/main_1.o build/default/foo_1.o -> build/default/main Waf: Leaving directory `/home/hideyuki/project/waf_test/build' 'build' finished successfully (0.439s) $ build/default/main 15129 $ ./waf Waf: Entering directory `/home/hideyuki/project/waf_test/build' Waf: Leaving directory `/home/hideyuki/project/waf_test/build' 'build' finished successfully (0.006s) $ emacs foo.cpp ... edit ... $ ./waf Waf: Entering directory `/home/hideyuki/project/waf_test/build' [2/3] cxx: foo.cpp -> build/default/foo_1.o [3/3] cxx_link: build/default/main_1.o build/default/foo_1.o -> build/default/main Waf: Leaving directory `/home/hideyuki/project/waf_test/build' 'build' finished successfully (0.164s) $ emacs foo.h ... edit ... $ ./waf Waf: Entering directory `/home/hideyuki/project/waf_test/build' [1/3] cxx: main.cpp -> build/default/main_1.o [2/3] cxx: foo.cpp -> build/default/foo_1.o [3/3] cxx_link: build/default/main_1.o build/default/foo_1.o -> build/default/main Waf: Leaving directory `/home/hideyuki/project/waf_test/build' 'build' finished successfully (0.408s)
å¿ è¦ãªãã¡ã¤ã«ã ãåã³ã³ãã¤ã«ããã¦ããã®ãåããã¾ãããªãããã¡ã¤ã«ã®åã³ã³ãã¤ã«ã¯md5ã®æ¯è¼ã«ããè¡ãããã®ã§ãå 容ãæ¬å½ã«å¤æ´ããã¦ããªãã¨åã³ã³ãã¤ã«ã¯è¡ããã¾ããã
ã©ã¤ãã©ãªã®ä½ãæ¹
ã©ã¤ãã©ãªãä½ãå ´åã¯ãfeaturesã«cprogramã®ä»£ããã«cshlibã¾ãã¯cstaticlibã¨æ¸ãã ãã§ããå ç¨ã®ä¾ããfoo.cppãã©ã¤ãã©ãªã«ãmain.cppãããã使ãããã°ã©ã ã«å¤æ´ãã¦ã¿ã¾ãã
def build(bld): bld(features = 'cxx cstaticlib', source = 'foo.cpp', target = 'foo', includes = '.') bld(features = 'cxx cprogram', source = 'main.cpp', target = 'main', includes = '.', uselib_local = 'foo')
featuresã«cstaticlibãæå®ãã¾ãããfoo.cppããfooã¨ããéçã©ã¤ãã©ãªãä½ãã¨ããæ示ã§ããmainã¯ä»åº¦ã¯ãã®fooã¨ããã©ã¤ãã©ãªããªã³ã¯ããªããã°ãªãã¾ããããã®æå®ãuselib_localã¨ããã¨ããã«æ¸ãã¾ããåãããã¸ã§ã¯ãã§ä½ãããã©ã¤ãã©ãªï¼ãã¼ã«ã«ãªã©ã¤ãã©ãªï¼ã¸ã®åç §ã¯uselib_localã«æ¸ãã¾ãã
$ ./waf distclean configure build 'distclean' finished successfully (0.002s) Checking for program g++,c++ : ok /usr/bin/g++ Checking for program cpp : ok /usr/bin/cpp Checking for program ar : ok /usr/bin/ar Checking for program ranlib : ok /usr/bin/ranlib Checking for g++ : ok 'configure' finished successfully (0.048s) Waf: Entering directory `/home/hideyuki/project/waf_test/build' [1/4] cxx: foo.cpp -> build/default/foo_1.o [2/4] cxx: main.cpp -> build/default/main_2.o [3/4] static_link: build/default/foo_1.o -> build/default/libfoo.a [4/4] cxx_link: build/default/main_2.o -> build/default/main Waf: Leaving directory `/home/hideyuki/project/waf_test/build' 'build' finished successfully (0.426s)
featuresã«cstaticlibãæå®ããã®ã§ãfoo.cppãã³ã³ãã¤ã«ãããstaticã©ã¤ãã©ãªlibfoo.aãçæããã¾ããï¼targetã§æå®ããååã«libãä»ãããã®ãçæããã¾ãã®ã§libãtargetã«libãã¤ãã¦ã¯ããã¾ãããliblibfoo.aã«ãªã£ã¦ãã¾ãã¾ãï¼ãããããmain.cppã¨libfoo.aããªã³ã¯ãããmainãçæããã¾ããããã§ãmainãçæããåã«libfoo.aãçæããã¦ããªããã°ãªãã¾ãããããã®ãã«ãé ã¯ããã«ãã¿ã¼ã²ããéã®ä¾åé¢ä¿ããèªåçã«è§£æ±ºããã¾ããæ¸ãã¦ããå ´æã®åå¾ã¯é¢ä¿ããã¾ããããµããã£ã¬ã¯ããªï¼å¾è¿°ï¼ãå«ãå ´åãå ¨ä½ãèæ ®ãã¦è§£æ±ºããã¾ããwafã¯waf build -j2ãªã©ã¨ããã¨ä¸¦åã³ã³ãã¤ã«ãã§ãã¾ããããããä¾åé¢ä¿ã«åºã¥ãã¾ããä¾åé¢ä¿ã循ç°ãã¦ããå ´åãwafã¯ãããæ¤ç¥ã§ãã¾ãããã¨ã©ã¼ã¡ãã»ã¼ã¸ã§ã¯ãªããå帰ãã¹ã¿ãã¯ãªã¼ãã¼ããã¼ãã¦wafãè½ã¡ã¾ããä¾åé¢ä¿ã¯ãã¡ãã¨ããªã¼ï¼ãããã¯æ£®ï¼ã«ãªãããã«ãã¾ãããã
ã¡ãªã¿ã«ãwafã¯ã³ãã³ãã並ã¹ã¦æ¸ãã¨ãä¸ã®ããã«ããããé ã«å®è¡ãã¾ãã
featuresã«cshlibãæå®ããã¨ãåçã©ã¤ãã©ãªãçæããã¾ãããã®éãåæ§ã«uselib_localã§ãªã³ã¯ã§ãã¾ãã
def build(bld): bld(features = 'cxx cshlib', source = 'foo.cpp', target = 'foo', includes = '.') bld(features = 'cxx cprogram', source = 'main.cpp', target = 'main', includes = '.', uselib_local = 'foo')
$ ./waf distclean configure build 'distclean' finished successfully (0.001s) Checking for program g++,c++ : ok /usr/bin/g++ Checking for program cpp : ok /usr/bin/cpp Checking for program ar : ok /usr/bin/ar Checking for program ranlib : ok /usr/bin/ranlib Checking for g++ : ok 'configure' finished successfully (0.065s) Waf: Entering directory `/home/hideyuki/project/waf_test/build' [1/4] cxx: foo.cpp -> build/default/foo_1.o [2/4] cxx: main.cpp -> build/default/main_2.o [3/4] cxx_link: build/default/foo_1.o -> build/default/libfoo.so [4/4] cxx_link: build/default/main_2.o -> build/default/main Waf: Leaving directory `/home/hideyuki/project/waf_test/build' 'build' finished successfully (0.507s)
ãµããã£ã¬ã¯ããª
å ç¨ã®ä¾ããlibfooãfooã¨ãããã£ã¬ã¯ããªã«ç§»åããããã¨æãã¾ãããµãã¢ã¸ã¥ã¼ã«ãåå²ããã®ã¯ããã¸ã§ã¯ããã·ã³ãã«ã«ä¿ã¤ããã«éè¦ã§ããlibfooãä½ãæ¹æ³ã¯ç¬ç«ãã¦ããæ¹ãè¯ãã®ã§ãwscriptãåå²ãã¾ãããã£ã¬ã¯ããªæ§æã¨ãã¦ã¯æ¬¡ã®ããã«ãªãã¾ãã
|- foo | |- foo.cpp | |- foo.h | `- wscript |- main.cpp `- wscript
ã«ã¼ãã®wscriptããåã®wscriptãå¼ã³åºãã«ã¯æ¬¡ã®ããã«ãã¾ãã
# wscript ef set_options(opt): opt.tool_options('compiler_cxx') def configure(conf): conf.check_tool('compiler_cxx') def build(bld): bld(features = 'cxx cprogram', source = 'main.cpp', target = 'main', includes = '. foo', uselib_local = 'foo') bld.recurse('foo')
# foo/wscript def build(bld): bld(features = 'cxx cshlib', source = 'foo.cpp', target = 'foo', includes = '.')
bld.recurse('foo') ã¨æ¸ãã¦ããé¨åãfoo/wscriptãå¼ã³åºãé¨åã§ããããããã¨ãfoo/wscriptã«ããåãé¢æ°ãå¼ã°ãã¾ãããã®å ´åã ã¨buildãªã®ã§buildãå¼ã°ãã¾ãããã¡ããconfigureããrecurseãããã¨ãå¯è½ã§ããrecurseã«ã¯ãã£ã¬ã¯ããªã®ãªã¹ãã渡ãã¾ãããµããã£ã¬ã¯ããªã®wscriptã«ã¯ãå¼ã³åºãããªãé¢æ°ã¯æ¸ããªãã¦ãæ§ãã¾ãããconfigureãrecurseã§ããã®ã§ãåãµãã¢ã¸ã¥ã¼ã«ã«å¿ è¦ãªã©ã¤ãã©ãªãã§ãã¯ãåæ£ããããã¨ãã§ãã¾ããAutotoolsã®ããã«configure.acãè¥å¤§åãããããã§ãã¯ã®å ´æã¨ä½¿ç¨ã®å ´æãé¢ããããããã¨ãé²ãã¾ããå®è¡ããã¨æ¬¡ã®ããã«ãªãã¾ãã
$ ./waf distclean configure build 'distclean' finished successfully (0.000s) Checking for program g++,c++ : ok /usr/bin/g++ Checking for program cpp : ok /usr/bin/cpp Checking for program ar : ok /usr/bin/ar Checking for program ranlib : ok /usr/bin/ranlib Checking for g++ : ok 'configure' finished successfully (0.054s) Waf: Entering directory `/home/hideyuki/project/waf_test/build' [1/4] cxx: main.cpp -> build/default/main_1.o [2/4] cxx: foo/foo.cpp -> build/default/foo/foo_1.o [3/4] cxx_link: build/default/foo/foo_1.o -> build/default/foo/libfoo.so [4/4] cxx_link: build/default/main_1.o -> build/default/main Waf: Leaving directory `/home/hideyuki/project/waf_test/build' 'build' finished successfully (0.535s)
ã©ã¤ãã©ãªãããããã¡ã¤ã«ã®ãã§ãã¯
C/C++ã®ã©ã¤ãã©ãªãããããã¡ã¤ã«ã®ãã§ãã¯ã¯check_ccã¾ãã¯ãcheck_cxxã«ãã£ã¦è¡ããã¨ãã§ãã¾ãããããã¯configureæã«è¡ãã®ã§ãconfigure()ã«è¨è¿°ãã¾ããä¸éãã®ä¾ã以ä¸ã«ç¤ºãã¾ãã
def configure(conf): conf.check_tool('compiler_cxx') # libmã®åå¨ç¢ºèª conf.check_cxx(lib = 'm') # ãã£ã¬ã¯ããªãæå®ãã¦ç¢ºèª conf.check_cxx(lib = 'superlib', libpath = '/var/super/lib') # time.hã®åå¨ç¢ºèª conf.check_cxx(header_name = 'time.h') # stdio.hã¨é¢æ°printfã®åå¨ç¢ºèªãå¿ é ï¼mandatoryï¼ conf.check_cxx(function_name = 'printf', header_name = 'stdio.h', mandatory = True) # check_cxxã¯boolãè¿ã if conf.check_cxx(lib = 'nuboo'): print "nuboo exists!" else: print "nuboo does not exist!" # ã³ã¼ãçãã³ã³ãã¤ã«ã§ããã調ã¹ããã³ã³ãã¤ã«ã§ãããã©ãããboobahã«æ ¼ç´ conf.check_cxx(fragment = 'int main(){ return 0; }', define_name = 'boobah') # ã³ã¼ãçãå®è¡ãã¦ãåºåãåãåºã conf.check_cxx(fragment = """ #include <iostream> using namespace std; int main(){ cout<<sizeof(long)<<endl; return 0; } """, define_name = 'LONG_SIZE', execute = True, define_ret = True, msg = 'Checking for long size') # uselib_storeï¼å¾è¿°ï¼ conf.check_cxx(lib = 'm', cxxflags = '-Wall', defines = ['var=foo', 'x=y'], uselib_store = 'M') # ãã§ãã¯ããçµæãããããã¡ã¤ã«ã¨ãã¦æ¸ãåºã conf.write_config_header('config.h') # envã®ä¸èº«ãåºåï¼ãããã°ã«ä¾¿å©ï¼ conf.env.store('conf.log')
check_cxxã¯C++ã³ã³ãã¤ã©ãç¨ãã¦ã³ã³ãã¤ã«ã試ã¿ã¾ããåæ§ã«check_ccã¯Cã³ã³ãã¤ã©ãç¨ãã¦ã³ã³ãã¤ã«ã試ã¿ã¾ããããããã使ç¨ããããã«ã¯ãset_optionsã§opt.tool_options('compiler_cxx')ãopt.tool_options('compiler_cc')ããã¦ããå¿ è¦ãããã¾ãã
libã«ã©ã¤ãã©ãªåãæå®ããã¨ããã®ã©ã¤ãã©ãªããªã³ã¯ã§ãããã©ããã調ã¹ã¾ãããã®éã«libpathã§ã©ã¤ãã©ãªãæ¢ãå ´æãæå®ã§ãã¾ãã
header_nameã«ããããã¡ã¤ã«åãæå®ããã¨ããã®ãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼ãã§ããã調ã¹ã¾ããfunction_nameã«é¢æ°åãæå®ããã¨ãé¢æ°ã®åå¨ã調ã¹ããã¾ãããã®ã¨ãã©ã¤ãã©ãªãããããã¡ã¤ã«ãããããåå¨ããã¨conf.env.HAVE_TIME_Hãconf.env.HAVE_PRINTFãªã©ã1ã«è¨å®ããã¾ãã
madantoryãæå®ããã¨ããã®ãã§ãã¯ãå¿ é ã«ã§ãã¾ãããããæå®ãããã§ãã¯ã失æããã¨configureãããã¾ãã
check_cxxã¯boolãè¿ãã®ã§ãPythonã®ifæãªã©ã§ç°¡åã«å©ç¨ã§ãã¾ããã¨ã¦ã便å©ã§ãã
ã³ã¼ãçã®ã³ã¼ããã¹ãããã³ã¼ãçã®åºåãconf.envã«è¨å®ã§ãã¾ããä¸ã®ä¾ã§ãã¨ãLONG_SIZEã«"8"ãè¨å®ããã¾ãã
wafã«ã¯uselibã¨ããä»çµã¿ãããã¾ãã詳ããã¯å¾è¿°ã®ã©ã¤ãã©ãªã®åç §ã§è¿°ã¹ã¾ãããããã§ã¯ãããã«æå®ããæååãæ¥å°¾è¾ã«ããããããªå¤æ°ãå®ç¾©ããã¾ããããã§ã¯ãLIB_MãCXXDEFINES_MãCXXFLAGS_Mããå®ç¾©ããã¾ãã
write_config_header()ãå¼ã³åºãã¨ãéããæ å ±ãC/C++ã®ããããã¡ã¤ã«ã«æ¸ãã ãã¾ããä¾ãã°ãä¸ã®ã³ã¼ããªãã次ã®ã³ã¼ããçæããã¾ãã
/* Configuration header created by Waf - do not edit */ #ifndef _CONFIG_H_WAF #define _CONFIG_H_WAF #define HAVE_TIME_H 1 #define HAVE_PRINTF 1 #define boobah 1 #define LONG_SIZE "8" #endif /* _CONFIG_H_WAF */
conf.env.store()ãå¼ã³åºãã¨ãç°å¢ãæ¸ãã ããã¨ãã§ãã¾ããããã¯wafã³ã¼ãã®ãããã°ã«ã¨ã¦ã便å©ã§ãã
configureã®å®è¡çµæã以ä¸ã«è¼ãã¦ããã¾ãã
$ ./waf configure Checking for program g++,c++ : ok /usr/bin/g++ Checking for program cpp : ok /usr/bin/cpp Checking for program ar : ok /usr/bin/ar Checking for program ranlib : ok /usr/bin/ranlib Checking for g++ : ok Checking for library m : ok Checking for library superlib : not found Checking for header time.h : ok Checking for function printf : ok Checking for library nuboo : not found nuboo does not exist! Checking for custom code : ok Checking for long size : ok Checking for library m : ok 'configure' finished successfully (1.480s)
pkg-config
pkg-configããããã¯ãhoge-configã®ãããªãCã®ã³ã³ãã¤ã©ãã©ã°ããªã³ã¯ãã©ã°ãã©ã¤ãã©ãªãã¹ãªã©ãåå¾ããããã®ããã°ã©ã ãæä¾ãã¦ããã©ã¤ãã©ãªãããã¾ãããã®ãããªã©ã¤ãã©ãªãããã°ãããã¨ã¦ã便å©ã«ãã§ãã¯ãè¡ããã¨ãã§ãã¾ãã
def configure(conf): conf.check_cfg(atleast_pkgconfig_version = '0.0.0') conf.check_cfg(package = 'pango', atleast_version = '0.0.0') conf.check_cfg(package = 'pango', exact_version = '0.21') conf.check_cfg(package = 'pango', max_version = '9.0.0') conf.check_cfg(package = 'pango', args='--cflags --libs') pango_version = conf.check_cfg(modversion = 'pango') conf.check_cfg(path = 'sdl-config', args = '--cflags --libs', package = '', uselib_store='SDL')
pkg-configã®å ´åãcheck_cfgã§ãpackageã«ããã±ã¼ã¸åã渡ãã°ããã¼ã¸ã§ã³ã®ãã§ãã¯ãªã©ãã§ãã¾ããç¬èªã®configããã°ã©ã ã®å ´åã¯ãpathã«æå®ãã¦ããã¾ãï¼ãã®å ´åã¯ãã¼ã¸ã§ã³ãã§ãã¯ãªã©ã¯ã§ããªã模æ§ï¼ãããã§ãuselib_storeãæå®ãã¦ãargsã«ã³ã³ãã¤ã©ãã©ã°ãåå¾ããããã®å¼æ°ãæ¸ãã¦ããã¨ãcheck_cfgã¯ãã®è¿ãå¤ã解æãã¦ã-IxxxãªãCPPPATH_hogeã«ã-DxxxãªãCXXDEFINES_hogeã«ã-LxxxãªãLIBPATH_hogeã«ã-lxxxãªãLIB_hogeã«ããã®ä»ã¯CXXFLAGS_hogeãªã©ã«ãèªåçã«æ¯ãåãã¦è¿½å ããã¾ãã
ã©ã¤ãã©ãªã®åç §
bldã®å¼æ°ã§ãã©ã¤ãã©ãªã®åç §ã追å ã§ãã¾ããä¾ãã°ãpthreadããªã³ã¯ãããªãã次ã®ããã«ãªãã¾ãã
def build(bld): bld(features = 'cxx cprogram', source = 'main.cpp', target = 'main', includes = '.', lib = ['pthread'])
ã©ã¤ãã©ãªãã¹ãæå®ããããªããlibpathãæ¸ãã¾ãã
def build(bld): bld(features = 'cxx cprogram', source = 'main.cpp', target = 'main', includes = '.', lib = ['pthread'], libpath = ['/usr/local/lib'])
ãã®ä»ããããããªãã·ã§ã³ãæå®ã§ãã¾ãã
def build(bld): bld(features = 'cxx cprogram', source = 'main.cpp', target = 'main', includes = '.', defines = ['LINUX=1', 'BIDULE'], cxxflags = ['-O2', '-Wall'], lib = ['m'], libpath = ['/usr/lib'], linkflags = ['-g'])
uselib
uselibãç¨ããã¨ãä¸è¨ã®ãããããªã³ã³ãã¤ã«ã®è¨å®ãä¸æ°ã«è¨å®ã§ãã¾ãã
def build(bld): bld(features = 'cxx cprogram', source = 'main.cpp', target = 'main', includes = '.', uselib = 'SDL')
bldã®å¼æ°ã«uselibãæå®ãã¦ããã¨ããã®æååãæ¥å°¾è¾ã¨ããè¨å®ãã¾ã¨ãã¦ãªããã¾ããä¾ãã°ãLIB_SDLãlibã«ãLIBPATH_SDLãlibpathã«ãCXXFLAGS_SDLãcxxflagsã«è¨å®ããã¾ããcheck_cfgãããã¯check_cxxã§ã®uselib_storeã¨uselibãçµã¿åããã¦ä½¿ãã¨ãã³ã³ãã¤ã«ã»ãªã³ã¯ãã©ã°ã®è¨å®ã大å¤ç°¡åã«è¡ããã¨ãã§ãã¾ãã
ãªãã·ã§ã³
configureæã®ãªãã·ã§ã³ãèªç±ã«è¿½å ãããã¨ãã§ãã¾ããããã¸ã§ã¯ãã®ç¹å®ã®ã¢ã¸ã¥ã¼ã«ã®æå¹ã»ç¡å¹ãåãæ¿ããããªã©ãå ¸åçãªå©ç¨ä¾ã§ããset_options()ã§add_optionãããã¨ã«ãããªãã·ã§ã³ã®è¿½å ãã§ãã¾ãã
def set_options(opt): opt.tool_options('compiler_cxx') # boolãªãã·ã§ã³ opt.add_option('--enable-super-module', action = 'store_true', default = False, help='enable a super module') # æååãªãã·ã§ã³ opt.add_option('--build_kind', action = 'store', default = 'debug,release', help = 'build the selected variants') def build(bld): import Options # ãªãã·ã§ã³ã®åç § if Options.options.enable_super_module: build.recurse('super')
追å ãããªãã·ã§ã³ã¯ waf --help ã«ã表示ããã¾ãã
$ ./waf --help waf [command] [options] Main commands (example: ./waf build -j4) build : builds the project clean : removes the build files configure: configures the project dist : makes a tarball for redistributing the sources distcheck: checks if the sources compile (tarball from 'dist') distclean: removes the build directory install : installs the build files uninstall: removes the installed files Options: --version show program's version number and exit -h, --help show this help message and exit -j JOBS, --jobs=JOBS amount of parallel jobs (1) -k, --keep keep running happily on independent task groups -v, --verbose verbosity level -v -vv or -vvv [default: 0] --nocache ignore the WAFCACHE (if set) --zones=ZONES debugging zones (task_gen, deps, tasks, etc) -p, --progress -p: progress bar; -pp: ide output --targets=COMPILE_TARGETS build given task generators, e.g. "target1,target2" --enable-super-module enable a super module --build-kind=BUILD_KIND build the selected variants ...
ã¦ããããã¹ã
wafã¯ã¦ããããã¹ãæ¯æ´æ©è½ãããã¾ããå ã®ããã¸ã§ã¯ãã§ãlibfooã®ã¦ããããã¹ããä½æãããã¨ã«ãã¾ãã
def set_options(opt): opt.tool_options('compiler_cxx') opt.tool_options('UnitTest') def configure(conf): conf.check_tool('compiler_cxx') conf.check_cxx(lib = 'gtest_main', uselib_store = 'gtest') def build(bld): bld(features = 'cxx cprogram test', source = 'foo_test.cpp', target = 'foo_test', includes = '. foo', uselib_local = 'foo', uselib = 'gtest') bld.recurse('foo') import UnitTest bld.add_post_fun(UnitTest.summary)
ã¾ããset_optionsã§tool_optionsã«UnitTestã追å ãã¾ãã次ã«ããã¹ãããã°ã©ã ãä½ãã¾ããããã¯featuresã«testã追å ããã ãã§ããtestãã£ã¼ãã£ã¼ãã¤ãã¦ããããã°ã©ã ã¯ãã³ã³ãã¤ã«å¾ã«èªåã§å®è¡ããããã®çµæãéè¨ãããããã«ãªãã¾ãããããããbld.add_post_funã§UnitTest.summaryãæå¾ã«å®è¡ãããããã«ãã¾ããããã§ãã¹ãã®çµæã表示ãããããã«ãªãã¾ãã
#include <gtest/gtest.h> #include "foo.h" TEST(footest, test) { EXPECT_EQ(foo(123), 123+123); }
ãã¹ãããã°ã©ã ãæ¸ãã¾ããä»åã¯gtestã使ãã¾ãããfooã¯äºä¹ãè¿ãé¢æ°ã ã£ãã®ã§ãããã¯failããã¯ãã§ããå®è¡ãã¦ã¿ã¾ãã
$ ./waf distclean configure build 'distclean' finished successfully (0.002s) Checking for program g++,c++ : ok /usr/bin/g++ Checking for program cpp : ok /usr/bin/cpp Checking for program ar : ok /usr/bin/ar Checking for program ranlib : ok /usr/bin/ranlib Checking for g++ : ok Checking for library gtest_main : ok 'configure' finished successfully (0.224s) Waf: Entering directory `/home/hideyuki/project/waf_test/build' [1/5] cxx: foo_test.cpp -> build/default/foo_test_1.o [2/5] cxx: foo/foo.cpp -> build/default/foo/foo_1.o [3/5] static_link: build/default/foo/foo_1.o -> build/default/foo/libfoo.a [4/5] cxx_link: build/default/foo_test_1.o -> build/default/foo_test [5/5] utest: build/default/foo_test Waf: Leaving directory `/home/hideyuki/project/waf_test/build' execution summary FAIL /home/hideyuki/project/waf_test/build/default/foo_test command execution failed: /home/hideyuki/project/waf_test/build/default/foo_test -> 'Running main() from gtest_main.cc [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from footest [ RUN ] footest.test ../foo_test.cpp:7: Failure Value of: 123+123 Actual: 246 Expected: foo(123) Which is: 15129 [ FAILED ] footest.test [----------] Global test environment tear-down [==========] 1 test from 1 test case ran. [ PASSED ] 0 tests. [ FAILED ] 1 test, listed below: [ FAILED ] footest.test 1 FAILED TEST
ã³ã³ãã¤ã«ãããå¾ããã¹ããå®è¡ããã¦ããã®ãåããã¾ãã失æãããã¹ããFAILã¨è¡¨ç¤ºããã¦ãã¾ãï¼ããã¯å®éã«ã¯èµ¤ã§è¡¨ç¤ºãããã®ã§ã失æãããã¨ãåãããããï¼ãwafã¯ãã¹ããã³ã³ãã¤ã«ã®å¾ã«å®è¡ãã¾ããã³ã³ãã¤ã«ãèµ·ãããªãã¨ãã¹ãã¯å®è¡ããã¾ããããã¹ãã失æããå ´åããå度waf buildãè¡ã£ã¦ããã¹ãã¯å®è¡ããã¾ãããwaf build --alltests ãªãã·ã§ã³ã使ãã¨ããã«ããããªãã£ããã¹ããå«ããå ¨ã¦ã®ãã¹ããå®è¡ãããã¨ãã§ãã¾ãã
ãã¦ãå ç¨ã®ãã°ãåãã£ãã®ã§ãä¿®æ£ãã¦åå®è¡ãã¾ãã
include <gtest/gtest.h> #include "foo.h" TEST(footest, test) { EXPECT_EQ(foo(123), 123*123); }
$ ./waf Waf: Entering directory `/home/hideyuki/project/waf_test/build' [1/5] cxx: foo_test.cpp -> build/default/foo_test_1.o [4/5] cxx_link: build/default/foo_test_1.o -> build/default/foo_test [5/5] utest: build/default/foo_test Waf: Leaving directory `/home/hideyuki/project/waf_test/build' execution summary ok /home/hideyuki/project/waf_test/build/default/foo_test 'build' finished successfully (0.779s)
ä»åº¦ã¯okã«ãªãã¾ããï¼okã¯ç·ã§è¡¨ç¤ºããã¾ãï¼ããªããéã£ããã¹ãã®åºåã¯è¡¨ç¤ºããã¾ããã
ã¤ã³ã¹ãã¼ã©
waf install ã¨ããã¨ããã«ããããã®ãã¤ã³ã¹ãã¼ã«ã§ãã¾ãã
$ sudo ./waf distclean configure build install 'distclean' finished successfully (0.002s) Checking for program g++,c++ : ok /usr/bin/g++ Checking for program cpp : ok /usr/bin/cpp Checking for program ar : ok /usr/bin/ar Checking for program ranlib : ok /usr/bin/ranlib Checking for g++ : ok Checking for library gtest_main : ok 'configure' finished successfully (0.209s) Waf: Entering directory `/home/hideyuki/project/waf_test/build' [1/5] cxx: foo_test.cpp -> build/default/foo_test_1.o [2/5] cxx: foo/foo.cpp -> build/default/foo/foo_1.o [3/5] cxx_link: build/default/foo/foo_1.o -> build/default/foo/libfoo.so [4/5] cxx_link: build/default/foo_test_1.o -> build/default/foo_test [5/5] utest: build/default/foo_test Waf: Leaving directory `/home/hideyuki/project/waf_test/build' execution summary ok /home/hideyuki/project/waf_test/build/default/foo_test 'build' finished successfully (0.965s) Waf: Entering directory `/home/hideyuki/project/waf_test/build' * installing build/default/foo/libfoo.so as /usr/local/lib/libfoo.so Waf: Leaving directory `/home/hideyuki/project/waf_test/build'
ãã¹ãã§ãªãå®è¡ãã¡ã¤ã«ãåçã©ã¤ãã©ãªã¯èªåçã«ã¤ã³ã¹ãã¼ã«å¯¾è±¡ã«ãªãã¾ãã
ç¹å®ã®ãã¡ã¤ã«ï¼ä¾ãã°ããããã¡ã¤ã«ï¼ãã¤ã³ã¹ãã¼ã«ããããå ´åãbld.install_files()ã使ãã¾ãã
def build(bld): ... # ç¹å®ã®ãã¡ã¤ã«ãã¤ã³ã¹ãã¼ã«ãã bld.install_files('${PREFIX}/include', ['foo/foo.h']) # ãã£ã¬ã¯ããªæ§é ãä¿æãã bld.install_files('${PREFIX}/include', ['foo/foo.h'], relative_trick = True) # å¥åã§ã¤ã³ã¹ãã¼ã«ãã bld.install_as('${PREFIX}/dir/bar.png', 'foo.png') # ã·ã³ããªãã¯ãªã³ã¯ãä½æãã bld.symlink_as('${PREFIX}/lib/libfoo.so.1', 'libfoo.so.1.2.3')
install_filesã®ç¬¬ä¸å¼æ°ã«ã¯ãã¤ã³ã¹ãã¼ã«ãããã£ã¬ã¯ããªãæå®ãã¾ããæååä¸ã®${PREFIX}ã¯ãbld.env.PREFIXã§ç½®æããã¾ããPREFIXã§ãªãã¦ãbld.envã«ããå¤æ°ãªãä½ã§ãå±éã§ãã¾ããbld.env.PREFIXã«ã¯ãconfigureæã«--prefix=ã§æå®ãããã£ã¬ã¯ããªãå ¥ã£ã¦ãã¾ããæå®ããªãã£ãå ´åã¯/usr/localã«ãªã£ã¦ãã¾ãã
relative_trickãæå®ããã¨ããã£ã¬ã¯ããªæ§é ãä¿æãã¦ã¤ã³ã¹ãã¼ã«ããã¾ããä¸ã®ä¾ãªãã${PREFIX}/include/foo/foo.h ã«ã¤ã³ã¹ãã¼ã«ããã¾ãï¼ä¸ã¤ç®ã®ä¾ã¯${PREFIX}/foo.h ã«ãªãã¾ãï¼ã
ãã®ä»ãå¥åã§ã®ã¤ã³ã¹ãã¼ã«ããã·ã³ããªãã¯ãªã³ã¯ä½æãã§ãã¾ãã
ããã±ã¼ã¸ä½æ
ãã¦ãlibfooãããããå®æããã®ã§ãããã±ã¼ã¸ãä½ã£ã¦é å¸ãã¾ããããwafã§ã¯ãAutotoolsã¨åæ§ãwaf distã¨ããã¨ãtarballãä½æããã¾ãã
$ ./waf dist New archive created: test-project-1.0.0.tar.bz2 (sha='0af6ce61eb3661bfc54efa5d2b301442a7e84557') 'dist' finished successfully (0.033s) $ ls build foo_test.cpp main.cpp test-project-1.0.0.tar.bz2 wscript foo foo_test.cpp~ main.cpp~ waf wscript~ $ tar -jtf test-project-1.0.0.tar.bz2 test-project-1.0.0/ test-project-1.0.0/waf test-project-1.0.0/main.cpp test-project-1.0.0/foo/ test-project-1.0.0/foo/foo.cpp test-project-1.0.0/foo/wscript test-project-1.0.0/foo/foo.h test-project-1.0.0/wscript test-project-1.0.0/foo_test.cpp
test-project-1.0.0.tar.bz2ã¨ãããã¡ã¤ã«ãåºæ¥ã¦ãã¾ããããã©ã«ãã§ã¯ãbz2å§ç¸®ããã¾ããå§ç¸®æ¹å¼ãå¤æ´ããã«ã¯æ¬¡ã®ããã«ãã¾ãã
import Scripting Scripting.g_gz = 'gz'
ã¨ããã§ãtarballã«å«ãããã¡ã¤ã«ãæå®ããè¦ãã¯ããã¾ããã§ãããã©ããã£ã¦wafã¯tarballã«å«ããã¹ããã¡ã¤ã«ãå¤æãã¦ããã®ã§ããããï¼
wafã¯åºæ¬çã«ããã£ã¬ã¯ããªã®å 容ããã¹ã¦tarballã«å«ãã¾ãããããããç¹å®ã®æ¥å°¾è¾ãæã¤ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªã¨ãç¹å®ã®ååã®ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªãé¤å¤ãã¾ããã½ã¼ã¹ã³ã¼ãã«ããã¨ããããã©ã«ãã®é¤å¤æ¥å°¾è¾ã¯'~ .rej .orig .pyc .pyo .bak .tar.bz2 tar.gz .zip .swp'ãããã©ã«ãã®é¤å¤ãã¡ã¤ã«ã»ãã£ã¬ã¯ããªã¯'.bzr .bzrignore .git .gitignore .svn CVS .cvsignore .arch-ids {arch} SCCS BitKeeper .hg _MTN _darcs Makefile Makefile.in config.log'ã®ããã§ããããã«ãblddirã¯é¤å¤ããã¾ãã
dist_hook()ã¨ããé¢æ°ãä½ãã°ãdistã§å«ãããã¡ã¤ã«ãã«ã¹ã¿ãã¤ãºãããã¨ãã§ãã¾ããdist_hook()ã¯ãtarballã«å«ãããã¡ã¤ã«ããã³ãã©ãªãã£ã¬ã¯ããªã«ã¾ã¨ãã¦ãå§ç¸®ããç´åã«ãããã®ãã£ã¬ã¯ããªãã«ã¬ã³ããã£ã¬ã¯ããªã«ãªã£ãç¶æ ã§å¼ã°ãã¾ãã
ãã¨ãã°ãmain.cppãå«ããããªããã°ãããã¾ãã
def dist_hook(): import os os.remove('main.cpp')
$ ./waf dist New archive created: test-project-1.0.0.tar.gz (sha='4dbbd6948532b5b52d9ff52615739e4c68ad5f17') 'dist' finished successfully (0.017s) $ tar -ztf test-project-1.0.0.tar.gz test-project-1.0.0/ test-project-1.0.0/waf test-project-1.0.0/foo/ test-project-1.0.0/foo/foo.cpp test-project-1.0.0/foo/wscript test-project-1.0.0/foo/foo.h test-project-1.0.0/wscript test-project-1.0.0/foo_test.cpp
ã¾ããé¤å¤ã«ã¼ã«ã«è¿½å ãããã¨ãã§ãã¾ãã
import Scripting Scripting.dist_exts += ['.cpp']
.cppãã¡ã¤ã«ãå«ã¾ããªããªãã¾ãã
$ ./waf dist New archive created: test-project-1.0.0.tar.gz (sha='a777a3cc369955f489a7d76c947eb067812f1917') 'dist' finished successfully (0.014s) $ tar -ztf test-project-1.0.0.tar.gz test-project-1.0.0/ test-project-1.0.0/waf test-project-1.0.0/foo/ test-project-1.0.0/foo/wscript test-project-1.0.0/foo/foo.h test-project-1.0.0/wscript
tarballã«å«ããããªããã¡ã¤ã«ããã£ã¬ã¯ããªå ã«ç½®ãããå ´åãç¹å®ã®æ¡å¼µåã«ãã¦ããã®æ¡å¼µåãé¤å¤ã«ã¼ã«ã«è¿½å ããããç¹å®ã®ãã£ã¬ã¯ããªãé¤å¤ã«ãã¦ããã«ã¾ã¨ãã¦ç½®ããããããã¯dist_hook()ãæ¸ãã¦ç¬èªã®é¤å»ã«ã¼ãã³ãæ¸ãã°ãªãã§ãã§ãã¾ãã
çµã³
ãã¦ãwafãããã ã£ãã§ãããããæ®éã®Pythonããã°ã©ã ã¨ãã¦ãã«ãã¹ã¯ãªãããè¨è¿°ããã®ã§ã¨ã¦ãè¦éããè¯ãã®ã§ã¯ãªããã¨æãã¾ããã©ãã«ä½ãæ¸ããã®ããä½ãæ¸ãããããã®ãã»ã¨ãã©è¿·ããã¨ãããã¾ãããwafã¯ã³ã³ãã¯ãã§ãããªããããããæããæ©è½ããµãã¼ããã¦ããã®ã§ãæ®æ®µä½¿ãã§ã¯ããããªãã¨å°ããã¨ã¯ã»ã¨ãã©ãªãã¨æãã¾ããããããwafã¯flexibleã¨è¬³ã£ã¦ããã ããã£ã¦ãæ©è½ãç¬èªã«æ¡å¼µãããã¨ãé常ã«å®¹æã«ã§ããããã«è¨è¨ããã¦ããã®ã§ãææªæ¸ãã°ãªãã¨ããªãã¾ãã
ä»åã¯ãã¥ã¼ããªã¢ã«ã¨ãããã¨ã§ãwafã®ãã¹ã¦ãç´¹ä»ã§ãã¦ããããã§ã¯ããã¾ããããã£ã¨wafãç¥ããããwafãæ¯é使ã£ã¦ã¿ããã¨ããæ¹ã¯ãä¸è¨ã®ãªã³ã¯ãåç §ãããã¨è¯ãã§ãããã