-
Notifications
You must be signed in to change notification settings - Fork 4
/
Build.pm6
57 lines (51 loc) · 1.9 KB
/
Build.pm6
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
#! /usr/bin/env perl6
#Note `zef build .` will run this script
use v6;
class Build {
need LibraryMake;
# adapted from deprecated Native::Resources
#| Sets up a C<Makefile> and runs C<make>. C<$folder> should be
#| C<"$folder/resources/lib"> and C<$libname> should be the name of the library
#| without any prefixes or extensions.
sub make(Str $folder, Str $destfolder, IO() :$libname!, Str :$I) {
my %vars = LibraryMake::get-vars($destfolder);
%vars<LIB-NAME> = ~ $*VM.platform-library-name($libname);
if Rakudo::Internals.IS-WIN {
unless $I {
note "Using prebuilt DLLs on Windows";
return True;
}
%vars<LIB-CFLAGS> = "-I$I";
%vars<LIBS> = '-lxml2';
%vars<MAKE> = 'make';
%vars<CC> = 'gcc';
%vars<CCFLAGS> = '-fPIC -O3 -DNDEBUG --std=gnu99 -Wextra -Wall';
%vars<LD> = 'gcc';
%vars<LDSHARED> = '-shared';
%vars<LDFLAGS> = "-fPIC -O3 -Lresources/libraries";
%vars<CCOUT> = '-o ';
%vars<LDOUT> = '-o ';
}
else {
%vars<LIBS> = chomp(qx{xml2-config --libs 2>/dev/null} || '-lxml2');
%vars<LIB-CFLAGS> = $I
?? "-I$I"
!! chomp(qx{xml2-config --cflags 2>/dev/null} || '-I/usr/include/libxml2');
s/:s '-DNDEBUG'// for %vars<CCFLAGS>, %vars<LDFLAGS>;
}
mkdir($destfolder);
LibraryMake::process-makefile($folder, %vars);
shell(%vars<MAKE>);
True;
}
method build($workdir, Str :$I) {
my $destdir = 'resources/libraries';
mkdir $destdir;
make($workdir, "$destdir", :libname<xml6>, :$I);
True;
}
}
# Build.pm can also be run standalone
sub MAIN(Str $working-directory = '.', Str :$I ) {
Build.new.build($working-directory, :$I);
}