Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 206 lines (186 sloc) 5.759 kB
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
1 $include_const "iglobals.pasm";
258177b @leto Get rid of a winxed deprecation warning and ignore ctags junk
leto authored
2 $loadlib "io_ops";
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
3
4 function main[main](argv) {
5 var parrot_libgit2 = {
6 "name" : 'parrot-libgit2',
7 "abstract" : 'Parrot bindings for libgit2',
8 "description" : 'Parrot bindings for libgit2 - the linkable git library',
9 "authority" : 'http://github.com/leto',
10 "copyright_holder" : 'Jonathan "Duke" Leto',
bed9503 @leto Fix a syntax error in setup.winxed and correct the path to our source…
leto authored
11 "keywords" : ["parrot", "git", "libgit2"],
1c0d7c5 @sa1 Unified build system
sa1 authored
12 "license_type" : 'GNU General Public License v3',
13 "license_uri" : 'http://www.gnu.org/licenses/gpl.html',
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
14 "checkout_uri" : 'git://github.com/leto/parrot-libgit2.git',
15 "browser_uri" : 'git://github.com/leto/parrot-libgit2',
16 "project_uri" : 'git://github.com/leto/parrot-libgit2',
17 "pir_winxed" : {},
18 "pbc_pir" : {},
19 "inst_lib" : [],
20 "installable_pbc" : {},
21 "include_winxed" : {},
22 "manifest_includes" : ["README.md", "setup.winxed"]
23 };
24
1c0d7c5 @sa1 Unified build system
sa1 authored
25 if (argv[1] == "test"){
26 build_test();
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
27 do_test();
1c0d7c5 @sa1 Unified build system
sa1 authored
28 }
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
29
30 setup_stable_libraries(parrot_libgit2);
31
32 load_bytecode('distutils.pir');
33 using setup;
34 using register_step_before;
35
36 register_step_before("build", check_dependencies);
1c0d7c5 @sa1 Unified build system
sa1 authored
37 register_step_before("build", build_nci);
b693d7c @sa1 Add compilation step
sa1 authored
38 register_step_before("build", build_lib);
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
39 register_step_before("clean", clean_build_dir);
f9d851d @sa1 Register wrapper installation step
sa1 authored
40 register_step_before("install", install_clib);
41 register_step_before("uninstall", uninstall_clib);
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
42
43 argv.shift();
44 setup(argv, parrot_libgit2);
45 }
46
47 function setup_stable_libraries(var parrot_libgit2) {
48 var libs = [
b498442 @sa1 Add Config Parsing API
sa1 authored
49 'Blob',
c14454e @leto Give Git2.Index a proper home and list all the current subsystems in …
leto authored
50 'Cache',
b498442 @sa1 Add Config Parsing API
sa1 authored
51 'Config',
a4dd73b @leto Add a test for creating a Git2.Repository object in winxed
leto authored
52 'Common',
b498442 @sa1 Add Config Parsing API
sa1 authored
53 'Commit',
c14454e @leto Give Git2.Index a proper home and list all the current subsystems in …
leto authored
54 'Index',
f7ca9ac @sa1 Add Tag API
sa1 authored
55 'Object',
f517ed7 @leto Start Git2.Odb class and add a test for git_repository_database
leto authored
56 'Odb',
8090e6f @leto Start of a Git2.Oid class
leto authored
57 'Oid',
c14454e @leto Give Git2.Index a proper home and list all the current subsystems in …
leto authored
58 'RefCache',
9bb3738 @sa1 Add AttrCache, fix Index and Repository classes
sa1 authored
59 'AttrCache',
b498442 @sa1 Add Config Parsing API
sa1 authored
60 'Repository',
8a12e0c @sa1 Add Reference API
sa1 authored
61 'Reference',
9e39a10 @sa1 Add a API to work with remotes
sa1 authored
62 'Remote',
0b92226 @sa1 Add basic rev-parsing
sa1 authored
63 'RevParse',
f7ca9ac @sa1 Add Tag API
sa1 authored
64 'RevWalk',
162f0cb @sa1 Add Tree, TreeIndex API
sa1 authored
65 'Tag',
66 'Tree',
67 'TreeIndex'
b498442 @sa1 Add Config Parsing API
sa1 authored
68 ];
69
70 var core = [
71 'git2',
72 'parrotgit'
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
73 ];
74
bed9503 @leto Fix a syntax error in setup.winxed and correct the path to our source…
leto authored
75 string prefix = "./src/Git2/";
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
76
77 for (string source in libs) {
78 string winxed_file = prefix + source + ".winxed";
79 string pir_file = prefix + source + ".pir";
bed9503 @leto Fix a syntax error in setup.winxed and correct the path to our source…
leto authored
80 string pbc_file = prefix + source + ".pbc";
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
81 parrot_libgit2["pir_winxed"][pir_file] = winxed_file;
82 parrot_libgit2["pbc_pir"][pbc_file] = pir_file;
83 parrot_libgit2["inst_lib"].push(pbc_file);
84 }
b498442 @sa1 Add Config Parsing API
sa1 authored
85 prefix = "./src/";
86 for(string source in core){
87 string pir_file = prefix + source + ".pir";
88 string pbc_file = prefix + source + ".pbc";
89 parrot_libgit2["pbc_pir"][pbc_file] = pir_file;
90 parrot_libgit2["inst_lib"].push(pbc_file);
91 }
92
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
93 }
94
1c0d7c5 @sa1 Unified build system
sa1 authored
95 function build_test() {
96 int result;
97 string cmd = "make rosella";
98 ${ spawnw result, cmd};
99 }
100
f9d851d @sa1 Register wrapper installation step
sa1 authored
101 function install_clib(){
102 //TODO use pkg-config
103 var env = new 'Env';
104 string parrotgitdir;
105 if (env['LIBPARROTGIT_INSTALL_DIR'] == ''){
106 parrotgitdir = "/usr/local/lib/";
107 }
108 else{
109 parrotgitdir = env['LIBPARROTGIT_INSTALL_DIR'];
110 }
111 string cmd = "cp libparrotgit.so " + parrotgitdir;
112 int result;
113 ${spawnw result, cmd};
114 }
115
116 function uninstall_clib(){
117 var env = new 'Env';
118 string parrotgitdir;
119 if (env['LIBPARROTGIT_INSTALL_DIR'] == ''){
120 parrotgitdir = "/usr/local/lib/";
121 }
122 else{
123 parrotgitdir = env['LIBPARROTGIT_INSTALL_DIR'];
124 }
125 string filename = parrotgitdir + "libparrotgit.so";
126 int result;
127 unlink(filename);
128 }
129
1c0d7c5 @sa1 Unified build system
sa1 authored
130 function build_nci() {
131 var env = new 'Env';
132 string libgit_dir;
133 string cmd = "pkg-config --variable=includedir libgit2 > version";
134 var out;
135 int result;
136 ${ getstdout out};
137 if (env['LIBGIT2_INSTALL_DIR'] == ''){
138 var s = new 'FileHandle';
139 ${ spawnw result, cmd};
b498442 @sa1 Add Config Parsing API
sa1 authored
140 s.open("./version");
1c0d7c5 @sa1 Unified build system
sa1 authored
141 string output = s.readline();
142 libgit_dir = substr(output, 0, length(output) - 1);
143 }
144 else {
145 libgit_dir = env['LIBGIT2_INSTALL_DIR'];
146 }
147 var ncifile = new 'FileHandle';
148 ncifile.open("src/git2.nci", "rw");
149 ncifile.print("# THIS FILE IS GENERATED, edit ./bin/header2nci.pl to make changes here\n");
150 ncifile.print("[package]\nGit2::Raw\n\n[lib]\n\nlibgit2.so\n\n[defs]\n");
151 ncifile.close();
152 string ncigencmd = "perl ./bin/header2nci.pl " + libgit_dir + "/git2.h >> src/git2.nci";
153 ${ spawnw result, ncigencmd};
154 ncigencmd = "for i in `ls " + libgit_dir + "/git2/*.h | sort -d`; do perl ./bin/header2nci.pl $i >> src/git2.nci; done";
155 ${ spawnw result, ncigencmd};
044d740 @sa1 Fix pir generation in libgit2
sa1 authored
156 string def2pir = "perl ./bin/ncidef2pir.pl src/git2.nci";
157 ${ spawnw result, def2pir};
e70c083 @sa1 Add a C wrapper for some functions
sa1 authored
158 def2pir = "perl ./bin/ncidef2pir.pl src/parrotgit.nci";
159 ${ spawnw result, def2pir};
160 }
161
162 function build_lib(){
163 int result;
242ba70 @leto Remove a linking warning and add API changes from libgit2 v0.19.0 'gu…
leto authored
164 string compile = "gcc -fPIC -c src/parrotgit.c -o src/parrotgit.o && gcc -shared -o libparrotgit.so src/parrotgit.o -lgit2";
e70c083 @sa1 Add a C wrapper for some functions
sa1 authored
165 ${spawnw result, compile};
1c0d7c5 @sa1 Unified build system
sa1 authored
166 }
167
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
168 function do_test() {
169 int result;
170 string cmd = "parrot-nqp t/harness";
171 ${ spawnw result, cmd };
172 ${ exit result };
173 }
174
175 function check_dependencies() {
176 var config = getinterp()[IGLOBALS_CONFIG_HASH];
67a641d @leto Correct our minimum parrot check to 3.5.0 instead of 3.2.0
leto authored
177 // Check if Parrot is > 3.5.0
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
178 int maj = config['MAJOR'];
179 int min = config['MINOR'];
67a641d @leto Correct our minimum parrot check to 3.5.0 instead of 3.2.0
leto authored
180 if (maj < 3 || (maj == 3 && min < 5)) {
181 die("You need at least Parrot 3.5.0 to use parrot-libgit2");
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
182 }
183 // Check if Parrot has been built/configured with libffi
184 int has_libffi = config['has_libffi'];
185 if (!has_libffi) {
186 die("You need to have Parrot configured with libffi to use parrot-libgit2");
187 }
188 }
189
190 function clean_build_dir() {
191 var config = getinterp()[IGLOBALS_CONFIG_HASH];
192 string exe = "build/git2_test" + string(config['exe']);
193 int e = 0;
194 ${ stat e, exe, 0 };
195 if (e) {
196 say("unlink " + exe);
197 unlink(exe);
198 }
6b04b2f @leto Clean up git2.pbc
leto authored
199 unlink("src/git2.pbc");
1c0d7c5 @sa1 Unified build system
sa1 authored
200 unlink("src/git2.nci");
e70c083 @sa1 Add a C wrapper for some functions
sa1 authored
201 unlink("libparrotgit.so");
202 int result = 0;
1c0d7c5 @sa1 Unified build system
sa1 authored
203 string cmd = "rm -rf rosella";
204 ${ spawnw result, cmd};
64b5dc2 @leto Initial skeleton of a Parrot library which uses winxed and rosella
leto authored
205 }
Something went wrong with that request. Please try again.