Skip to content

Commit e320958

Browse files
committed
truffle: remove incompatible binaries for arm64 linux
1 parent 70455d7 commit e320958

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Formula/t/truffle.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,25 @@ def install
2323
system "npm", "install", *std_npm_args
2424
bin.install_symlink Dir[libexec/"bin/*"]
2525

26+
# Remove incompatible pre-built binaries
2627
truffle_dir = libexec/"lib/node_modules/truffle"
2728
os = OS.kernel_name.downcase
2829
arch = Hardware::CPU.intel? ? "x64" : Hardware::CPU.arch.to_s
30+
platforms = ["#{os}-#{arch}"]
31+
platforms << "#{os}-x64+arm64" if OS.mac?
2932
%w[
3033
**/node_modules/*
3134
node_modules/ganache/node_modules/@trufflesuite/bigint-buffer
32-
node_modules/ganache/node_modules/@trufflesuite/uws-js-unofficial
3335
].each do |pattern|
34-
truffle_dir.glob("#{pattern}/{prebuilds,binaries}/*").each do |dir|
35-
if OS.mac? && dir.basename.to_s == "darwin-x64+arm64"
36-
# Replace universal binaries with their native slices
37-
deuniversalize_machos dir/"node.napi.node"
38-
else
39-
# Remove incompatible pre-built binaries
40-
dir.glob("*.musl.node").map(&:unlink)
41-
rm_r(dir) if dir.basename.to_s != "#{os}-#{arch}"
42-
end
36+
truffle_dir.glob("#{pattern}/prebuilds/*").each do |dir|
37+
dir.glob("*.musl.node").map(&:unlink)
38+
rm_r(dir) if platforms.exclude?(dir.basename.to_s)
4339
end
4440
end
45-
46-
# Replace remaining universal binaries with their native slices
47-
deuniversalize_machos truffle_dir/"node_modules/ganache/node_modules/fsevents/fsevents.node"
41+
pattern = "node_modules/ganache/node_modules/@trufflesuite/uws-js-unofficial/{binaries,dist}/*.node"
42+
truffle_dir.glob(pattern) do |f|
43+
rm(f) unless f.basename.to_s.match?("_#{os}_#{arch}_")
44+
end
4845

4946
# Remove incompatible pre-built binaries that have arbitrary names
5047
truffle_dir.glob("node_modules/ganache/dist/node{/,/F/}*.node").each do |f|
@@ -54,6 +51,9 @@ def install
5451

5552
f.unlink
5653
end
54+
55+
# Replace universal binaries with their native slices
56+
deuniversalize_machos
5757
end
5858

5959
test do

0 commit comments

Comments
 (0)