forked from chapel-lang/chapel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchapel-main.rb
121 lines (107 loc) · 4.17 KB
/
chapel-main.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
class Chapel < Formula
include Language::Python::Shebang
desc "Programming language for productive parallel computing at scale"
homepage "https://chapel-lang.org/"
url "<url-placeholder-value-injected-during-testing>"
sha256 "<sha256-placeholder-value-injected-during-testing>"
license "Apache-2.0"
head "https://github.com/chapel-lang/chapel.git", branch: "main"
# Don't include the bottle information in chapel-main.rb deliberatley. The
# idea is that we don't want to accidentally use a published bottle in our testing,
# which would always report passing.
depends_on "cmake"
depends_on "gmp"
depends_on "hwloc"
depends_on "jemalloc"
depends_on "llvm@19"
depends_on "pkgconf"
depends_on "[email protected]"
def llvm
deps.map(&:to_formula).find { |f| f.name.match? "^llvm" }
end
def install
# Always detect Python used as dependency rather than needing aliased Python formula
python = "python3.13"
# It should be noted that this will expand to: 'for cmd in python3.13 python3 python python2; do'
# in our find-python.sh script.
inreplace "util/config/find-python.sh", /^(for cmd in )(python3 )/, "\\1#{python} \\2"
# a lot of scripts have a python3 or python shebang, which does not point to python3.12 anymore
Pathname.glob("**/*.py") do |pyfile|
rewrite_shebang detected_python_shebang, pyfile
end
libexec.install Dir["*"]
# Chapel uses this ENV to work out where to install.
ENV["CHPL_HOME"] = libexec
ENV["CHPL_GMP"] = "system"
# This ENV avoids a problem where cmake cache is invalidated by subsequent make calls
ENV["CHPL_CMAKE_USE_CC_CXX"] = "1"
ENV["CHPL_CMAKE_PYTHON"] = python
# don't try to set CHPL_LLVM_GCC_PREFIX since the llvm
# package should be configured to use a reasonable GCC
(libexec/"chplconfig").write <<~EOS
CHPL_RE2=bundled
CHPL_GMP=system
CHPL_TARGET_MEM=jemalloc
CHPL_TARGET_JEMALLOC=system
CHPL_HWLOC=system
CHPL_LLVM_CONFIG=#{llvm.opt_bin}/llvm-config
CHPL_LLVM_GCC_PREFIX=none
EOS
# Must be built from within CHPL_HOME to prevent build bugs.
# https://github.com/Homebrew/legacy-homebrew/pull/35166
cd libexec do
system "./util/printchplenv", "--all"
with_env(CHPL_LLVM: "none") do
system "make"
end
with_env(CHPL_LLVM: "system") do
system "make"
end
with_env(CHPL_PIP_FROM_SOURCE: "1") do
system "make", "chpldoc"
system "make", "chplcheck"
system "make", "chpl-language-server"
end
system "make", "mason"
system "make", "cleanall"
rm_r("third-party/llvm/llvm-src/")
rm_r("third-party/gasnet/gasnet-src/")
rm_r("third-party/libfabric/libfabric-src/")
rm_r("third-party/libunwind/libunwind-src/")
rm_r("third-party/gmp/gmp-src/")
rm_r("third-party/qthread/qthread-src/")
end
# Install chpl and other binaries (e.g. chpldoc) into bin/ as exec scripts.
platform = if OS.linux? && Hardware::CPU.is_64_bit?
"linux64-#{Hardware::CPU.arch}"
else
"#{OS.kernel_name.downcase}-#{Hardware::CPU.arch}"
end
bin.install libexec.glob("bin/#{platform}/*")
bin.env_script_all_files libexec/"bin"/platform, CHPL_HOME: libexec
man1.install_symlink libexec.glob("man/man1/*.1")
(lib/"cmake/chpl").install libexec.glob("lib/cmake/chpl/*")
end
test do
ENV["CHPL_HOME"] = libexec
ENV["CHPL_INCLUDE_PATH"] = HOMEBREW_PREFIX/"include"
ENV["CHPL_LIB_PATH"] = HOMEBREW_PREFIX/"lib"
cd libexec do
with_env(CHPL_LLVM: "system") do
system "util/test/checkChplInstall"
system "util/test/checkChplDoc"
end
with_env(CHPL_LLVM: "none") do
system "util/test/checkChplInstall"
system "util/test/checkChplDoc"
end
end
system bin/"chpl", "--print-passes", "--print-commands", libexec/"examples/hello.chpl"
system bin/"chpldoc", "--version"
system bin/"mason", "--version"
# Test chplcheck, if it works CLS probably does too.
# chpl-language-server will hang indefinitely waiting for a LSP client
system bin/"chplcheck", "--list-rules"
system bin/"chplcheck", libexec/"examples/hello.chpl"
end
end