diff --git a/launch_with_pydiscovery.cmd b/launch_with_pydiscovery.cmd new file mode 100644 index 0000000..a27e87d --- /dev/null +++ b/launch_with_pydiscovery.cmd @@ -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= diff --git a/pico_project.py b/pico_project.py index b906af1..c57e7df 100755 --- a/pico_project.py +++ b/pico_project.py @@ -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)