mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-12-27 01:42:11 +08:00
Minor bootstrap improvements (#1380)
This commit is contained in:
parent
e14fbdb616
commit
52cf7c8a5b
6 changed files with 123 additions and 132 deletions
130
.github/scripts/app/bootstrap_mac.sh
vendored
130
.github/scripts/app/bootstrap_mac.sh
vendored
|
@ -3,142 +3,34 @@ set -e pipefail
|
|||
|
||||
main() {
|
||||
export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN)
|
||||
elixir_vsn="${elixir_vsn:-1.14.0}"
|
||||
|
||||
wxwidgets_repo="wxWidgets/wxWidgets"
|
||||
wxwidgets_ref="v3.1.7"
|
||||
otp_repo="wojtekmach/otp"
|
||||
otp_ref="wm-WX_MACOS_NON_GUI_APP"
|
||||
elixir_vsn="1.14.0-rc.1"
|
||||
mkdir -p tmp/cache
|
||||
. .github/scripts/app/bootstrap_otp_mac.sh
|
||||
|
||||
target=$(target)
|
||||
|
||||
mkdir -p tmp
|
||||
|
||||
wxwidgets_dir="$PWD/tmp/wxwidgets-${wxwidgets_ref}-$target"
|
||||
if [ ! -d $wxwidgets_dir ]; then
|
||||
build_wxwidgets $wxwidgets_repo $wxwidgets_ref $target $wxwidgets_dir
|
||||
fi
|
||||
|
||||
export PATH="${wxwidgets_dir}/bin:$PATH"
|
||||
echo "checking wx"
|
||||
file `which wxrc`
|
||||
wx-config --version
|
||||
echo
|
||||
|
||||
openssl_dir=$(brew --prefix openssl@1.1)
|
||||
|
||||
otp_dir="$PWD/tmp/otp-${otp_ref}-$target"
|
||||
if [ ! -d $otp_dir ]; then
|
||||
build_otp $otp_repo $otp_ref $target $openssl_dir $otp_dir
|
||||
fi
|
||||
|
||||
export PATH="${otp_dir}/bin:$PATH"
|
||||
echo "checking otp"
|
||||
file `which erlc`
|
||||
erl +V
|
||||
erl -noshell -eval 'io:format("root_dir=~p~n", [code:root_dir()]), halt().'
|
||||
erl -noshell -eval 'ok = crypto:start(), io:format("crypto ok~n"), halt().'
|
||||
erl -noshell -eval '{wx_ref,_,_,_} = wx:new(), io:format("wx ok~n"), halt().'
|
||||
echo
|
||||
|
||||
elixir_dir="$PWD/tmp/elixir-${elixir_vsn}"
|
||||
elixir_dir="$PWD/tmp/cache/elixir-${elixir_vsn}"
|
||||
if [ ! -d "${elixir_dir}" ]; then
|
||||
build_elixir $elixir_vsn
|
||||
build_elixir $elixir_vsn $elixir_dir
|
||||
fi
|
||||
|
||||
export PATH="${elixir_dir}/bin:$PATH"
|
||||
echo "checking elixir"
|
||||
elixir --version
|
||||
|
||||
cat << EOF > tmp/bootstrap_env.sh
|
||||
export PATH="${otp_dir}/bin:\$PATH"
|
||||
export PATH="${elixir_dir}/bin:\$PATH"
|
||||
EOF
|
||||
}
|
||||
|
||||
build_wxwidgets() {
|
||||
repo=$1
|
||||
ref=$2
|
||||
target=$3
|
||||
dest_dir=$4
|
||||
src_dir=tmp/wxwidgets-$ref-src
|
||||
|
||||
if [ ! -d $src_dir ]; then
|
||||
echo cloning $repo $ref
|
||||
git clone --branch $ref --depth 1 --recursive https://github.com/$repo $src_dir
|
||||
fi
|
||||
|
||||
cd $src_dir
|
||||
./configure \
|
||||
--disable-shared \
|
||||
--prefix=$dest_dir \
|
||||
--with-cocoa \
|
||||
--with-macosx-version-min=10.15 \
|
||||
--disable-sys-libs
|
||||
make
|
||||
make install
|
||||
cd -
|
||||
}
|
||||
|
||||
build_otp() {
|
||||
repo=$1
|
||||
ref=$2
|
||||
target=$3
|
||||
openssl_dir=$4
|
||||
dest_dir=$5
|
||||
|
||||
src_dir=tmp/otp-$ref-src
|
||||
if [ ! -d $src_dir ]; then
|
||||
echo cloning $repo $ref
|
||||
git clone --branch $ref --depth 1 --recursive https://github.com/$repo $src_dir
|
||||
fi
|
||||
|
||||
export RELEASE_ROOT=$dest_dir
|
||||
|
||||
cd $src_dir
|
||||
export ERL_TOP=`pwd`
|
||||
export ERLC_USE_SERVER=true
|
||||
./otp_build configure \
|
||||
--disable-dynamic-ssl-lib \
|
||||
--with-ssl=$openssl_dir \
|
||||
--without-odbc
|
||||
|
||||
./otp_build boot -a
|
||||
./otp_build release -a $RELEASE_ROOT
|
||||
make release_docs DOC_TARGETS=chunks
|
||||
cd -
|
||||
|
||||
cd $RELEASE_ROOT
|
||||
./Install -sasl $PWD
|
||||
./bin/erl -noshell -eval 'io:format("~s", [erlang:system_info(system_version)]), halt().'
|
||||
./bin/erl -noshell -eval 'ok = crypto:start(), halt().'
|
||||
./bin/erl -noshell -eval '{wx_ref,_,_,_} = wx:new(), halt().'
|
||||
cd -
|
||||
echo "elixir ok"
|
||||
}
|
||||
|
||||
# build_elixir $vsn $dest_dir
|
||||
build_elixir() {
|
||||
vsn=$1
|
||||
dest_dir=$2
|
||||
otp_release=$(erl -noshell -eval 'io:format("~s", [erlang:system_info(otp_release)]), halt().')
|
||||
|
||||
cd tmp
|
||||
# TODO: On Elixir 1.14, use https://github.com/elixir-lang/elixir/releases/download/v${vsn}/elixir-${vsn}-otp-${otp_release}.zip
|
||||
url=https://repo.hex.pm/builds/elixir/v${vsn}-otp-${otp_release}.zip
|
||||
curl --fail -LO $url
|
||||
mkdir elixir-$vsn
|
||||
unzip v${vsn}-otp-${otp_release}.zip -d elixir-$vsn
|
||||
cd -
|
||||
}
|
||||
|
||||
target() {
|
||||
os=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
arch=$(uname -m)
|
||||
case $arch in
|
||||
"arm64") arch="aarch64";;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
echo "$arch-$os"
|
||||
mkdir -p $dest_dir
|
||||
unzip -q v${vsn}-otp-${otp_release}.zip -d $dest_dir
|
||||
cd - > /dev/null
|
||||
}
|
||||
|
||||
main
|
||||
|
|
103
.github/scripts/app/bootstrap_otp_mac.sh
vendored
Normal file
103
.github/scripts/app/bootstrap_otp_mac.sh
vendored
Normal file
|
@ -0,0 +1,103 @@
|
|||
#!/bin/bash
|
||||
set -e pipefail
|
||||
|
||||
main() {
|
||||
export MAKEFLAGS=-j$(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
wxwidgets_repo="${wxwidgets_repo:-wxWidgets/wxWidgets}"
|
||||
wxwidgets_ref="${wxwidgets_ref:-v3.1.7}"
|
||||
otp_repo="${otp_repo:-wojtekmach/otp}"
|
||||
otp_ref="${otp_ref:-wm-WX_MACOS_NON_GUI_APP}"
|
||||
|
||||
mkdir -p tmp/cache
|
||||
|
||||
openssl_dir=$(brew --prefix openssl@1.1)
|
||||
|
||||
otp_dir="$PWD/tmp/cache/${otp_repo}-${otp_ref}"
|
||||
if [ ! -d $otp_dir ]; then
|
||||
wxwidgets_dir="$PWD/tmp/cache/${wxwidgets_repo}-${wxwidgets_ref}"
|
||||
if [ ! -d $wxwidgets_dir ]; then
|
||||
build_wxwidgets $wxwidgets_repo $wxwidgets_ref $wxwidgets_dir
|
||||
fi
|
||||
|
||||
export PATH="${wxwidgets_dir}/bin:$PATH"
|
||||
echo "checking wx"
|
||||
file `which wxrc`
|
||||
wx-config --version
|
||||
echo "wx ok"
|
||||
echo
|
||||
build_otp $otp_repo $otp_ref $openssl_dir $otp_dir
|
||||
fi
|
||||
|
||||
export PATH="${otp_dir}/bin:$PATH"
|
||||
echo "checking otp"
|
||||
cd $otp_dir
|
||||
./Install -sasl $PWD
|
||||
erl -noshell -eval 'io:format("root_dir=~p~n", [code:root_dir()]), halt().'
|
||||
erl -noshell -eval 'io:format("~s", [erlang:system_info(system_version)]), halt().'
|
||||
erl -noshell -eval 'io:format("~s~n", [erlang:system_info(system_architecture)]), halt().'
|
||||
erl -noshell -eval 'ok = crypto:start(), io:format("crypto ok~n"), halt().'
|
||||
erl -noshell -eval '{wx_ref,_,_,_} = wx:new(), io:format("wx ok~n"), halt().'
|
||||
cd - > /dev/null
|
||||
echo "otp ok"
|
||||
echo
|
||||
}
|
||||
|
||||
# build_wxwidgets $repo $ref $dest_dir
|
||||
build_wxwidgets() {
|
||||
repo=$1
|
||||
ref=$2
|
||||
dest_dir=$3
|
||||
src_dir=tmp/$repo-$ref-src
|
||||
|
||||
if [ ! -d $src_dir ]; then
|
||||
echo cloning $repo $ref
|
||||
git clone --branch $ref --depth 1 --recursive https://github.com/$repo $src_dir
|
||||
fi
|
||||
|
||||
cd $src_dir
|
||||
./configure \
|
||||
--disable-shared \
|
||||
--prefix=$dest_dir \
|
||||
--with-cocoa \
|
||||
--with-macosx-version-min=10.15 \
|
||||
--disable-sys-libs
|
||||
make
|
||||
make install
|
||||
cd - > /dev/null
|
||||
}
|
||||
|
||||
|
||||
# build_otp $repo $ref $openssl_dir $dest_dir
|
||||
build_otp() {
|
||||
repo=$1
|
||||
ref=$2
|
||||
openssl_dir=$3
|
||||
dest_dir=$4
|
||||
|
||||
src_dir=tmp/otp-$repo-$ref-src
|
||||
if [ ! -d $src_dir ]; then
|
||||
echo cloning $repo $ref
|
||||
git clone --branch $ref --depth 1 --recursive https://github.com/$repo $src_dir
|
||||
fi
|
||||
|
||||
export RELEASE_ROOT=$dest_dir
|
||||
|
||||
cd $src_dir
|
||||
export ERL_TOP=`pwd`
|
||||
export ERLC_USE_SERVER=true
|
||||
./otp_build configure \
|
||||
--disable-dynamic-ssl-lib \
|
||||
--with-ssl=$openssl_dir \
|
||||
--without-odbc
|
||||
|
||||
./otp_build boot -a
|
||||
./otp_build release -a $RELEASE_ROOT
|
||||
|
||||
if [ -z "$skip_docs" ]; then
|
||||
make release_docs DOC_TARGETS=chunks
|
||||
fi
|
||||
cd - > /dev/null
|
||||
}
|
||||
|
||||
main
|
3
.github/scripts/app/build_mac.sh
vendored
3
.github/scripts/app/build_mac.sh
vendored
|
@ -8,8 +8,7 @@
|
|||
# $ open ./test/support/notebooks/basic.livemd
|
||||
set -e
|
||||
|
||||
sh .github/scripts/app/bootstrap_mac.sh
|
||||
. tmp/bootstrap_env.sh
|
||||
. .github/scripts/app/bootstrap_mac.sh
|
||||
mix local.hex --force --if-missing
|
||||
mix local.rebar --force --if-missing
|
||||
MIX_ENV=prod MIX_TARGET=app mix deps.get --only prod
|
||||
|
|
|
@ -102,12 +102,9 @@ defmodule AppBundler.MacOS do
|
|||
)
|
||||
|
||||
to_sign =
|
||||
"#{app_dir}/**"
|
||||
|> Path.wildcard()
|
||||
|> Enum.filter(fn file ->
|
||||
stat = File.lstat!(file)
|
||||
Bitwise.band(0o100, stat.mode) != 0 and stat.type == :regular
|
||||
end)
|
||||
"find #{app_dir} -perm +111 -type f -exec sh -c \"file {} | grep --silent Mach-O\" \\; -print"
|
||||
|> shell!(into: "")
|
||||
|> String.split("\n", trim: true)
|
||||
|
||||
to_sign = to_sign ++ [app_dir]
|
||||
|
||||
|
@ -122,9 +119,8 @@ defmodule AppBundler.MacOS do
|
|||
log(:green, "signing", Path.relative_to_cwd(app_dir))
|
||||
codesign(to_sign, "--options=runtime --entitlements=#{entitlements_plist_path}", notarization)
|
||||
|
||||
target = AppBundler.target()
|
||||
vsn = release.version
|
||||
dmg_path = "#{Mix.Project.build_path()}/#{app_name}Install-#{vsn}-#{target}.dmg"
|
||||
dmg_path = "#{Mix.Project.build_path()}/#{app_name}Install-#{vsn}.dmg"
|
||||
log(:green, "creating", Path.relative_to_cwd(dmg_path))
|
||||
|
||||
cmd!(
|
||||
|
|
|
@ -14,7 +14,8 @@ defmodule AppBundler.Utils do
|
|||
|
||||
def shell!(command, opts \\ []) do
|
||||
opts = Keyword.put_new(opts, :into, IO.stream())
|
||||
{_, 0} = System.shell(command, opts)
|
||||
{output, 0} = System.shell(command, opts)
|
||||
output
|
||||
end
|
||||
|
||||
def ensure_executable(url) do
|
||||
|
|
4
mix.exs
4
mix.exs
|
@ -1,11 +1,11 @@
|
|||
defmodule Livebook.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
@elixir_requirement "~> 1.14-rc.1"
|
||||
@elixir_requirement "~> 1.14"
|
||||
@version "0.6.3"
|
||||
@description "Interactive and collaborative code notebooks - made with Phoenix LiveView"
|
||||
|
||||
@app_elixir_version "1.14.0-rc.1"
|
||||
@app_elixir_version "1.14.0"
|
||||
@app_rebar3_version "3.19.0"
|
||||
|
||||
def project do
|
||||
|
|
Loading…
Reference in a new issue