-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrakefile
176 lines (146 loc) · 2.99 KB
/
rakefile
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Source
NAME = 'tec-suite'
SRC = 'tecs.py'
CFG = 'tecs.cfg'
def windows?
(/mingw/ =~ RUBY_PLATFORM) != nil
end
def linux?
(/linux/ =~ RUBY_PLATFORM) != nil
end
def x86_64?
(/x86_64/ =~ RUBY_PLATFORM) != nil
end
def macos?
(/darwin/ =~ RUBY_PLATFORM) != nil
end
def version
`git describe`.chomp
end
def platform
if x86_64?
return '64'
else
return '32'
end
end
def cheol(fname)
f_content = open(fname) { |f| f.readlines }
f_content = f_content.collect { |l| l.chomp }
open(fname, 'w') do |f|
f_content.each { |l| f.puts l }
end
end
windows? and (
# Python and PyInstaller
PYTHON = 'c:\Python27\python.exe'
PYINSTALLER = 'E:\tools\PyInstaller-3.1.1\pyinstaller.py'
PYIBUILDPATH = '_build'
PYISPECPATH = PYIBUILDPATH
DISTPATH = NAME + '-' + version + '-win32'
DISTFILE = DISTPATH + '.zip'
# additional files
DIST_EXTRA_FILES_PATH = DISTPATH + '/apps'
DIST_EXTRA_FILES = [
'_distfiles/apps/crx2rnx.exe',
'_distfiles/apps/gzip.exe',
'_distfiles/apps/crx2rnx.README',
'_distfiles/apps/gzip.README'
]
ARCH_CMD = [
'7z',
'a',
DISTFILE,
DISTPATH
].join(' ')
)
linux? and (
PYTHON = 'python2.7'
PYINSTALLER = '/media/sf_Projects/tools/PyInstaller-3.1.1/pyinstaller.py'
PYIBUILDPATH = '_build'
PYISPECPATH = PYIBUILDPATH
DISTPATH = NAME + '-' + version + '-linux' + platform
DISTFILE = DISTPATH + '.tgz'
DIST_EXTRA_FILES = nil
ARCH_CMD = [
'tar',
'-caf',
DISTFILE,
DISTPATH
].join(' ')
)
macos? and (
PYTHON = 'python2.7'
PYINSTALLER = '/Users/ilya/Projects/tools/PyInstaller-3.1.1/pyinstaller.py'
PYIBUILDPATH = '_build'
PYISPECPATH = PYIBUILDPATH
DISTPATH = NAME + '-' + version + '-macos'
DISTFILE = DISTPATH + '.tgz'
DIST_EXTRA_FILES = nil
ARCH_CMD = [
'tar',
'-czf',
DISTFILE,
DISTPATH
].join(' ')
)
desc 'make distributive'
task :default => [:build, :cfg] do
# add extra files
if DIST_EXTRA_FILES
mkdir DIST_EXTRA_FILES_PATH
DIST_EXTRA_FILES.each do |f|
cp f, DIST_EXTRA_FILES_PATH
windows? and (
(f =~ /\.readme$/i) and (
readme = Pathname.new(f).basename
f_path = Pathname.new(DIST_EXTRA_FILES_PATH) + readme
cheol(f_path)
)
)
end
end
# make archive
system ARCH_CMD
end
desc 'build the binary'
task :build => :clean do
cmd = [
PYTHON,
PYINSTALLER,
"--specpath=#{PYISPECPATH}",
"--workpath=#{PYIBUILDPATH}",
"--distpath=#{DISTPATH}",
"--clean",
"--name=tecs",
"--onefile",
SRC
].join(' ')
system cmd
end
desc 'copy confguration file'
task :cfg do
if windows?
require 'pathname'
cfg_path = Pathname.new(DISTPATH)
cfg = cfg_path + CFG
chenc_cmd = [
'iconv',
'-f utf-8',
'-t cp1251',
CFG,
'>',
cfg
].join(' ')
system chenc_cmd
cheol(cfg)
else
cp CFG, DISTPATH
end
end
desc 'clean'
task :clean do
rm_rf DISTPATH
rm_rf DISTFILE
rm_rf PYIBUILDPATH
end