Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create install script #753

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions docs/src/quickstart/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@ At this point Fe is only available for **Linux** and **MacOS**.
> Note: If you happen to be a Windows developer, consider getting involved
> and help us to support the Windows platform. [Here would be a good place to start.](https://github.com/ethereum/fe/issues/62)

### Download the compiler

At this point Fe is only distributed via a single executable file linked from the [home page](https://fe-lang.org). In the future we will make sure it can be installed through popular package managers such as `apt` or `homebrew`.
First run the command below to get fe compiler, and add fe compier to your PATH:

Depending on your operating system, the file that you download is either named `fe_amd64` or `fe_mac`.

> Note: We will rename the file to `fe` and assume that name for the rest of the guide. In the future when Fe can be installed via other mechanisms we can assume `fe` to become the canonical command name.
```bash
curl https://raw.githubusercontent.com/ethereum/fe/create-install-script/install.sh | sh
```

### Add permission to execute
Check install successfuly
```

In order to be able to execute the Fe compiler we will have to make the file *executable*. This can be done by navigating to the directory where the file is located and executing `chmod + x <filename>` (e.g. `chmod +x fe`).
> fe

After we have set the proper permissions we should be able to run `./fe_amd64 --help` or `./fe_mac -h` and an output that should be roughly comparable to:

```
Fe 0.4.0-alpha
Compiler for the Fe language

Expand All @@ -39,4 +37,6 @@ OPTIONS:

ARGS:
<input> The input source file to use e.g erc20.fe
```
```

Happy coding!!!
77 changes: 77 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
set -e


# Reference from https://github.com/foundry-rs/foundry/blob/master/foundryup/install
need_cmd() {
if ! check_cmd "$1"; then
err "need '$1' (command not found)"
fi
}

check_cmd() {
command -v "$1" > /dev/null 2>&1
}

echo "Installing fe compiler to your system..."

need_cmd jq

FE_DIR=${FE_DIR-"$HOME/.fe"}
FE_BIN_DIR="$FE_DIR/bin"
FE_BIN="$FE_BIN_DIR/fe"

mkdir -p $FE_BIN_DIR
echo $FE_DIR
echo $FE_BIN_DIR
echo $FE_BIN

OS=$(uname -s)

echo "Your OS is $OS"

if [ $(uname -s) = "Linux" ]; then
ARCHITECTURE="amd64"
else
ARCHITECTURE="mac"
fi


VERSION=$(curl --silent https://api.github.com/repos/ethereum/fe/releases | jq -r 'map(select(.prerelease)) | first | .tag_name')
echo "Installing latest version $VERSION..."


FE_LINK=https://github.com/ethereum/fe/releases/download/${VERSION}/fe_$ARCHITECTURE

echo $FE_LINK
curl -L $FE_LINK -o $FE_BIN
chmod +x $FE_BIN

case $SHELL in
*/zsh)
PROFILE=$HOME/.zshrc
;;
*/bash)
PROFILE=$HOME/.bashrc
;;
*/fish)
PROFILE=$HOME/.config/fish/config.fish
;;
*)
echo "Cannot detect shell in your system. Please manually add ${FE_BIN_DIR} to your PATH!"
exit 1
esac

echo "Add fe dir to you PATH"
if [[ ":$PATH:" != *":${FE_BIN_DIR}:"* ]]; then
echo >> $PROFILE && echo "export PATH=\"\$PATH:$FE_BIN_DIR\"" >> $PROFILE
fi

if [[ "$OSTYPE" =~ ^darwin && ! -f /usr/local/opt/libusb/lib/libusb-1.0.0.dylib ]]; then
echo && echo "warning: libusb not found. You may need to install it manually on MacOS via Homebrew (brew install libusb)."
fi

echo "Install complete... Please start new terminal or run 'source $PROFILE' to reset shell env"