waf is a build tool written in pytho. I tried to introduce it by creating a D language compilation environment automatically to some extent. Since it is written in python, you need an environment where python can run.
- The official page is below. http://code.google.com/p/waf/
- Something like this page http://docs.waf.googlecode.com/git/book_17/single.html
- Documentary waf code can also be found here http://docs.waf.googlecode.com/git/apidocs_17/index.html
The environment with waf and .d code is as follows.
Ignore ~~ .sublime-project and ~~ .sublime-wokspace because they are project related files used in Sublime Text 2.
waf is the main body of the compilation tool. wscript describes the build rules. The import relations of .d files (excluding Phobos) are as follows
However, /src/unipa/courceinfo.d imports std.net.curl, so you have to refer to the curl library.
Now, let's take a look at the contents of wscript
wscript
import os.path
APPNAME='UNIPA_UFCS'
VERSION='1.0'
top='.'
out='./build'
def options(opt):
opt.load('compiler_d')
def configure(conf):
conf.load('compiler_d')
def build(bld):
bld.add_post_fun(target_run)
bld.program(
source='./src/main.d ./src/unipa/webdata.d ./src/unipa/courceinfo.d',
target=APPNAME,
includes = './src/',
libpath = '/dmd2/osx/lib',
lib = 'curl'
)
def target_run(ctx):
ctx.exec_command(os.path.join(out, APPNAME) + '> result.txt')
APPNAME is the name of the executable file, VIRSION is the same, top is the folder with wscript, and out is the output destination of .o or the executable file. If you write options and configure as above, it will build the settings suitable for the D language development environment. easy. build is the build rule body, write the build rule in bld.program. It is written in various ways. Well, I think you can understand the meaning. For example, refer to the curl library with libpath and lib. If you put a function in the argument of bld.add_post_fun, it will execute the function you passed when the build was successful. target_run runs the executable file when the compilation is successful and outputs the output to result.txt.
Well, it looks like this.
After that, if you set the build on the Sublime Text 2 side, it will be a happier environment. It's coming again.
Recommended Posts