Skip to content

Launcher for Windows #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions launch_with_pydiscovery.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@if not defined _echo echo off
rem save path of the launcher script
set "lscp-path=%cd%"

rem https://stackoverflow.com/questions/22352793/reading-a-registry-value-to-a-batch-variable-handling-spaces-in-value
rem Find Regkey of Raspberry Pi Pico SDK
for /f "usebackq tokens=1,*" %%h in (
`"reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /f "Raspberry Pi Pico SDK" 2>NUL | find /i "Raspberry Pi Pico SDK""`
) do (
set "pico-sdk-regkey=%%h %%i"
)

rem Find path to Raspberry Pi Pico SDK
for /f "usebackq tokens=2,*" %%h in (
`"reg query "%pico-sdk-regkey%" /v "InstallPath" 2>NUL"`
) do (
set "pico-env-for-projGen-path=%%i"
)

rem Delete no longer required variable
set pico-sdk-regkey=

rem change directory to prepare the environment by launching the existing script pico-env
cd /D "%pico-env-for-projGen-path%"
rem Delete no longer required variable
set "pico-env-for-projGen-path="
call pico-env.cmd

rem change directory back to launcher script
cd /D %lscp-path%

rem Delete no longer required variable
set "lscp-path="

REM https://blog.finxter.com/how-to-find-path-where-python-is-installed-on-windows/
for /f "usebackq tokens=2,*" %%h in (
`py.exe -c "import os, sys; print('Python Path ' + os.path.dirname(sys.executable))"`
) do (
set "ls-pypath=%%i"
)

call "%ls-pypath%\python" pico_project.py --gui
rem Delete no longer required variable
set ls-pypath=
12 changes: 9 additions & 3 deletions pico_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,9 +1362,15 @@ def DoEverything(parent, params):
makeCmd = 'mingw32-make '

else:
# Everything else assume nmake
cmakeCmd = 'cmake -DCMAKE_BUILD_TYPE=Debug -G "NMake Makefiles" ..'
makeCmd = 'nmake '
# Check if the environment variable CMAKE_GENERATOR specifies Ninja; If yes: Don´t specifiy special case to CMake
if os.environ.get('CMAKE_GENERATOR', 'not_found') == 'Ninja':
cmakeCmd = 'cmake -DCMAKE_BUILD_TYPE=Debug ..'
makeCmd = 'ninja '

else:
# Everything else assume nmake
cmakeCmd = 'cmake -DCMAKE_BUILD_TYPE=Debug -G "NMake Makefiles" ..'
makeCmd = 'nmake '
else:
cmakeCmd = 'cmake -DCMAKE_BUILD_TYPE=Debug ..'
makeCmd = 'make -j' + str(cpus)
Expand Down