-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
48 lines (41 loc) · 1.32 KB
/
Rakefile
File metadata and controls
48 lines (41 loc) · 1.32 KB
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
require 'rbconfig'
require 'rubygems'
require 'shellwords'
cc, cflags, coutflag, libext, exeext =
RbConfig::CONFIG.fetch_values 'CC', 'CFLAGS', 'COUTFLAG', 'LIBEXT', 'EXEEXT'
prism = Gem.loaded_specs.fetch('prism').full_gem_path
include = File.join prism, 'include'
library = File.join prism, 'build'
prism_lib = File.join(library, "libprism.#{libext}") # from `prism/Makefile`
file prism_lib do
# I’m not bothering with “error while loading shared libraries:
# libprism.so: cannot open shared object file: No such file or directory”.
system 'make', '-C', prism, 'static'
end
file prism_h = File.join(include, 'prism.h')
file libprism_example_c = 'libprism_example.c'
libprism_example_exe = "libprism_example#{exeext}"
file libprism_example_exe => [libprism_example_c, prism_h, prism_lib] do
command_line = [cc,
"-I#{include.shellescape}",
cflags,
[coutflag, libprism_example_exe].join,
libprism_example_c,
"-L#{library.shellescape}",
'-lprism'
].join ' '
puts command_line if verbose
system command_line
end
task compile: libprism_example_exe
task default: :compile do
system "./#{libprism_example_exe}"
end
task :clean do
system 'make', '-C', prism, 'clean'
end
task clobber: :clean do
puts "rm #{libprism_example_exe}" if verbose
File.delete libprism_example_exe
rescue Errno::ENOENT
end