-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3529 from fable-compiler/new_build
- Loading branch information
Showing
78 changed files
with
4,723 additions
and
1,567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# We use a custom dev container for Fable, because we want to be able to | ||
# control the version of each target language we use. | ||
# This also allow to have a consistent development environment for | ||
# contributors and avoid problems like having some tools not compilable | ||
# because of .NET specificities on OSX ARM for example. | ||
|
||
# To debug this DockerFile, you can use the following commands: | ||
# | ||
# Should be run from the .devcontainer folder | ||
# | ||
# Build the docker file with the fable-dev tag | ||
# docker build --tag fable-dev . | ||
# or if you want to see the progress (useful for debugging) | ||
# docker build --tag fable-dev . --progress=plain | ||
# | ||
# Run the docker file and delete it on exit: | ||
# docker run -it --rm fable-dev | ||
|
||
# Use x86_64 architecture to avoid all the small pains | ||
# coming from alpine over ARM --platform=linux/amd64 | ||
FROM mcr.microsoft.com/devcontainers/base:debian | ||
# Install the xz-utils package | ||
RUN apt-get update && apt-get install -y xz-utils | ||
|
||
# Options | ||
# Let it here to avoid conflicts with Microsoft options !!! | ||
ARG DOTNET_VERSION=6.0.406 | ||
ARG NODE_VERSION=18.8.0 | ||
ARG PYTHON_VERSION=3.11.5 | ||
ARG DART_VERSION=3.1.2 | ||
|
||
USER vscode | ||
|
||
# Change the default shell to zsh | ||
SHELL ["/bin/zsh", "-c"] | ||
|
||
# # Install .NET | ||
WORKDIR /home/vscode | ||
RUN sudo apt install wget | ||
RUN wget -qO- https://dot.net/v1/dotnet-install.sh | bash -s - --version $DOTNET_VERSION | ||
RUN echo "# Load dotnet path" >> .zshrc | ||
RUN echo "export PATH=$PATH:/home/vscode/.dotnet" >> .zshrc | ||
# Trigger the dotnet first run experience by running a command | ||
RUN source .zshrc && dotnet --help | ||
# Add dotnet zsh completion | ||
COPY scripts/zsh_dotnet_completion.sh /home/vscode/zsh_dotnet_completion.sh | ||
RUN cat /home/vscode/zsh_dotnet_completion.sh >> .zshrc | ||
RUN rm /home/vscode/zsh_dotnet_completion.sh | ||
|
||
# Install Node.js | ||
RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash | ||
# Even, if we changed the default shell to ZSH, nvm install script | ||
# still uses bash, so we manually need to add the nvm path to zsh | ||
RUN echo "# Load nvm path" >> .zshrc | ||
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> .zshrc | ||
RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' >> .zshrc | ||
RUN echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion"' >> .zshrc | ||
# We need to source the zshrc and execute nvm install in the same RUN command | ||
# Otherwise, the nvm command will not be available | ||
RUN source .zshrc && nvm install $NODE_VERSION | ||
|
||
# Install python | ||
# Install Python build dependencies | ||
RUN sudo apt-get install -y build-essential libssl-dev zlib1g-dev \ | ||
libbz2-dev libreadline-dev libsqlite3-dev curl \ | ||
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev | ||
# Install pyenv | ||
RUN curl https://pyenv.run | bash | ||
RUN echo "# Load pyenv path" >> .zshrc | ||
RUN echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc | ||
RUN echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc | ||
RUN echo 'eval "$(pyenv init -)"' >> ~/.zshrc | ||
RUN source .zshrc && pyenv install $PYTHON_VERSION | ||
# Make python point to the installed version | ||
RUN source .zshrc && pyenv global $PYTHON_VERSION | ||
RUN source .zshrc && curl -sSL https://install.python-poetry.org | python | ||
RUN echo "# Load poetry path" >> .zshrc | ||
RUN echo 'export PATH="$HOME/.local/bin:$PATH"' >> .zshrc | ||
|
||
# Install rust | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s - -y | ||
RUN echo "# Load rust path" >> .zshrc | ||
RUN echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> .zshrc | ||
|
||
# Instal dart | ||
# Use custom dsm install script, because we broke it while | ||
# trying to fix another issue with dsm | ||
# See https://github.com/Yakiyo/dsm/issues/26 | ||
COPY scripts/install_dsm.sh /home/vscode/install_dsm.sh | ||
RUN sudo chmod +x /home/vscode/install_dsm.sh | ||
RUN /home/vscode/install_dsm.sh | ||
# RUN curl -fsSL https://dsm-vm.vercel.app/install.sh | bash | ||
RUN echo "# Load dart path" >> .zshrc | ||
RUN echo 'export PATH="/home/vscode/.dsm:$PATH"' >> .zshrc | ||
RUN echo 'eval "`dsm env zsh`"' >> .zshrc | ||
# Workaround dsm bug (see script for more details) | ||
COPY scripts/install_dart.sh /home/vscode/install_dart.sh | ||
RUN sudo chmod +x /home/vscode/install_dart.sh | ||
RUN source .zshrc && /home/vscode/install_dart.sh $DART_VERSION | ||
RUN source .zshrc && dsm use $DART_VERSION | ||
RUN rm /home/vscode/install_dsm.sh | ||
RUN rm /home/vscode/install_dart.sh | ||
|
||
# Force docker to load the zsh profile | ||
# This should be the last steps | ||
CMD [ "/bin/zsh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-outside-of-docker | ||
{ | ||
"name": "Docker outside of Docker", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
// "image": "mcr.microsoft.com/devcontainers/base:bullseye", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"Ionide.Ionide-fsharp", | ||
"adpyke.codesnap", | ||
"Dart-Code.dart-code", | ||
"EditorConfig.EditorConfig", | ||
"GitHub.copilot", | ||
"christian-kohler.npm-intellisense", | ||
"ionutvmi.path-autocomplete", | ||
"ms-python.vscode-pylance", | ||
"rust-lang.rust-analyzer", | ||
"tintoy.msbuild-project-tools", | ||
"eamodio.gitlens", | ||
"tamasfe.even-better-toml" | ||
], | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "zsh", | ||
// I don't know why but Ionide and C# extension don't find | ||
// the installed dotnet version. | ||
// For Ionide, we guide it using the following setting | ||
"FSharp.dotnetRoot": "/home/vscode/.dotnet", | ||
// For C#, we disable the warning as we don't seems to need it. | ||
// If this is a problem, we can probably use the C#/F# dockerfile | ||
// as the base and keep our way to install the different target version | ||
// .NET included to respect the global.json requirements | ||
"csharp.suppressDotnetInstallWarning": true | ||
} | ||
} | ||
}, | ||
|
||
"mounts": [ | ||
// Mount .npmrc from the host machine, to be able to use the host session | ||
// This allow the user to login on their own machine once and not each time | ||
// they build a new devcontainer | ||
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.npmrc,target=/home/vscode/.npmrc,type=bind,consistency=cached" | ||
], | ||
|
||
"containerEnv": { | ||
// Expose the local environment variable to the container | ||
// They are used for releasing and publishing from the container | ||
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}", | ||
"FABLE_NUGET_KEY": "${localEnv:FABLE_NUGET_KEY}" | ||
}, | ||
|
||
// Restore the dotnet tools when the container is attached | ||
// This makes fanomas available directly without having the user needing to | ||
// run `dotnet tool restore` or build the project once | ||
"postAttachCommand": "/bin/zsh -c 'source ~/.zshrc && dotnet tool restore'" | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "docker --version", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root", | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/zsh | ||
|
||
# dsm seems to incorrectly detect the architecture on Mac M1 | ||
# The if statement below is a workaround for this issue | ||
# See https://github.com/Yakiyo/dsm/issues/26 | ||
|
||
if [[ $(uname -m) == 'aarch64' ]]; then | ||
dsm install --arch arm64 $1; | ||
else | ||
dsm install $1; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
#!/bin/bash | ||
|
||
# set -e | ||
|
||
OS=$(echo `uname -s`|tr '[:upper:]' '[:lower:]') | ||
|
||
case "$OS" in | ||
mingw*) OS='windows';; | ||
msys*) OS='windows';; | ||
esac | ||
|
||
VERSION="latest" | ||
INSTALL_DIR="$HOME/.dsm" | ||
FILE="" | ||
|
||
# TODO: Implement this | ||
show_help() { | ||
echo "dsm installation script" | ||
echo "" | ||
echo "USAGE:" | ||
echo " ./install.sh [OPTIONS]" | ||
echo "" | ||
echo "OPTIONS:" | ||
echo " -d, --install-dir Directory to install to." | ||
echo " -s, --skip-shell Skip shell setup" | ||
echo " -v, --version The version of dsm to install" | ||
echo " -F, --filename Manually override the filename of dsm to use." | ||
echo "" | ||
echo "For any queries, help or bug, please open an issue at https://github.com/Yakiyo/dsm/issues" | ||
|
||
exit 0 | ||
} | ||
|
||
clap() { | ||
while [[ $# -gt 0 ]]; do | ||
key="$1" | ||
|
||
case $key in | ||
-h | --help) | ||
show_help | ||
;; | ||
-d | --install-dir) | ||
INSTALL_DIR="$2" | ||
shift | ||
shift | ||
;; | ||
-s | --skip-shell) | ||
SKIP_SHELL="true" | ||
shift | ||
;; | ||
-v | --version) | ||
VERSION="v$2" | ||
shift | ||
shift | ||
;; | ||
-F | --filename) | ||
FILENAME="$2" | ||
shift | ||
shift | ||
;; | ||
*) | ||
echo "Unrecognized argument $key. Use the `--help` flag to see usage" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
# Duct taped this to somewhat work | ||
filename() { | ||
if [ "$OS" = "linux" ]; then | ||
case "$(uname -m)" in | ||
arm | armv7*) | ||
FILENAME="arm-unknown-linux-gnueabihf" | ||
;; | ||
*) | ||
FILENAME="x86_64-unknown-linux-musl" | ||
esac | ||
elif [ "$OS" = "darwin" ]; then | ||
FILENAME="x86_64-apple-darwin" | ||
elif [ "$OS" = "windows" ]; then | ||
FILENAME="x86_64-pc-windows-msvc.exe" | ||
else | ||
echo "OS $OS is not supported." | ||
echo "If you think that's a bug - please file an issue to https://github.com/Yakiyo/dsm/issues" | ||
exit 1 | ||
fi | ||
FILE="dsm-$FILENAME" | ||
} | ||
|
||
download () { | ||
if [ "$VERSION" = "latest" ]; then | ||
URL="https://github.com/Yakiyo/dsm/releases/latest/download/$FILE" | ||
else | ||
URL="https://github.com/Yakiyo/dsm/releases/download/$VERSION/$FILE" | ||
fi | ||
echo "Downloading from $URL ...." | ||
|
||
TMP=$(mktemp -d) | ||
mkdir -p "$INSTALL_DIR" &>/dev/null | ||
|
||
if ! curl --progress-bar --fail -L "$URL" -o "$TMP/$FILE"; then | ||
echo "Download failed. Check that the release/filename are correct." | ||
exit 1 | ||
fi | ||
|
||
EXE="" | ||
if [ "$OS" = "windows" ]; then | ||
EXE=".exe" | ||
fi | ||
|
||
mv "$TMP/$FILE" "$INSTALL_DIR/dsm$EXE" | ||
|
||
chmod u+x "$INSTALL_DIR/dsm$EXE" | ||
} | ||
|
||
ensure_dir () { | ||
local CONTAINING_DIR | ||
CONTAINING_DIR="$(dirname "$1")" | ||
if [ ! -d "$CONTAINING_DIR" ]; then | ||
echo " >> Creating directory $CONTAINING_DIR" | ||
mkdir -p "$CONTAINING_DIR" | ||
fi | ||
} | ||
|
||
# Courtesy of https://github.com/Schniz/fnm/blob/master/.ci/install.sh | ||
setup_shell() { | ||
CURRENT_SHELL="$(basename "$SHELL")" | ||
|
||
if [ "$CURRENT_SHELL" = "zsh" ]; then | ||
CONF_FILE=${ZDOTDIR:-$HOME}/.zshrc | ||
ensure_dir "$CONF_FILE" | ||
echo "Installing for Zsh. Appending the following to $CONF_FILE:" | ||
echo "" | ||
echo ' # dsm' | ||
echo ' export PATH="'"$INSTALL_DIR"':$PATH"' | ||
echo ' eval "`dsm env zsh`"' | ||
|
||
echo '' >>$CONF_FILE | ||
echo '# dsm' >>$CONF_FILE | ||
echo 'export PATH="'$INSTALL_DIR':$PATH"' >>$CONF_FILE | ||
echo 'eval "`dsm env zsh`"' >>$CONF_FILE | ||
|
||
elif [ "$CURRENT_SHELL" = "fish" ]; then | ||
CONF_FILE=$HOME/.config/fish/conf.d/dsm.fish | ||
ensure_dir "$CONF_FILE" | ||
echo "Installing for Fish. Appending the following to $CONF_FILE:" | ||
echo "" | ||
echo ' # dsm' | ||
echo ' set PATH "'"$INSTALL_DIR"'" $PATH' | ||
echo ' dsm env fish | source' | ||
|
||
echo '# dsm' >>$CONF_FILE | ||
echo 'set PATH "'"$INSTALL_DIR"'" $PATH' >>$CONF_FILE | ||
echo 'dsm env fish | source' >>$CONF_FILE | ||
|
||
elif [ "$CURRENT_SHELL" = "bash" ]; then | ||
if [ "$OS" = "darwin" ]; then | ||
CONF_FILE=$HOME/.profile | ||
else | ||
CONF_FILE=$HOME/.bashrc | ||
fi | ||
ensure_dir "$CONF_FILE" | ||
echo "Installing for Bash. Appending the following to $CONF_FILE:" | ||
echo "" | ||
echo ' # dsm' | ||
echo ' export PATH="'"$INSTALL_DIR"':$PATH"' | ||
echo ' eval "`dsm env bash`"' | ||
|
||
echo '' >>$CONF_FILE | ||
echo '# dsm' >>$CONF_FILE | ||
echo 'export PATH="'"$INSTALL_DIR"':$PATH"' >>$CONF_FILE | ||
echo 'eval "`dsm env bash`"' >>$CONF_FILE | ||
|
||
else | ||
echo "Could not infer shell type. Please set up manually." | ||
exit 1 | ||
fi | ||
|
||
echo "" | ||
echo "In order to apply the changes, open a new terminal or run the following command:" | ||
echo "" | ||
echo " source $CONF_FILE" | ||
} | ||
|
||
filename | ||
clap "$@" | ||
download | ||
if [ "$SKIP_SHELL" != "true" ]; then | ||
setup_shell | ||
fi |
Oops, something went wrong.