Skip to content
This repository
Browse code

Merge branch 'setup_winxed' of github.com:lateau/cardinal into setup_nqp

  • Loading branch information...
commit 602e40f15c2ffa75409f6871d4f709ca49145988 2 parents 57004ee + 27f7162
lateau authored

Showing 1 changed file with 249 additions and 0 deletions. Show diff stats Hide diff stats

  1. +249 0 setup.winxed
249 setup.winxed
... ... @@ -0,0 +1,249 @@
  1 +$include_const "iglobals.pasm";
  2 +using extern "io_ops";
  3 +
  4 +function main[main](argv) {
  5 + // load parrot library & targes
  6 + load_bytecode('distutils.pir');
  7 +
  8 + using setup;
  9 + using register_step_before;
  10 +
  11 + // config
  12 + var cardinal = {
  13 + "name" : 'Cardinal',
  14 + "abstract" : 'Cardinal - Ruby compiler for Parrot',
  15 + "authority" : 'http://github.com/parrot',
  16 + "description" : 'Cardinal is a Ruby compiler for Parrot.',
  17 + "keywords" : [ "parrot", "cardinal", "ruby" ],
  18 + "license_type" : 'Artistic License 2.0',
  19 + "license_uri" : 'http://www.perlfoundation.org/artistic_license_2_0',
  20 + "copyright_holder" : 'Parrot Foundation',
  21 + "checkout_uri" : 'git://github.com/parrot/cardinal.git',
  22 + "browser_uri" : 'git://github.com/parrot/cardinal.git',
  23 + "project_uri" : 'git://github.com/parrot/cardinal.git',
  24 + "inc_pir" : {},
  25 + "pir_pge" : {},
  26 + "pir_nqp" : {},
  27 + "pir_pir" : {},
  28 + "pbc_pir" : {},
  29 + "installable_pbc" : {},
  30 + "prove_exec" : {},
  31 + "doc_files" : 'README.rdoc',
  32 + "manifest_includes" : ["README.rdoc", "setup.winxed"]
  33 + };
  34 + var required = { "parrot" : "3.8.0", "winxed" : '1.2.0' };
  35 + var config = getinterp()[IGLOBALS_CONFIG_HASH];
  36 +
  37 + // test option: ex) test array
  38 + if ( (argv[1] == 'test') && argv[2] != '' ) {
  39 + var test_target = argv[2];
  40 + ${ set_global 'test_target', test_target };
  41 + }
  42 +
  43 + ${ set_global 'cardinal', cardinal };
  44 + ${ set_global 'config', config };
  45 + ${ set_global 'required', required };
  46 +
  47 + // register steps
  48 + register_step("__build", __build);
  49 + register_step("smoke", __smoke);
  50 + register_step("__test", __test);
  51 +
  52 + register_step_before("__build", __check_dependencies);
  53 + register_step_before("build", __build);
  54 + register_step_after("build", __build_test_pir);
  55 + register_step_before("clean", __clean);
  56 + register_step_before("__test", __check_dependencies);
  57 + register_step_before("test", __test);
  58 + register_step_before("smoke", __check_dependencies);
  59 + register_step_before("install", __install);
  60 + register_step_after("help", __help);
  61 +
  62 + argv.shift();
  63 + setup(argv, cardinal);
  64 +}
  65 +
  66 +// before steps
  67 +function __check_dependencies() {
  68 + var config;
  69 + var required;
  70 + ${ get_global config, 'config'};
  71 + ${ get_global required, 'required'};
  72 +
  73 + var req = split('.', required['parrot']);
  74 + var sys = split('.', config['VERSION']);
  75 +
  76 + if( (req[0] > sys[0]) || (req[1] > sys[1]) || (req[2] > sys[2]) ) {
  77 + // bug?
  78 + // string msg = '' + required['parrot'];
  79 + // msg is expected 3.3.0 but was 3
  80 +
  81 + say("BUILD FAILED");
  82 + say("===================================================");
  83 + say("Your Parrot is older version than Cardinal requires");
  84 + print("Please upgrade to Parrot-");
  85 + say(required['parrot']);
  86 + say("");
  87 + say("See parrot download page for more details:");
  88 + say(" http://parrot.org/download");
  89 +
  90 + die('');
  91 + }
  92 +}
  93 +
  94 +function __build() {
  95 + var cardinal;
  96 + ${ get_global cardinal, 'cardinal'};
  97 +
  98 + cardinal['inc_pir']['src/gen_builtins.pir'] = [
  99 + "src/builtins/guts.pir",
  100 + "src/builtins/control.pir",
  101 + "src/builtins/say.pir",
  102 + "src/builtins/cmp.pir",
  103 + "src/builtins/op.pir",
  104 + "src/classes/Object.pir",
  105 + "src/classes/Exception.pir",
  106 + "src/classes/NilClass.pir",
  107 + "src/classes/String.pir",
  108 + "src/classes/Numeric.pir",
  109 + "src/classes/Integer.pir",
  110 + "src/classes/Float.pir",
  111 + "src/classes/Array.pir",
  112 + "src/classes/Hash.pir",
  113 + "src/classes/Range.pir",
  114 + "src/classes/TrueClass.pir",
  115 + "src/classes/FalseClass.pir",
  116 + "src/classes/Kernel.pir",
  117 + "src/classes/Time.pir",
  118 + "src/classes/Math.pir",
  119 + "src/classes/GC.pir",
  120 + "src/classes/IO.pir",
  121 + "src/classes/Proc.pir",
  122 + "src/classes/File.pir",
  123 + "src/classes/FileStat.pir",
  124 + "src/classes/Dir.pir",
  125 + "src/builtins/globals.pir",
  126 + "src/builtins/eval.pir",
  127 + "src/classes/Continuation.pir"
  128 + ];
  129 + cardinal['pir_pge']['src/gen_grammar.pir'] = 'src/parser/grammar.pg';
  130 + cardinal['pir_nqp']['src/gen_actions.pir'] = 'src/parser/actions.pm';
  131 +
  132 + cardinal['pbc_pir']['cardinal.pbc'] = [
  133 + "cardinal.pir",
  134 + "src/parser/quote_expression.pir",
  135 + "src/gen_grammar.pir",
  136 + "src/gen_actions.pir",
  137 + "src/gen_builtins.pir"
  138 + ];
  139 +
  140 + cardinal['installable_pbc']['parrot-cardinal'] = 'cardinal.pbc';
  141 +}
  142 +
  143 +function __build_test_pir() {
  144 + var cmd = './installable_cardinal --target=pir --output=Test.pir Test.rb';
  145 + say(cmd);
  146 + system(cmd);
  147 +}
  148 +
  149 +function __clean() {
  150 + var files = [
  151 + './cardinal.c',
  152 + './cardinal.o',
  153 + './cardinal.pbc',
  154 + './Test.pir',
  155 + './report.tar.gz',
  156 + './build.yaml',
  157 + './src/gen_grammar.pir',
  158 + './src/gen_actions.pir',
  159 + './src/gen_builtins.pir',
  160 + './cardinal.pbc',
  161 + './installable_cardinal'
  162 + ];
  163 +
  164 + for (string file in files) {
  165 + int e = 0;
  166 + ${ stat e, file, 0 };
  167 + if(e) {
  168 + say("unlink " + file);
  169 + unlink(file);
  170 + }
  171 + }
  172 +}
  173 +
  174 +// TODO: print test report!
  175 +function __test() {
  176 + int result;
  177 + var target;
  178 + var test_opt;
  179 + ${ get_global test_opt, 'test_target' };
  180 +
  181 + string command = './installable_cardinal ';
  182 + var files = {};
  183 + files['general'] = glob('t/*.t');
  184 + files['array'] = glob('t/array/*.t');
  185 + files['file'] = glob('t/file/*.t');
  186 + files['float'] = glob('t/float/*.t');
  187 + files['hash'] = glob('t/array/*.t');
  188 + files['integer'] = glob('t/integer/*.t');
  189 + files['kernel'] = glob('t/kernel/*.t');
  190 + files['math'] = glob('t/math/*.t');
  191 + files['range'] = glob('t/range/*.t');
  192 + files['string'] = glob('t/string/*.t');
  193 +
  194 + if ( test_opt != null ) {
  195 + target = { 'opt' : files[test_opt] };
  196 + } else {
  197 + target = files;
  198 + }
  199 +
  200 + // TODO: dirty!
  201 + // run tests
  202 + for (string key in target) {
  203 + for (string file in target[key]) {
  204 + //${ runtests file :flat, command :named('exec') };
  205 + int result = 0;
  206 + string exe = command + file;
  207 + say(exe);
  208 + ${ spawnw result, exe };
  209 + }
  210 + }
  211 +
  212 + ${ exit result };
  213 +}
  214 +
  215 +function __smoke() {
  216 + var config;
  217 + var smoke_extra = {};
  218 +
  219 + ${ get_global config, 'config'};
  220 +
  221 + smoke_extra['Architecture'] = config['archname'];
  222 + smoke_extra['Platform'] = config['osname'];
  223 + smoke_extra['Parrot Revision'] = config['revision'];
  224 + //smoke_extra['Submitter'] = get_submitter();
  225 +
  226 + config['smolder_extra_properties'] = smoke_extra;
  227 + //config['smolder_tags'] = ${get_tags()};
  228 + config['prove_archive'] = 'report.tar.gz';
  229 + config['smolder_url'] = 'http://smolder.parrot.org/app/projects/process_add_report/10';
  230 +}
  231 +
  232 +function __install() {
  233 +
  234 +}
  235 +
  236 +function __help() {
  237 + var required;
  238 + ${ get_global required, 'required'};
  239 +
  240 + string parrot = required['parrot'];
  241 + string winxed = required['winxed'];
  242 +
  243 + say(
  244 + "\t" + "smoke:\t\tReport smoke test." + "\n\n" +
  245 + " " + "Requirements:" + "\n\n" +
  246 + "\t" + "parrot: " + "\t" + parrot + "\n\n" +
  247 + "\t" + "winxed: " + "\t" + winxed
  248 + );
  249 +}

0 comments on commit 602e40f

Please sign in to comment.
Something went wrong with that request. Please try again.