diff --git a/makefile b/makefile new file mode 100644 index 000000000..069943f5b --- /dev/null +++ b/makefile @@ -0,0 +1,25 @@ +# Use install-deps instead of 'install' because usually 'make install' adds a +# binary to the system path and we don't want to confuse users +install-deps: +# Install ligo/tezos specific system-level dependencies + sudo scripts/install_native_dependencies.sh + +build-deps: +# Create opam dev switch locally for use with Ligo, add merlin/etc + if [ -n "`opam switch show | grep -P ".+/ligo"`" ]; + then exit; else scripts/setup_dev_switch.sh; + fi +# Set up the local ligo opam repository so that it can be built + if [ -n "`opam repo list --safe | grep -P "ligo-opam-repository"`" ]; + then exit; else scripts/setup_ligo_opam_repository.sh; + fi +# Install OCaml build dependencies for Ligo + scripts/install_ligo_with_dependencies.sh + +build: build-deps +# Build Ligo for local dev use + scripts/build_ligo_local.sh + +.ONESHELL: +test: build + scripts/test_ligo.sh diff --git a/scripts/build_ligo_local.sh b/scripts/build_ligo_local.sh new file mode 100755 index 000000000..85fcb6892 --- /dev/null +++ b/scripts/build_ligo_local.sh @@ -0,0 +1,2 @@ +eval $(opam env) +dune build -p ligo diff --git a/scripts/install_build_environment.sh b/scripts/install_build_environment.sh new file mode 100755 index 000000000..4d5e36400 --- /dev/null +++ b/scripts/install_build_environment.sh @@ -0,0 +1,64 @@ +# This script installs opam for the user. It should NOT be included in any makefiles/etc. + +if [ -n "`which opam`" ] +then + if [ -n "`opam --version | grep -P "2\..\.."`" ] + then + echo "Opam 2.x seems to already exist, exiting..." + exit 1 + else + read -p "This script will upgrade opam to the 2.x series, are you okay with that? (y/n)" choice1 + case "$choice1" in + y|Y ) : ;; + n|N ) exit ;; + esac + fi +fi + +sudo apt-get install -y make \ + m4 \ + gcc \ + patch \ + bubblewrap \ + rsync \ + curl \ + +if [ -n "`uname -a | grep -i ubuntu`" ] +then + sudo add-apt-repository -y ppa:avsm/ppa + sudo apt-get update + sudo apt-get install opam +else + # I'm going to assume here that we're on x86_64, 32-bit users should be basically + # extinct at this point right? + curl -L https://github.com/ocaml/opam/releases/download/2.0.4/opam-2.0.4-x86_64-linux \ + --output opam_temp_version_2_0_4.bin + if [ "`openssl sha256 -r opam_temp_version_2_0_4.bin`" = "373e34f92f282273d482537f8103caad0d17b6f2699ff504bed77f474cb0c951 *opam_temp_version_2_0_4.bin" ] + then + # Stay paranoid, in case other checks fail don't want to overrwrite + # user's opam on accident + chmod +x opam_temp_version_2_0_4.bin # Set execute so we can get version + if [ -e /usr/local/bin/opam ] + then + opam_old_v=`/usr/local/bin/opam --version` + opam_new_v=`opam_temp_version_2_0_4.bin --version` + read -p "This will overrwrite the opam you have in /usr/local/bin (version $opam_old_v) with version $opam_new_v, do you actually want to do that? Type yes. (yes/n)" choice2 + else + choice2="yes" + fi + if [ $choice2 = "yes" ] + then + sudo mv opam_temp_version_2_0_4.bin /usr/local/bin/opam + else + rm opam_temp_version_2_0_4.bin + exit + fi + else + echo "opam file hash doesn't match what was recorded at time of signature verification!" + echo "(If you actually get this message, you should probably file an issue)" + echo "https://gitlab.com/ligolang/ligo/issues" + exit 1 + fi +fi + +opam init -a --bare diff --git a/scripts/setup_dev_switch.sh b/scripts/setup_dev_switch.sh new file mode 100755 index 000000000..5b9ea1dca --- /dev/null +++ b/scripts/setup_dev_switch.sh @@ -0,0 +1,4 @@ +opam switch create . ocaml-base-compiler.4.06.1 +eval $(opam env) +opam install -y ocp-indent tuareg merlin alcotest-lwt crowbar +opam -y user-setup install diff --git a/scripts/test_ligo.sh b/scripts/test_ligo.sh new file mode 100755 index 000000000..d13e26d3d --- /dev/null +++ b/scripts/test_ligo.sh @@ -0,0 +1,2 @@ +eval $(opam env) +dune build @ligo-test