Skip to content

Commit

Permalink
Add environment file for fish shell support
Browse files Browse the repository at this point in the history
fixes #104
  • Loading branch information
ymherklotz committed May 15, 2024
1 parent 2818ae7 commit 7d6d2c1
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ export PATH="<extracted_location>/oss-cad-suite/bin:$PATH"
source <extracted_location>/oss-cad-suite/environment
```

Linux and macOS (fish shell)
```bash
fish_add_path "<extracted_location>/oss-cad-suite/bin"

# or

source <extracted_location>/oss-cad-suite/environment.fish
```

Windows
```batch
from existing CMD prompt:
Expand Down
7 changes: 7 additions & 0 deletions default/patches/README
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Linux and macOS
---------------
export PATH="<extracted_location>/oss-cad-suite/bin:$PATH"

with fish shell:
fish_add_path "<extracted_location>/oss-cad-suite/bin"

Windows
-------
from existing shell:
Expand All @@ -32,3 +35,7 @@ If you want to use the bundled version of Python, for example with nmigen, nextp
We also provide a virtual environment that you can setup like this:

source <extracted_location>/oss-cad-suite/environment

or with fish shell:

source <extracted_location>/oss-cad-suite/environment.fish
60 changes: 60 additions & 0 deletions default/patches/environment.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env fish

function deactivate -d "Deactivate the ___BRANDING___ virtual environment"

if set --query _OLD_ENVIRONMENT_PATH
set --export PATH $_OLD_ENVIRONMENT_PATH
set --erase _OLD_ENVIRONMENT_PATH
end

if set --query _OLD_ENVIRONMENT_PYTHONHOME
set --export PYTHONHOME $_OLD_ENVIRONMENT_PYTHONHOME
set --erase _OLD_ENVIRONMENT_PYTHONHOME
end

set --erase VIRTUAL_ENV
set --erase VERILATOR_ROOT
set --erase GHDL_PREFIX

if functions --query _old_environment_fish_prompt
functions --erase fish_prompt
functions --copy _old_environment_fish_prompt fish_prompt
functions --erase _old_environment_fish_prompt
end

if test (count $argv) -eq 0; or test $argv[1] != "nondestructive"
functions --erase deactivate
end

end

deactivate nondestructive

set --local release_current_dir (dirname (status -f))

if test (uname) = "Darwin"
set --global release_topdir_abs ($release_current_dir/libexec/realpath $release_current_dir)
else
set --global release_topdir_abs (realpath $release_current_dir)
end

set --export VIRTUAL_ENV '___BRANDING___'

set --global _OLD_ENVIRONMENT_PATH "$PATH"
set --export PATH "$release_topdir_abs/bin:$release_topdir_abs/py3bin:$PATH"

if set --query PYTHONHOME
set --export _OLD_ENVIRONMENT_PYTHONHOME "$PYTHONHOME"
set --erase PYTHONHOME
end

functions --copy fish_prompt _old_environment_fish_prompt
function fish_prompt -d "Write out the prompt"
set_color magenta
echo -n -s '(' $VIRTUAL_ENV ') '
set_color normal
_old_environment_fish_prompt
end

set --export VERILATOR_ROOT "$release_topdir_abs/share/verilator"
set --export GHDL_PREFIX "$release_topdir_abs/lib/ghdl"
2 changes: 1 addition & 1 deletion default/rules/resources-min.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
Target(
name = 'system-resources-min',
sources = [ ],
patches = [ 'fonts.conf.template', 'win-launcher.c', 'environment', 'environment.bat', 'start.bat', 'cacert.pem', 'tabbyadm' ],
patches = [ 'fonts.conf.template', 'win-launcher.c', 'environment', 'environment.fish', 'environment.bat', 'start.bat', 'cacert.pem', 'tabbyadm' ],
tools = {},
)
4 changes: 2 additions & 2 deletions default/rules/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Target(
name = 'system-resources',
sources = [ ],
patches = [ 'fonts.conf.template', 'win-launcher.c', 'environment', 'environment.bat', 'start.bat', 'cacert.pem', 'tabbyadm' ],
patches = [ 'fonts.conf.template', 'win-launcher.c', 'environment', 'environment.fish', 'environment.bat', 'start.bat', 'cacert.pem', 'tabbyadm' ],
tools = {},
)

Target(
name = 'system-resources-tabby',
sources = [ ],
patches = [ 'fonts.conf.template', 'win-launcher.c', 'environment', 'environment.bat', 'start.bat', 'cacert.pem', 'tabbyadm' ],
patches = [ 'fonts.conf.template', 'win-launcher.c', 'environment', 'environment.fish', 'environment.bat', 'start.bat', 'cacert.pem', 'tabbyadm' ],
tools = {},
)
3 changes: 3 additions & 0 deletions scripts/package-darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ cp /opt/local/bin/realpath libexec/.

cp ${PATCHES_DIR}/${README} ${OUTPUT_DIR}${INSTALL_PREFIX}/README
sed "s|___BRANDING___|${BRANDING}|g" -i ${OUTPUT_DIR}${INSTALL_PREFIX}/environment
if [ -f "${OUTPUT_DIR}${INSTALL_PREFIX}/environment.fish" ]; then
sed "s|___BRANDING___|${BRANDING}|g" -i ${OUTPUT_DIR}${INSTALL_PREFIX}/environment.fish
fi
if [ -f "${OUTPUT_DIR}${INSTALL_PREFIX}/bin/tabbyadm" ]; then
sed "s|___BRANDING___|${BRANDING}|g" -i ${OUTPUT_DIR}${INSTALL_PREFIX}/bin/tabbyadm
fi
Expand Down
3 changes: 3 additions & 0 deletions scripts/package-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ fi

cp ${PATCHES_DIR}/${README} ${OUTPUT_DIR}${INSTALL_PREFIX}/README
sed "s|___BRANDING___|${BRANDING}|g" -i ${OUTPUT_DIR}${INSTALL_PREFIX}/environment
if [ -f "${OUTPUT_DIR}${INSTALL_PREFIX}/environment.fish" ]; then
sed "s|___BRANDING___|${BRANDING}|g" -i ${OUTPUT_DIR}${INSTALL_PREFIX}/environment.fish
fi
if [ -f "${OUTPUT_DIR}${INSTALL_PREFIX}/bin/tabbyadm" ]; then
sed "s|___BRANDING___|${BRANDING}|g" -i ${OUTPUT_DIR}${INSTALL_PREFIX}/bin/tabbyadm
fi
Expand Down

0 comments on commit 7d6d2c1

Please sign in to comment.