mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-10 15:04:25 +08:00
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:
parent
d392e8d4ab
commit
e152c9d1a7
3 changed files with 29 additions and 11 deletions
|
@ -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
|
%>import Cocoa
|
||||||
|
|
||||||
|
@ -88,6 +95,7 @@ func buildReleaseTask() -> Process {
|
||||||
|
|
||||||
<%= if additional_paths != "" do %>
|
<%= if additional_paths != "" do %>
|
||||||
let resourcePath = Bundle.main.resourcePath ?? ""
|
let resourcePath = Bundle.main.resourcePath ?? ""
|
||||||
|
_ = resourcePath
|
||||||
let additionalPaths = "<%= additional_paths %>"
|
let additionalPaths = "<%= additional_paths %>"
|
||||||
let path = task.environment!["PATH"] ?? ""
|
let path = task.environment!["PATH"] ?? ""
|
||||||
task.environment!["PATH"] = "\(additionalPaths):\(path)"
|
task.environment!["PATH"] = "\(additionalPaths):\(path)"
|
||||||
|
|
3
mix.exs
3
mix.exs
|
@ -164,7 +164,8 @@ defmodule Livebook.MixProject do
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
additional_paths: [
|
additional_paths: [
|
||||||
"rel/erts-#{:erlang.system_info(:version)}/bin",
|
"/usr/local/bin",
|
||||||
|
"rel/vendor/otp/bin",
|
||||||
"rel/vendor/elixir/bin"
|
"rel/vendor/elixir/bin"
|
||||||
],
|
],
|
||||||
macos: [
|
macos: [
|
||||||
|
|
|
@ -10,11 +10,13 @@ defmodule Standalone do
|
||||||
erts_source = Path.join(:code.root_dir(), "erts-#{release.erts_version}")
|
erts_source = Path.join(:code.root_dir(), "erts-#{release.erts_version}")
|
||||||
otp_bin_dir = Path.join(:code.root_dir(), "bin")
|
otp_bin_dir = Path.join(:code.root_dir(), "bin")
|
||||||
otp_lib_dir = :code.lib_dir()
|
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}
|
# 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)
|
File.mkdir_p!(release_erts_bin_dir)
|
||||||
|
|
||||||
cp_r!(Path.join(erts_source, "bin"), release_erts_bin_dir)
|
cp_r!(Path.join(erts_source, "bin"), release_erts_bin_dir)
|
||||||
|
|
||||||
File.rm(Path.join(release_erts_bin_dir, "erl"))
|
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"))
|
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)
|
cp_r!(Path.join(erts_source, "include"), release_erts_include_dir)
|
||||||
|
|
||||||
# 2. copy lib
|
# 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)
|
cp_r!(otp_lib_dir, release_lib_dir)
|
||||||
|
|
||||||
for dir <- Path.wildcard("#{release_lib_dir}/*/doc/{xml,html,pdf}") do
|
for dir <- Path.wildcard("#{release_lib_dir}/*/doc/{xml,html,pdf}") do
|
||||||
File.rm_rf!(dir)
|
File.rm_rf!(dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
# 3. copy boot files
|
for dir <- Path.wildcard("#{release_lib_dir}/*/src") do
|
||||||
release_bin_dir = Path.join(release.path, "bin")
|
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)))
|
File.cp!(file, Path.join(release_bin_dir, Path.basename(file)))
|
||||||
end
|
end
|
||||||
|
|
||||||
# 4. copy usr
|
# 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
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
Loading…
Add table
Reference in a new issue