Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 220 lines (197 sloc) 6.039 kB
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
1 $include_const "iglobals.pasm";
0ab5e7c @leto Remove use of the deprecated 'using extern' in Winxed
leto authored
2 $loadlib "io_ops";
6e66cb7 @bubaflub winxed > PIR, use setup.winxed
authored
3
4 function main[main](argv) {
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
5 var parrot_gmp = {
6e66cb7 @bubaflub winxed > PIR, use setup.winxed
authored
6 "name" : 'Parrot-GMP',
7 "abstract" : 'Parrot bindings for the GNU Multi-Precision Library',
7060cfd @bubaflub update description and rosella test dependency
authored
8 "description" : 'Parrot bindings for the GNU Multi-Precision Library. Currently has bindings for Integer type functions and random initialization functions.',
6e66cb7 @bubaflub winxed > PIR, use setup.winxed
authored
9 "authority" : 'http://github.com/bubaflub',
10 "copyright_holder" : 'Bob Kuo',
11 "keywords" : ["parrot", "gmp"],
12 "license_type" : 'Artistic License 2.0',
13 "license_uri" : 'http://www.perlfoundation.org/artistic_license_2_0',
14 "checkout_uri" : 'git://github.com/bubaflub/parrot-gmp.git',
15 "browser_uri" : 'git://github.com/bubaflub/parrot-gmp',
16 "project_uri" : 'git://github.com/bubaflub/parrot-gmp',
17 "pir_winxed" : {},
18 "pbc_pir" : {},
19 "inst_lib" : [],
20 "installable_pbc" : {},
21 "include_winxed" : {},
22 "manifest_includes" : ["README.md", "setup.winxed"]
23 };
0a99c90 @bubaflub update setup.winxed:
authored
24 var config = getinterp()[IGLOBALS_CONFIG_HASH];
25 ${ set_global 'config', config };
6e66cb7 @bubaflub winxed > PIR, use setup.winxed
authored
26
27 if (argv[1] == "test")
28 do_test();
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
29
30 setup_stable_libraries(parrot_gmp);
31
32 load_bytecode('distutils.pir');
33 using setup;
34 using register_step_before;
35
36 register_step_before("build", check_dependencies);
37 register_step_before("clean", clean_build_dir);
38
4d9acd0 @bubaflub changes for NCI thunks:
authored
39 if (_config('has_libffi') != 1) {
40 register_step_before("build", build_nci_thunks);
a6372e0 @bubaflub updates to setup:
authored
41 register_step_before("clean", clean_nci_thunks);
4d9acd0 @bubaflub changes for NCI thunks:
authored
42 register_step_after("install", install_nci_thunks);
43 }
44
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
45 argv.shift();
46 setup(argv, parrot_gmp);
47 }
48
49 function setup_stable_libraries(var parrot_gmp) {
e75759e @bubaflub there is no raw.winxed, fix the setup scripts
authored
50 parrot_gmp["pbc_pir"]["GMP/raw.pbc"] = "src/GMP/raw.pir";
51 parrot_gmp["inst_lib"].push("GMP/raw.pbc");
52
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
53 var libs = [
54 'Common',
55 'Random',
56 'Integer'
57 ];
58
59 string prefix = "src/GMP/";
60
61 for (string source in libs) {
62 string winxed_file = prefix + source + ".winxed";
63 string pir_file = prefix + source + ".pir";
edf5ad6 @bubaflub install to GMP/ instead of src/GMP and update all tests and examples
authored
64 string pbc_file = "GMP/" + source + ".pbc";
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
65 parrot_gmp["pir_winxed"][pir_file] = winxed_file;
66 parrot_gmp["pbc_pir"][pbc_file] = pir_file;
b79df51 @bubaflub add install path
authored
67 parrot_gmp["inst_lib"].push(pbc_file);
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
68 }
e75759e @bubaflub there is no raw.winxed, fix the setup scripts
authored
69
6e66cb7 @bubaflub winxed > PIR, use setup.winxed
authored
70 }
71
72 function do_test() {
73 int result;
0a99c90 @bubaflub update setup.winxed:
authored
74 string command = _build_command([
75 "parrot-nqp",
76 "t/harness"
77 ]);
78 ${ spawnw result, command };
6e66cb7 @bubaflub winxed > PIR, use setup.winxed
authored
79 ${ exit result };
80 }
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
81
82 function check_dependencies() {
83 // Check if Parrot is > 3.2.0
0a99c90 @bubaflub update setup.winxed:
authored
84 int maj = _config('MAJOR');
85 int min = _config('MINOR');
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
86 if (maj < 3 || (maj == 3 && min < 2)) {
87 die("You need at least Parrot 3.2.0 to use Parrot-GMP");
88 }
89 // Check if Parrot has been built/configured with gmp
0a99c90 @bubaflub update setup.winxed:
authored
90 int has_gmp = _config('HAS_GMP');
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
91 if (!has_gmp) {
92 die("You need to have Parrot configured with GMP to use Parrot-GMP");
93 }
94 // Check GMP version > 4.3
95 // Also grab other system dependent information
96 string file = "build/gmp_test.c";
0a99c90 @bubaflub update setup.winxed:
authored
97 string exe = "build/gmp_test" + string(_config('exe'));
98 string command = _build_command([
99 _config('cc'),
100 _config('ccflags'),
101 _config('cc_exe_out'),
102 exe,
103 file
104 ]);
105 say(command);
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
106 system(command);
4871e4c @bubaflub update setup to handle actually check GMP version
authored
107 var pipe = new "FileHandle";
108 pipe.encoding('utf8');
109 pipe.open(exe, "rp");
110 string output = pipe.readall();
111 pipe.close();
112 int exit_status = pipe.exit_status();
113 if (exit_status != 0) {
114 die("Could not run " + exe + ": please check that your system has libgmp");
115 }
116 var lines = split("\n", output);
117 var values = split(' ', lines[0]);
118 int gmp_major = values[0];
119 int gmp_minor = values[1];
120 int gmp_patch = values[2];
34a68e4 @bubaflub actually support back to 4.2 and not just 4.3
authored
121 if (gmp_major < 4 || (gmp_major == 4 && gmp_minor < 2)) {
122 die("Need GMP version >= 4.2");
4871e4c @bubaflub update setup to handle actually check GMP version
authored
123 }
124 // TODO: process other values from build/gmp_test
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
125 }
126
127 function clean_build_dir() {
0a99c90 @bubaflub update setup.winxed:
authored
128 string exe = "build/gmp_test" + string(_config('exe'));
129 _unlink_file(exe);
130 _unlink_file("src/GMP/thunks.c");
131 _unlink_file("src/GMP/thunks.o");
132 }
133
134 function _unlink_file(string file) {
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
135 int e = 0;
0a99c90 @bubaflub update setup.winxed:
authored
136 ${ stat e, file, 0 };
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
137 if (e) {
0a99c90 @bubaflub update setup.winxed:
authored
138 say("unlink " + file);
139 unlink(file);
67cbcf3 @bubaflub update README and setup.winxed - build, clean, and test work
authored
140 }
141 }
0a99c90 @bubaflub update setup.winxed:
authored
142
143 function build_nci_thunks() {
144 string thunk = "src/GMP/thunks.c";
145 int result;
146 string command = _build_command([
147 "parrot_nci_thunk_gen",
148 "--dynext",
149 "--no-warn-dups",
150 "--output=src/GMP/thunks.c",
151 "<src/GMP/thunks.nci"
152 ]);
153 say(command);
154 ${ spawnw result, command };
155
156 string file = "src/GMP/thunks.c";
5956c4c @bubaflub fix missing string cast and move a few things around
authored
157 string obj = "GMP/thunks" + string(_config('o'));
0a99c90 @bubaflub update setup.winxed:
authored
158 command = _build_command([
159 _config('cc'),
160 _config('ccflags'),
d84acae @bubaflub attempted fix for building, Eclesia++
authored
161 _config('cc_shared'),
0a99c90 @bubaflub update setup.winxed:
authored
162 _config('embed-cflags'),
163 _config('libparrot_linkflags'),
164 "-Ipmc/pmc_nci.h",
165 _config('cc_o_out'),
166 obj,
167 "-c",
168 file
169 ]);
170 say(command);
171 ${ spawnw result, command };
5956c4c @bubaflub fix missing string cast and move a few things around
authored
172 string shared_obj = "GMP/thunks" + string(_config('load_ext'));
0a99c90 @bubaflub update setup.winxed:
authored
173 command = _build_command([
174 _config('ld'),
175 _config('ld_out'),
176 shared_obj,
177 obj,
178 _config('ldflags'),
179 _config('ld_debug'),
180 _config('rpath_blib'),
181 _config('linkflags'),
182 _config('ld_load_flags')
183 ]);
184 if(string(_config('parrot_is_shared'))) {
185 command = command + " " + string(_config('inst_libparrot_ldflags'));
186 }
187 say(command);
188 ${ spawnw result, command };
189 }
190
a6372e0 @bubaflub updates to setup:
authored
191 function clean_nci_thunks() {
192 _unlink_file("src/GMP/thunks.c");
193 _unlink_file("GMP/thunks" + string(_config('o')));
194 _unlink_file("GMP/thunks" + string(_config('load_ext')));
195 }
196
4d9acd0 @bubaflub changes for NCI thunks:
authored
197 function install_nci_thunks() {
198 string install_path = string(_config('libdir')) + string(_config('versiondir'));
199 install_path += string(_config('slash')) + 'dynext' + string(_config('slash'));
200 string shared_obj = "GMP/thunks" + string(_config('load_ext'));
201 int result;
202 string command = _build_command([
203 'cp',
204 shared_obj,
205 install_path
206 ]);
207 say(command);
208 ${ spawnw result, command };
209 }
210
0a99c90 @bubaflub update setup.winxed:
authored
211 function _config(string key) {
212 var config;
213 ${ get_global config, 'config' };
214 return string(config[key]);
215 }
216
217 function _build_command(var commands) {
218 return string(join(' ', commands));
219 }
Something went wrong with that request. Please try again.