|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -# This is a workaround which is againt necessary on MacOS 14.0, it looks like this bug is back: |
4 | | -# https://github.com/microsoft/vscode-dev-containers/issues/1487#issuecomment-1143907307 |
5 | | - |
6 | | -# grant permissions to mounted rust volume |
7 | | -chown vscode:vscode /rust-volume |
8 | | - |
9 | | -# create /.cargo/config.toml in root folder |
10 | | -mkdir /.cargo/ |
11 | | -touch /.cargo/config.toml |
12 | | -cat <<EOF >/.cargo/config.toml |
13 | | -[build] |
14 | | -target-dir = "/rust-volume/target" |
15 | | -EOF |
| 3 | +#region sudo stuff |
| 4 | + |
| 5 | +HOST_OS="" |
| 6 | +ARCH_AND_OS_FUNC="${WORKSPACE_FOLDER}.devcontainer/scripts/functions/get-arch-and-os.sh" |
| 7 | +if [[ -f "$ARCH_AND_OS_FUNC" ]]; then |
| 8 | + source $ARCH_AND_OS_FUNC |
| 9 | + read -r _ HOST_OS <<< "$(get_arch_and_os)" |
| 10 | +fi |
| 11 | +if [[ "$HOST_OS" == "darwin" ]]; then # darwin == Mac OS |
| 12 | + # This is a workaround which is againt necessary on MacOS 14.0, it looks like this bug is back: |
| 13 | + # https://github.com/microsoft/vscode-dev-containers/issues/1487#issuecomment-1143907307 |
| 14 | + # grant permissions to mounted rust volume |
| 15 | + echo "(Mac OS only) Granting permissions to mounted rust volume" |
| 16 | + sudo chown vscode:vscode /rust-volume |
| 17 | + |
| 18 | + # create /.cargo/config.toml in root folder |
| 19 | + sudo mkdir /.cargo/ |
| 20 | + sudo touch /.cargo/config.toml |
| 21 | + sudo bash -c "cat << EOF > /.cargo/config.toml |
| 22 | + [build] |
| 23 | + target-dir = \"/rust-volume/target\" |
| 24 | + EOF" |
| 25 | +fi |
| 26 | + |
| 27 | +#endregion |
| 28 | + |
| 29 | +for arg in "$@"; do |
| 30 | + if [[ "$arg" == --workspace-folder=* ]]; then |
| 31 | + WORKSPACE_FOLDER="${arg#--workspace-folder=}" |
| 32 | + fi |
| 33 | +done |
| 34 | +INSTALL_RUST_TOOLCHAIN_FUNC="${WORKSPACE_FOLDER}.devcontainer/scripts/functions/install-rust-toolchain.sh" |
| 35 | +if [[ -f "$INSTALL_RUST_TOOLCHAIN_FUNC" ]]; then |
| 36 | + source $INSTALL_RUST_TOOLCHAIN_FUNC |
| 37 | + install_rust_toolchain "$@" |
| 38 | +fi |
0 commit comments