This repository has been archived by the owner on Mar 8, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
crystal.rb
67 lines (53 loc) · 1.88 KB
/
crystal.rb
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
58
59
60
61
62
63
64
65
66
67
CRYSTAL_VERSION = ENV['CRYSTAL_RELEASE_VERSION'] || "0.20.4"
FIRST_RUN = ENV["FIRST_RUN"]
name "crystal"
default_version CRYSTAL_VERSION
source git: "https://github.com/crystal-lang/crystal"
dependency "pcre"
dependency "bdw-gc"
dependency "llvm_bin" unless FIRST_RUN
dependency "libevent"
env = with_standard_compiler_flags(with_embedded_path(
"LIBRARY_PATH" => "#{install_dir}/embedded/lib"
))
env["CFLAGS"] << " -fPIC"
unless FIRST_RUN
llvm_bin = Omnibus::Software.load(project, "llvm_bin", nil)
end
output_bin = "#{install_dir}/embedded/bin/crystal"
if FIRST_RUN
env["PATH"] = "#{project_dir}/deps:#{env["PATH"]}"
else
env["PATH"] = "#{llvm_bin.project_dir}/bin:#{project_dir}/deps:#{env["PATH"]}"
end
if mac_os_x?
env["CRYSTAL_PATH"] = "/private/var/cache/omnibus/src/crystal/src"
else
env["CRYSTAL_PATH"] = "#{project_dir}/src"
end
build do
command "git checkout #{CRYSTAL_VERSION}", cwd: project_dir
mkdir "#{project_dir}/deps"
command "make deps", env: env
command "mkdir .build", env: env
command "echo #{Dir.pwd}", env: env
command "cp #{Dir.pwd}/crystal-#{ohai['os']}-#{ohai['kernel']['machine']} .build/crystal", env: env
command "bin/crystal build src/compiler/crystal.cr --release --no-debug -o #{output_bin} -D without_openssl -D without_zlib", env: env
block do
raise "Could not build crystal" unless File.exists?(output_bin)
if mac_os_x?
otool_libs = `otool -L #{output_bin}`
if otool_libs.include?("/usr/local/lib")
raise "Found local libraries linked to the generated compiler:\n#{otool_libs}"
end
end
end
sync "#{project_dir}/src", "#{install_dir}/src"
sync "#{project_dir}/etc", "#{install_dir}/etc"
sync "#{project_dir}/samples", "#{install_dir}/samples"
mkdir "#{install_dir}/bin"
erb source: "crystal.erb",
dest: "#{install_dir}/bin/crystal",
mode: 0755,
vars: { install_dir: install_dir }
end