Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 338 lines (278 sloc) 9.212 kb
32929b6 @lateau setup.winxed
lateau authored
1 #!/usr/bin/env winxed
2
e8116ba @lateau ignore pod with /* */
lateau authored
3 /*
4 =head1 NAME
5
6 setup.winxed - Python distutils style
7
8 =head1 DESCRIPTION
9
10 No Configure step, no Makefile generated.
11
12 See <runtime/parrot/library/distutils.pir>.
13
14 =head1 USAGE
15
16 $ winxed setup.winxed build
17 $ winxed setup.winxed test [name]
18 $ sudo winxed setup.winxed install
19
20 for more usages:
21 $ winxed setup.winxed help
22
23 =cut
24 */
32929b6 @lateau setup.winxed
lateau authored
25
27f7162 @lateau issue #18
lateau authored
26 $include_const "iglobals.pasm";
b675f75 @tadzik Fix setup.winxed
tadzik authored
27 $loadlib "io_ops";
27f7162 @lateau issue #18
lateau authored
28
29 function main[main](argv) {
30 load_bytecode('distutils.pir');
31
32 using setup;
32929b6 @lateau setup.winxed
lateau authored
33 using register_step;
27f7162 @lateau issue #18
lateau authored
34 using register_step_before;
32929b6 @lateau setup.winxed
lateau authored
35 using register_step_after;
27f7162 @lateau issue #18
lateau authored
36
37 // config
32929b6 @lateau setup.winxed
lateau authored
38 var config = getinterp()[IGLOBALS_CONFIG_HASH];
39 var requirement = {
40 "parrot" : "3.8.0",
41 "winxed" : '1.2.0+'
42 };
27f7162 @lateau issue #18
lateau authored
43 var cardinal = {
44 "name" : 'Cardinal',
45 "abstract" : 'Cardinal - Ruby compiler for Parrot',
46 "authority" : 'http://github.com/parrot',
47 "description" : 'Cardinal is a Ruby compiler for Parrot.',
48 "keywords" : [ "parrot", "cardinal", "ruby" ],
49 "license_type" : 'Artistic License 2.0',
50 "license_uri" : 'http://www.perlfoundation.org/artistic_license_2_0',
51 "copyright_holder" : 'Parrot Foundation',
52 "checkout_uri" : 'git://github.com/parrot/cardinal.git',
53 "browser_uri" : 'git://github.com/parrot/cardinal.git',
54 "project_uri" : 'git://github.com/parrot/cardinal.git',
55 "inc_pir" : {},
56 "pir_pge" : {},
57 "pir_nqp" : {},
58 "pir_pir" : {},
59 "pbc_pir" : {},
32929b6 @lateau setup.winxed
lateau authored
60 "prove_exec" : string(get_parrot()) + ' cardinal.pbc',
61 "prove_files" : 't/*.t t/*/*.t',
62 "prove_archive" : 'report.tar.gz',
63 "smolder_url" : 'http://smolder.parrot.org/app/projects/process_add_report/10',
64 "installable_pbc" : { 'parrot-cardinal' : 'cardinal.pbc' },
27f7162 @lateau issue #18
lateau authored
65 "doc_files" : 'README.rdoc',
66 "manifest_includes" : ["README.rdoc", "setup.winxed"]
67 };
68
32929b6 @lateau setup.winxed
lateau authored
69 ${ set_global 'cardinal', cardinal };
70 ${ set_global 'config', config };
71 ${ set_global 'requirement', requirement };
72
73 // check dependencies
74 check_cardinal_deps();
75
76 // test option:
77 // ex) setup.winxed test array
27f7162 @lateau issue #18
lateau authored
78 if ( (argv[1] == 'test') && argv[2] != '' ) {
79 var test_target = argv[2];
80 ${ set_global 'test_target', test_target };
81 }
82
83 // register steps
84 register_step_before("build", __build);
85 register_step_after("build", __build_test_pir);
86 register_step_before("clean", __clean);
32929b6 @lateau setup.winxed
lateau authored
87 register_step_before("test", __optional_test);
4841027 @lateau target install added
lateau authored
88 register_step_before("smoke", __smoke);
27f7162 @lateau issue #18
lateau authored
89 register_step_after("help", __help);
32929b6 @lateau setup.winxed
lateau authored
90 register_step_before("install", __check_install);
91
92 // run build before 'sdist', 'bdist'
93 if ( (argv[1] == 'sdist') || (argv[1] == 'bdist') ) {
94 run_step('build', cardinal:[flat, named]);
95 }
27f7162 @lateau issue #18
lateau authored
96
97 argv.shift();
32929b6 @lateau setup.winxed
lateau authored
98 setup(argv:[flat], cardinal:[flat, named]);
27f7162 @lateau issue #18
lateau authored
99 }
100
32929b6 @lateau setup.winxed
lateau authored
101
102 // ///////////////////////////////// //
103 // MISC
104 // ///////////////////////////////// //
105
106 function check_cardinal_deps() {
27f7162 @lateau issue #18
lateau authored
107 var config;
4841027 @lateau target install added
lateau authored
108 var requirement;
27f7162 @lateau issue #18
lateau authored
109 ${ get_global config, 'config'};
4841027 @lateau target install added
lateau authored
110 ${ get_global requirement, 'requirement'};
27f7162 @lateau issue #18
lateau authored
111
4841027 @lateau target install added
lateau authored
112 var req = split('.', requirement['parrot']);
27f7162 @lateau issue #18
lateau authored
113 var sys = split('.', config['VERSION']);
114
b675f75 @tadzik Fix setup.winxed
tadzik authored
115 if( !(sys[0] >= req[0] || sys[1] >= req[1] || sys[2] >= req[2]) ) {
32929b6 @lateau setup.winxed
lateau authored
116 say(
117 "BUILD FAILED" + "\n" +
118 "===================================================" + "\n" +
119 "Your Parrot is older version than Cardinal requires" + "\n" +
120 "Please upgrade to Parrot-" + string(requirement['parrot']) + "\n" +
121 "\n" +
122 "See parrot download page for more details:" + "\n" +
123 " http://parrot.org/download" + "\n"
124 );
27f7162 @lateau issue #18
lateau authored
125 die('');
126 }
127 }
128
32929b6 @lateau setup.winxed
lateau authored
129 function get_submitter() {
130 var env = new "Env";
131 string submitter = env['SMOLDER_SUBMITTER'];
132
133 return submitter;
134 }
135
136 // ///////////////////////////////// //
137 // BEFORE STEPS HERE
138 // ///////////////////////////////// //
139
140 // add a {NewClass}.pir here
27f7162 @lateau issue #18
lateau authored
141 function __build() {
142 var cardinal;
143 ${ get_global cardinal, 'cardinal'};
144
145 cardinal['inc_pir']['src/gen_builtins.pir'] = [
146 "src/builtins/guts.pir",
147 "src/builtins/control.pir",
148 "src/builtins/say.pir",
149 "src/builtins/cmp.pir",
150 "src/builtins/op.pir",
151 "src/classes/Object.pir",
152 "src/classes/Exception.pir",
153 "src/classes/NilClass.pir",
154 "src/classes/String.pir",
155 "src/classes/Numeric.pir",
156 "src/classes/Integer.pir",
157 "src/classes/Float.pir",
158 "src/classes/Array.pir",
159 "src/classes/Hash.pir",
160 "src/classes/Range.pir",
161 "src/classes/TrueClass.pir",
162 "src/classes/FalseClass.pir",
163 "src/classes/Kernel.pir",
164 "src/classes/Time.pir",
165 "src/classes/Math.pir",
166 "src/classes/GC.pir",
167 "src/classes/IO.pir",
168 "src/classes/Proc.pir",
169 "src/classes/File.pir",
170 "src/classes/FileStat.pir",
171 "src/classes/Dir.pir",
172 "src/builtins/globals.pir",
173 "src/builtins/eval.pir",
174 "src/classes/Continuation.pir"
175 ];
176 cardinal['pir_pge']['src/gen_grammar.pir'] = 'src/parser/grammar.pg';
177 cardinal['pir_nqp']['src/gen_actions.pir'] = 'src/parser/actions.pm';
178
179 cardinal['pbc_pir']['cardinal.pbc'] = [
180 "cardinal.pir",
181 "src/parser/quote_expression.pir",
182 "src/gen_grammar.pir",
183 "src/gen_actions.pir",
184 "src/gen_builtins.pir"
185 ];
186 }
187
188 function __build_test_pir() {
32929b6 @lateau setup.winxed
lateau authored
189 int exit_code = 0;
190 ${ stat exit_code, './Test.pir', 0 };
191
192 // pass Test.pir when cardinal is already builded
193 if ( ! exit_code ) {
194 // build Test.rb
195 var cardinal;
196 ${ get_global cardinal, 'cardinal' };
197
198 string parrot_cmd = string(get_parrot());
199 string installable_pbc = string(cardinal['installable_pbc']['parrot-cardinal']);
200
201 var cmd = parrot_cmd + ' ' + installable_pbc + ' ' + '--target=pir --output=Test.pir Test.rb';
202
203 say(cmd);
204 system(cmd);
205 }
206 }
207
208 function __check_install() {
209 var cardinal;
210 string installable_pbc;
211 int exit_code = 0;
212
213 ${ get_global cardinal, 'cardinal' };
214 installable_pbc = string(cardinal['installable_pbc']['parrot-cardinal']);
215 ${ stat exit_code, installable_pbc, 0 };
216
217 if ( ! exit_code ) {
218 say(
219 "INSTALL FAILED" + "\n" +
220 "===========================================" + "\n" +
221 "Make sure build cardinal before run install" + "\n" +
222 "\n" +
223 "$ winxed setup.winxed build" + "\n" +
224 "$ sudo winxed setup.winxed install"
225 );
226 ${ exit exit_code };
227 }
27f7162 @lateau issue #18
lateau authored
228 }
229
230 function __clean() {
32929b6 @lateau setup.winxed
lateau authored
231 load_bytecode('osutils.pbc');
232
27f7162 @lateau issue #18
lateau authored
233 var files = [
234 './cardinal.c',
235 './cardinal.o',
236 './cardinal.pbc',
237 './Test.pir',
238 './report.tar.gz',
239 './build.yaml',
240 './src/gen_grammar.pir',
241 './src/gen_actions.pir',
242 './src/gen_builtins.pir',
243 './cardinal.pbc',
32929b6 @lateau setup.winxed
lateau authored
244 './installable_cardinal',
245 './parrot-cardinal-HEAD.tar.gz',
246 './rpm/SOURCES/parrot-cardinal-HEAD.tar.gz',
247 './rpm/SPEC/parrot-cardinal.spec'
248 ];
249 var dirs = [
250 './rpm/SOURCES',
251 './rpm/SPECS',
252 './rpm'
27f7162 @lateau issue #18
lateau authored
253 ];
254
255 for (string file in files) {
32929b6 @lateau setup.winxed
lateau authored
256 int exit_code = 0;
257 ${ stat exit_code, file, 0 };
258
259 if ( exit_code ) {
27f7162 @lateau issue #18
lateau authored
260 say("unlink " + file);
261 unlink(file);
262 }
263 }
264
32929b6 @lateau setup.winxed
lateau authored
265 for (string dir in dirs) {
266 int exit_code = 0;
267 ${ stat exit_code, dir, 0 };
268
269 if ( exit_code ) {
270 var os;
271 ${ new os, 'OS' };
27f7162 @lateau issue #18
lateau authored
272
32929b6 @lateau setup.winxed
lateau authored
273 say("remove " + dir);
274 os.rm(dir);
27f7162 @lateau issue #18
lateau authored
275 }
276 }
32929b6 @lateau setup.winxed
lateau authored
277 }
278
279 // NO NEED TO ADD NEW TEST DIR
280 function __optional_test() {
281 var test_target;
282 ${ get_global test_target, 'test_target' };
27f7162 @lateau issue #18
lateau authored
283
32929b6 @lateau setup.winxed
lateau authored
284 if ( test_target != null ) {
285 var cardinal;
286 var files;
287 string command;
288
289 ${ get_global cardinal, 'cardinal' };
290 run_step('build', cardinal:[flat, named]);
291
292 if ( string(test_target) == 'builtins' ) {
293 files = glob('t/*.t');
294 } else {
295 files = glob('t/' + string(test_target) + '/*.t' );
296 }
297
298 command = string(get_parrot()) + ' cardinal.pbc';
299
300 say('Test ' + string(test_target) + "\n");
301 runtests(files:[flat], command:[named('exec')]);
302
303 ${ exit 0 };
304 }
27f7162 @lateau issue #18
lateau authored
305 }
306
307 function __smoke() {
308 var config;
4841027 @lateau target install added
lateau authored
309 var cardinal;
32929b6 @lateau setup.winxed
lateau authored
310 var extra_prop = {};
27f7162 @lateau issue #18
lateau authored
311
32929b6 @lateau setup.winxed
lateau authored
312 ${ get_global config, 'config' };
313 ${ get_global cardinal, 'cardinal' };
27f7162 @lateau issue #18
lateau authored
314
32929b6 @lateau setup.winxed
lateau authored
315 extra_prop['Architecture'] = string(config['archname']);
316 extra_prop['Platform'] = string(config['osname']);
317 extra_prop['Parrot Revision'] = string(config['revision']);
318 extra_prop['Submitter'] = get_submitter();
27f7162 @lateau issue #18
lateau authored
319
32929b6 @lateau setup.winxed
lateau authored
320 cardinal['smolder_extra_properties'] = extra_prop;
321 cardinal['smolder_tags'] = string(config['osname']) + ', ' + string(config['archname']);
27f7162 @lateau issue #18
lateau authored
322 }
323
324 function __help() {
4841027 @lateau target install added
lateau authored
325 var requirement;
326 ${ get_global requirement, 'requirement'};
27f7162 @lateau issue #18
lateau authored
327
4841027 @lateau target install added
lateau authored
328 string parrot = requirement['parrot'];
329 string winxed = requirement['winxed'];
27f7162 @lateau issue #18
lateau authored
330
331 say(
32929b6 @lateau setup.winxed
lateau authored
332 " " + "smoke: Report smoke test." + "\n\n" +
333 " " + "Requirements:" + "\n\n" +
334 " " + "parrot: " + " " + string(parrot) + "\n\n" +
335 " " + "winxed: " + " " + string(winxed)
27f7162 @lateau issue #18
lateau authored
336 );
337 }
Something went wrong with that request. Please try again.