Skip to content

Commit

Permalink
Install solc binaries in make.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
shohamc1 committed Jul 26, 2023
1 parent 5652859 commit c865942
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ setup_vars() {

CLANG_DEFAULT_VERSION=${CLANG_DEFAULT_VERSION:-"15"}
RUST_DEFAULT_VERSION=${RUST_DEFAULT_VERSION:-"1.70"}

SOLC_DIR=${SOLC_DIR:-"${BUILD_TARGET_DIR}/solc-bin"}

MAKE_DEBUG=${MAKE_DEBUG:-"1"}

Expand Down Expand Up @@ -72,6 +74,7 @@ main() {
_platform_init
setup_vars
git_add_hooks
_append_to_path "${SOLC_DIR}"

# Get all functions declared in this file except ones starting with
# '_' or the ones in the list
Expand All @@ -86,10 +89,12 @@ main() {
if [[ "$x" == "$cmd" ]]; then
shift
${cmd} "$@"
_remove_from_path "${SOLC_DIR}"
return 0
fi
done

_remove_from_path "${SOLC_DIR}"
help
return 1
}
Expand Down Expand Up @@ -546,6 +551,44 @@ pkg_install_rust() {
_fold_end
}

pkg_install_solc_linux() {
_fold_start "pkg-install-solc"

local solc_dir="${SOLC_DIR}"

_ensure_enter_dir "${solc_dir}"
wget -O solc https://github.com/ethereum/solidity/releases/download/v0.8.20/solc-static-linux
chmod +x solc
_exit_dir

_fold_end
}

pkg_install_solc_osx() {
_fold_start "pkg-install-solc"

local solc_dir="${SOLC_DIR}"

_ensure_enter_dir "${solc_dir}"
wget -o solc https://github.com/ethereum/solidity/releases/download/v0.8.20/solc-macos
chmod +x solc
_exit_dir

_fold_end
}

pkg_install_solc_windows() {
_fold_start "pkg-install-solc"

local solc_dir="${SOLC_DIR}"

_ensure_enter_dir "${solc_dir}"
wget -o solc https://github.com/ethereum/solidity/releases/download/v0.8.20/solc-windows.exe
_exit_dir

_fold_end
}

pkg_local_ensure_osx_sysroot() {
local sdk_name="Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers"
local pkg="${sdk_name}.tar.gz"
Expand Down Expand Up @@ -969,6 +1012,7 @@ ci_setup_deps() {
DEBIAN_FRONTEND=noninteractive pkg_setup_locale
DEBIAN_FRONTEND=noninteractive pkg_install_llvm
DEBIAN_FRONTEND=noninteractive pkg_install_rust
DEBIAN_FRONTEND=noninteractive pkg_install_solc_linux
}

_ci_setup_deps_target() {
Expand Down Expand Up @@ -1055,4 +1099,34 @@ _exit_dir() {
popd > /dev/null
}

_append_to_path() {
if [ -d "$1" ]; then
# Check if the directory is not already in the PATH
if [[ ":$PATH:" != *":$1:"* ]]; then
# Append the directory to the PATH
path="$PATH:$1"
export PATH="${path}"
else
echo "'$1' already in PATH"
fi
else
echo "'$1' does not exist"
fi
}

_remove_from_path() {
if [ -d "$1" ]; then
# Check if the directory is in the PATH
if [[ ":$PATH:" == *":$1:"* ]]; then
# Remove the directory from the PATH
path=$(echo "$PATH" | tr : '\n' | grep -v "^$1$" | tr '\n' :)
export PATH="${path}"
else
echo "'$1' not in PATH"
fi
else
echo "'$1' does not exist"
fi
}

main "$@"

0 comments on commit c865942

Please sign in to comment.