Skip to content

Commit

Permalink
Merge pull request #30 from derickson2402/dev
Browse files Browse the repository at this point in the history
Add global/workspace configuration
  • Loading branch information
derickson2402 authored Mar 30, 2022
2 parents 8e30e57 + 7bb49c9 commit 14cee1d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ caen [program] [args]
This will run your command in an environment identical to CAEN Linux. For example, if you are working on a C++ project for EECS 281, you could use:

```bash
caen make clean
caen make my_program.cpp < input.txt
caen valgrind my_program.cpp
caen perf record my_program.cpp
caen make my_program.cpp
caen my_program < input.txt
caen valgrind my_program
caen perf record my_program
caen go build my_other_program.go
caen ./my_other_program
caen ./my_other_program < input.txt | caen my_program
```

## Installation
Expand All @@ -43,21 +43,21 @@ You can run ```caen bash``` to start a new bash shell in the container! This can

Executables generated with this container are compiled for CAEN servers and won't work on your host system. You should run your ```make clean``` script before switching back and forth, and then run ```make``` from the environment you want to use.

There are a few environment variables that you can use to change the behavior of the container. You can either use ```export VARIABLE=value``` to make the settings stick around until you close your shell, or you can use ```VARIABLE=value caen ...``` to just use it once. The currently supported variables are given below:
There are a few environment variables that you can use to change the behavior of the container. To permanently set an option, add it to a file in your home directory ```~/.caen.conf```. To set an option just for the current workspace, you can set them in the file ```$(pwd)/.caen.conf```. You can also use ```export VARIABLE=value``` to make the settings stick around just until you close your shell, or you can use ```VARIABLE=value caen ...``` to just use it once. The currently supported variables are given below:

Variable Name | Default Value | Description
--------------|---------------|------------
CAEN_VERSION | latest | Container tag to use, either of the form ```v0.5```, or a branch name like ```dev``` or ```feature-example```
CAEN_ARGS | -- | Optional arguments to pass to the ```docker run``` command. Be careful with these, they will likely collide with existing options
CAEN_USER | your-uid:your-gid | Defaults to your current ```UID:GID```. You can specify just ```UID``` or both, just need to use the number

For example, temporarily run a command as a different user:
For example, your workspace configuration might look like this because you need to run as a different user:

```bash
CAEN_USER=65535 caen my-program
```env
CAEN_USER=65535
```

Or use a different version until you close your shell:
Or maybe you want to use a different container version until you close your shell:

```bash
export CAEN_VERSION=dev
Expand Down
15 changes: 13 additions & 2 deletions caen
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ CAEN_SCRIPT_VER=v0.6.1

# Shell settings to improve safety
set -fu -o pipefail
CAEN_ARGS=${CAEN_ARGS:=" "}

# Source any global or workspace configuration options. This must happen first
# so users can't break private vars. If HOME is unset program will crash. But
# HOME var is part of POSIX compatability, so not our problem
if [ -f "${HOME}/.caen.conf" ]; then
source "${HOME}/.caen.conf"
fi
if [ -f "$(pwd)/.caen.conf" ]; then
source "$(pwd)/.caen.conf"
fi

# Define our help message, docker flags, and env vars
CAEN_ARGS=${CAEN_ARGS:=" "}
CAEN_REPO_NAME=${CAEN_REPO_NAME:=ghcr.io/derickson2402/dockerized-caen}
CAEN_URL='https://github.com/derickson2402/Dockerized-CAEN'
CAEN_VERSION=${CAEN_VERSION:=latest}
Expand Down Expand Up @@ -45,7 +55,8 @@ on GitHub for help:
EOF
)
# Make sure a tmp file existst for us to store the last update check date in

# Make sure a tmp file exists for us to store the last update check date in
[[ -f /tmp/caen-last-update-check ]] || touch /tmp/caen-last-update-check
CAEN_SCRIPT_LAST_UPDATE=$(cat /tmp/caen-last-update-check)

Expand Down

0 comments on commit 14cee1d

Please sign in to comment.