Fix vendoring OTP (#1495)

Summary of changes:

- Vendor OTP at: rel/vendor/otp
- Remove rel/vendor/otp/lib/*/src
- Include /usr/local/bin in $PATH. This is not there by default and that's where homebrew (on x86_64) installs things so it should make it easier to build some packages with NIFs.
This commit is contained in:
Wojtek Mach 2022-10-24 10:56:16 +02:00 committed by GitHub
parent d392e8d4ab
commit e152c9d1a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 11 deletions

View file

@ -1,6 +1,13 @@
<%
additional_paths = Enum.map_join(@app_options[:additional_paths], ":", &"\\(resourcePath)/#{&1}")
additional_paths =
Enum.map_join(@app_options[:additional_paths], ":", fn path ->
if String.starts_with?(path, "/") do
path
else
"\\(resourcePath)/#{path}"
end
end)
%>import Cocoa
@ -88,6 +95,7 @@ func buildReleaseTask() -> Process {
<%= if additional_paths != "" do %>
let resourcePath = Bundle.main.resourcePath ?? ""
_ = resourcePath
let additionalPaths = "<%= additional_paths %>"
let path = task.environment!["PATH"] ?? ""
task.environment!["PATH"] = "\(additionalPaths):\(path)"

View file

@ -164,7 +164,8 @@ defmodule Livebook.MixProject do
]
],
additional_paths: [
"rel/erts-#{:erlang.system_info(:version)}/bin",
"/usr/local/bin",
"rel/vendor/otp/bin",
"rel/vendor/elixir/bin"
],
macos: [

View file

@ -10,11 +10,13 @@ defmodule Standalone do
erts_source = Path.join(:code.root_dir(), "erts-#{release.erts_version}")
otp_bin_dir = Path.join(:code.root_dir(), "bin")
otp_lib_dir = :code.lib_dir()
vendor_otp_dir = Path.join([release.path, "vendor", "otp"])
File.rm_rf!(vendor_otp_dir)
File.mkdir_p!(vendor_otp_dir)
# 1. copy erts/{bin,include}
release_erts_bin_dir = Path.join(release.path, "erts-#{release.erts_version}/bin")
release_erts_bin_dir = Path.join([vendor_otp_dir, "erts-#{release.erts_version}", "bin"])
File.mkdir_p!(release_erts_bin_dir)
cp_r!(Path.join(erts_source, "bin"), release_erts_bin_dir)
File.rm(Path.join(release_erts_bin_dir, "erl"))
@ -37,28 +39,35 @@ defmodule Standalone do
make_executable(Path.join(release_erts_bin_dir, "erl"))
release_erts_include_dir = Path.join(release.path, "erts-#{release.erts_version}/include")
release_erts_include_dir =
Path.join([vendor_otp_dir, "erts-#{release.erts_version}", "include"])
cp_r!(Path.join(erts_source, "include"), release_erts_include_dir)
# 2. copy lib
release_lib_dir = Path.join(release.path, "lib")
release_lib_dir = Path.join(vendor_otp_dir, "lib")
cp_r!(otp_lib_dir, release_lib_dir)
for dir <- Path.wildcard("#{release_lib_dir}/*/doc/{xml,html,pdf}") do
File.rm_rf!(dir)
end
# 3. copy boot files
release_bin_dir = Path.join(release.path, "bin")
for dir <- Path.wildcard("#{release_lib_dir}/*/src") do
File.rm_rf!(dir)
end
for file <- Path.wildcard(Path.join(otp_bin_dir, "*.boot")) do
# 3. copy boot files
release_bin_dir = Path.join(vendor_otp_dir, "bin")
File.mkdir!(release_bin_dir)
for file <- Path.wildcard(Path.join(otp_bin_dir, "*")) do
File.cp!(file, Path.join(release_bin_dir, Path.basename(file)))
end
# 4. copy usr
cp_r!(Path.join(:code.root_dir(), "usr"), Path.join(release.path, "usr"))
cp_r!(Path.join(:code.root_dir(), "usr"), Path.join(vendor_otp_dir, "usr"))
%{release | erts_source: erts_source}
release
end
@doc """