-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwscript
138 lines (105 loc) · 2.85 KB
/
wscript
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#! /usr/bin/env python
# encoding: utf-8
'''
@file: wscript
@date: Sep 6, 2014
@author: Milos Subotic <[email protected]>
@license: MIT
@brief: Waf script for building coloring_tee project.
@version: 1.0
Changelog:
1.0 - Initial version.
'''
###############################################################################
import os
import fnmatch
import shutil
import datetime
import waflib
###############################################################################
VERSION = '4.0'
APPNAME = 'coloring_tee'
top = '.'
out = 'build'
###############################################################################
def recursive_glob(pattern, directory = '.'):
for root, dirs, files in os.walk(directory, followlinks = True):
for f in files:
if fnmatch.fnmatch(f, pattern):
yield os.path.join(root, f)
for d in dirs:
if fnmatch.fnmatch(d + '/', pattern):
yield os.path.join(root, d)
def collect_git_ignored_files():
for gitignore in recursive_glob('.gitignore'):
with open(gitignore) as f:
base = os.path.dirname(gitignore)
for pattern in f.readlines():
pattern = pattern[:-1]
for f in recursive_glob(pattern, base):
yield f
###############################################################################
def options(opt):
opt.load('compiler_c compiler_cxx')
opt.add_option(
'--debug',
action = 'store_true',
dest = 'debug',
default = False,
help = 'enable compiler debug information'
)
opt.recurse('source')
def configure(conf):
conf.load('compiler_c compiler_cxx')
conf.env.CFLAGS += []
conf.env.CXXFLAGS += []
if conf.options.debug:
conf.env.CFLAGS.append('-g')
conf.env.CXXFLAGS.append('-g')
conf.define('INSTALL_PREFIX', conf.options.prefix)
conf.define('VERSION_STR', VERSION)
conf.define('PROGRAM_NAME', APPNAME)
conf.define(
'DEFAUL_CONFIG_FILE',
os.path.join(conf.options.prefix, 'share/coloring_tee/config.lua')
)
conf.write_config_header('config.h')
conf.recurse('source')
def build(bld):
bld.install_files(
'${PREFIX}/share/coloring_tee',
bld.path.ant_glob('share/coloring_tee/*')
)
bld.install_files(
'${PREFIX}/bin',
bld.path.ant_glob('bin/*'),
chmod = 0755
)
bld.recurse('source')
def distclean(ctx):
for fn in collect_git_ignored_files():
if os.path.isdir(fn):
shutil.rmtree(fn)
else:
os.remove(fn)
def dist(ctx):
# TODO For now dist is with .git, make new command backup.
now = datetime.datetime.now()
time_stamp = '{:d}-{:02d}-{:02d}-{:02d}-{:02d}-{:02d}'.format(
now.year,
now.month,
now.day,
now.hour,
now.minute,
now.second
)
ctx.arch_name = '../{}-{}.zip'.format(APPNAME, time_stamp)
ctx.algo = 'zip'
ctx.base_name = APPNAME
# Also pack git.
waflib.Node.exclude_regs = waflib.Node.exclude_regs.replace(
'''
**/.git
**/.git/**
**/.gitignore''', '')
###############################################################################