-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwscript
More file actions
77 lines (60 loc) · 1.79 KB
/
wscript
File metadata and controls
77 lines (60 loc) · 1.79 KB
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
#! /usr/bin/env python
# encoding: utf-8
'''
@author: Milos Subotic <milos.subotic.sm@gmail.com>
@license: MIT
@brief: Waf script just for distclean and dist commands.
'''
###############################################################################
import os
import fnmatch
import shutil
import datetime
import waflib
###############################################################################
APPNAME = 'huffman_coding'
top = '.'
###############################################################################
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.rstrip() # Remove new line sign on line end.
for f in recursive_glob(pattern, base):
yield f
###############################################################################
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):
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''', '')
###############################################################################