From dd396d4d7363c9b1098fccb62d28754970205b1f Mon Sep 17 00:00:00 2001 From: Jamon Terrell Date: Mon, 9 Dec 2024 13:00:56 -0600 Subject: [PATCH] added support for powershell on windows --- README.md | 3 +++ default/patches/environment.ps1 | 26 +++++++++++++++++++++++ default/rules/resources-min.py | 2 +- default/rules/resources.py | 4 ++-- default/scripts/system-resources-min.sh | 1 + default/scripts/system-resources-tabby.sh | 1 + scripts/package-windows.sh | 2 ++ 7 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 default/patches/environment.ps1 diff --git a/README.md b/README.md index 7a51d78..dd7ab92 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,9 @@ Windows from existing CMD prompt: \oss-cad-suite\environment.bat +from existing PowerShell prompt: +. \oss-cad-suite\environment.ps1 + to create new CMD prompt: \oss-cad-suite\start.bat ``` diff --git a/default/patches/environment.ps1 b/default/patches/environment.ps1 new file mode 100644 index 0000000..776cb23 --- /dev/null +++ b/default/patches/environment.ps1 @@ -0,0 +1,26 @@ +# Find root dir +if (-not $env:YOSYSHQ_ROOT) { + $env:YOSYSHQ_ROOT = Join-Path (Get-Item -Path $PSScriptRoot).FullName "\" +} + +# Set prompt +function Prompt { + "[___BRANDING___] PS " + $(Get-Location) + "> " +} + +# Set environment variables +$env:SSL_CERT_FILE = Join-Path $env:YOSYSHQ_ROOT "etc\cacert.pem" +$env:PATH = "$($env:YOSYSHQ_ROOT)bin;$($env:YOSYSHQ_ROOT)lib;$env:PATH" +$env:PYTHON_EXECUTABLE = Join-Path $env:YOSYSHQ_ROOT "lib\python3.exe" +$env:QT_PLUGIN_PATH = Join-Path $env:YOSYSHQ_ROOT "lib\qt5\plugins" +$env:QT_LOGGING_RULES = "*=false" +$env:GTK_EXE_PREFIX = $env:YOSYSHQ_ROOT +$env:GTK_DATA_PREFIX = $env:YOSYSHQ_ROOT +$env:GDK_PIXBUF_MODULEDIR = Join-Path $env:YOSYSHQ_ROOT "lib\gdk-pixbuf-2.0\2.10.0\loaders" +$env:GDK_PIXBUF_MODULE_FILE = Join-Path $env:YOSYSHQ_ROOT "lib\gdk-pixbuf-2.0\2.10.0\loaders.cache" + +# Update GDK pixbuf loaders cache +& "$env:YOSYSHQ_ROOT\lib\gdk-pixbuf-query-loaders.exe" --update-cache + +# Additional environment variable +$env:OPENFPGALOADER_SOJ_DIR = Join-Path $env:YOSYSHQ_ROOT "share\openFPGALoader" diff --git a/default/rules/resources-min.py b/default/rules/resources-min.py index b69507a..0497ee5 100644 --- a/default/rules/resources-min.py +++ b/default/rules/resources-min.py @@ -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.bat', 'environment.ps1', 'start.bat', 'cacert.pem', 'tabbyadm' ], tools = {}, ) diff --git a/default/rules/resources.py b/default/rules/resources.py index 0e4696b..59c3d76 100644 --- a/default/rules/resources.py +++ b/default/rules/resources.py @@ -3,13 +3,13 @@ Target( name = 'system-resources', sources = [ ], - patches = [ 'fonts.conf.template', 'win-launcher.c', 'environment', 'environment.fish', 'environment.bat', 'start.bat', 'cacert.pem', 'tabbyadm' ], + patches = [ 'fonts.conf.template', 'win-launcher.c', 'environment', 'environment.fish', 'environment.bat', 'environment.ps1', '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.bat', 'environment.ps1', 'start.bat', 'cacert.pem', 'tabbyadm' ], tools = {}, ) diff --git a/default/scripts/system-resources-min.sh b/default/scripts/system-resources-min.sh index ff74648..e5f3542 100644 --- a/default/scripts/system-resources-min.sh +++ b/default/scripts/system-resources-min.sh @@ -25,6 +25,7 @@ if [ ${ARCH_BASE} == 'windows' ]; then ${CC} -DGUI=0 -O -s -o ${OUTPUT_DIR}${INSTALL_PREFIX}/win-launcher.exe ${PATCHES_DIR}/win-launcher.c cp ${PATCHES_DIR}/environment.bat ${OUTPUT_DIR}${INSTALL_PREFIX}/. + cp ${PATCHES_DIR}/environment.ps1 ${OUTPUT_DIR}${INSTALL_PREFIX}/. cp ${PATCHES_DIR}/start.bat ${OUTPUT_DIR}${INSTALL_PREFIX}/. mkdir -p ${OUTPUT_DIR}${INSTALL_PREFIX}/etc diff --git a/default/scripts/system-resources-tabby.sh b/default/scripts/system-resources-tabby.sh index 57065e9..e520008 100644 --- a/default/scripts/system-resources-tabby.sh +++ b/default/scripts/system-resources-tabby.sh @@ -89,6 +89,7 @@ if [ ${ARCH_BASE} == 'windows' ]; then ${CC} -DGUI=0 -O -s -o ${OUTPUT_DIR}${INSTALL_PREFIX}/win-launcher.exe ${PATCHES_DIR}/win-launcher.c cp ${PATCHES_DIR}/environment.bat ${OUTPUT_DIR}${INSTALL_PREFIX}/. + cp ${PATCHES_DIR}/environment.ps1 ${OUTPUT_DIR}${INSTALL_PREFIX}/. cp ${PATCHES_DIR}/start.bat ${OUTPUT_DIR}${INSTALL_PREFIX}/. mkdir -p ${OUTPUT_DIR}${INSTALL_PREFIX}/etc diff --git a/scripts/package-windows.sh b/scripts/package-windows.sh index 7bb17c1..a0f1419 100644 --- a/scripts/package-windows.sh +++ b/scripts/package-windows.sh @@ -7,6 +7,8 @@ rm -rf ${OUTPUT_DIR}${INSTALL_PREFIX}/lib/yosys cp ${PATCHES_DIR}/${README} ${OUTPUT_DIR}${INSTALL_PREFIX}/README sed "s|___BRANDING___|${BRANDING}|g" -i ${OUTPUT_DIR}${INSTALL_PREFIX}/environment.bat +sed "s|___BRANDING___|${BRANDING}|g" -i ${OUTPUT_DIR}${INSTALL_PREFIX}/environment.ps1 + if [ -f "${OUTPUT_DIR}${INSTALL_PREFIX}/bin/tabbyadm" ]; then sed "s|___BRANDING___|${BRANDING}|g" -i ${OUTPUT_DIR}${INSTALL_PREFIX}/bin/tabbyadm fi