My favorites | Sign in
Logo
waf
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2006 (ita)

# notes:
# 1. We think it is good to give names to our objects
# 2. In practice something like 'libkdegames' might do it better
# 3. Any coincidence with characters living or dead is purely coincidental

def myfun(self, name):

import ccroot
env2 = self.env.copy()
env2['CXXFLAGS'] = "-Dxxxxxxxxxxxxxxxxxxxxxxx"

node = self.path.find_resource(name)
task = self.create_task('cxx', env2)

task.m_scanner = ccroot.g_c_scanner
task.path_lst = self.inc_paths
task.defines = self.scanner_defines

task.m_inputs = [node]
task.m_outputs = [node.change_ext(".o")]
self.compiled_tasks.append(task)

def build(bld):
import Params
print "command-line parameter meow is ", Params.g_options.meow

# 1. A simple program
obj = bld.create_obj('cpp', 'program')
obj.source='''
a1.cpp
b1.cpp b2.cpp
main.cpp
'''
obj.includes='.'
obj.target='testprogram'
obj.defines='LINUX=1 BIDULE'
obj.obj_ext = '_1.o'
# obj.add_obj_file('kk.o') # <- example on how to add custom object files considered source

#obj.mappings["a1.cpp"] = myfun <- example of how to modify the environment for one file
# of you need to modify more files, add custom object files or use the objects type

# 2. A shared library
# The extension (.so) is added automatically
obj = bld.create_obj('cpp', 'shlib')
obj.source='''
a1.cpp
b1.cpp b2.cpp
'''
obj.includes = '.'
#obj.name = 'peter'
obj.target = 'testshlib'
obj.inst_var = 'SOME_INSTALL_DIR'

# 3. A static library
# The extension (.a) is added automatically
obj = bld.create_obj('cpp', 'staticlib')
obj.source='''
c1.cpp
'''
obj.includes = '.'
obj.name = 'tony'
obj.target = 'teststaticlib'

# 4. Another shared library
obj = bld.create_obj('cpp', 'shlib')
obj.source='''
d1.cpp
'''
obj.includes = '.'
obj.target = 'shlib1'
obj.name = 'john'
obj.want_libtool = 1
obj.vnum = '1.2.3'

# 5. A program that links against shlib1
obj = bld.create_obj('cpp', 'program')
obj.source='''
e1.cpp
'''
obj.includes = '.'
obj.uselib = 'MYPROG'
obj.uselib_local = 'tony john testshlib' # 'tony john peter' # look for 'peter' above
obj.target = 'program_dyn_linked'

# IMPORTANT WARNING:
# uselib_local expects *names*, that is, the field obj.name
# by simplicity, when there is no ambiguity: obj.target == obj.name

# installing files, headers ..
install_files('PREFIX', 'include', 'a1.h')
#install_as('PREFIX', 'dir/ahoy.h', 'a1.h')

def set_options(opt):
# options defined if src/ was to be compiled as a standalone module
opt.add_option('--meow', type='string', help='option hidden in the src module', dest='meow')

def configure(conf):
print "sub-configuration file called (demo)"

Show details Hide details

Change log

r4125 by gjcarneiro on Jul 09, 2008   Diff
Create a branch out of waf 1.4.2.
Go to: 
Project members, sign in to write a code review

Older revisions

r3373 by tnagy1024 on May 17, 2008   Diff
New release.
r3217 by tnagy1024 on Apr 23, 2008   Diff
Docs.
r3084 by tnagy1024 on Apr 09, 2008   Diff
Docs.
All revisions of this file

File info

Size: 2798 bytes, 104 lines
Hosted by Google Code