github.com/mit-dci/lit@v0.0.0-20221102210550-8c3d3b49f2ce/build/env.sh (about)

     1  #!/bin/sh
     2  
     3  set -e
     4  
     5  if [ ! -f "build/env.sh" ]; then
     6      echo "$0 must be run from the root of the repository."
     7      exit 2
     8  fi
     9  
    10  # Create fake Go workspace if it doesn't exist yet.
    11  workspace="$PWD/build/_workspace"
    12  root="$PWD"
    13  homedir="$workspace/src/github.com/mit-dci"
    14  
    15  # Are we actually doing cleanup?
    16  if [ "$1" = "clean" ]; then
    17      rm -rf $workspace
    18      exit
    19  fi
    20  
    21  # Create the homedir
    22  if [ ! -L "$homedir/lit" ]; then
    23      mkdir -p $homedir
    24      back=$(pwd)
    25      cd $homedir
    26      ln -s ../../../../../. lit
    27      cd $back
    28  fi
    29  
    30  # Set up the environment to use the workspace.
    31  GOPATH="$workspace"
    32  export GOPATH
    33  
    34  # Run the command inside the workspace.
    35  cd "$homedir/lit"
    36  PWD="$homedir/lit"
    37  
    38  # Launch the arguments with the configured environment.
    39  if [ ! -z "$1" ]; then
    40  	exec "$@"
    41  fi