diff --git a/install.bat b/install.bat index fdb9771a469..784fd850cd0 100644 --- a/install.bat +++ b/install.bat @@ -10,10 +10,13 @@ set IDF_PATH=%IDF_PATH:~0,-1% echo Installing ESP-IDF tools python.exe %IDF_PATH%\tools\idf_tools.py install +if %errorlevel% neq 0 goto :end echo Setting up Python environment python.exe %IDF_PATH%\tools\idf_tools.py install-python-env +if %errorlevel% neq 0 goto :end echo All done! You can now run: echo export.bat -:: Clean up + +:end diff --git a/tools/idf_tools.py b/tools/idf_tools.py index 7cdd1823663..b5cfb08038e 100755 --- a/tools/idf_tools.py +++ b/tools/idf_tools.py @@ -441,6 +441,9 @@ def check_version(self, extra_paths=None): def get_install_type(self): return self._current_options.install + def compatible_with_platform(self): + return any([v.compatible_with_platform() for v in self.versions.values()]) + def get_recommended_version(self): recommended_versions = [k for k, v in self.versions.items() if v.status == IDFToolVersion.STATUS_RECOMMENDED @@ -1030,6 +1033,9 @@ def action_install(args): fatal('unknown tool name: {}'.format(tool_name)) raise SystemExit(1) tool_obj = tools_info[tool_name] + if not tool_obj.compatible_with_platform(): + fatal('tool {} does not have versions compatible with platform {}'.format(tool_name, CURRENT_PLATFORM)) + raise SystemExit(1) if tool_version is not None and tool_version not in tool_obj.versions: fatal('unknown version for tool {}: {}'.format(tool_name, tool_version)) raise SystemExit(1) diff --git a/tools/tools.json b/tools/tools.json index 5bbed7e8b70..3204ec3ad9f 100644 --- a/tools/tools.json +++ b/tools/tools.json @@ -69,6 +69,15 @@ "install": "always", "license": "GPL-2.0-or-later", "name": "esp32ulp-elf", + "platform_overrides": [ + { + "install": "on_request", + "platforms": [ + "linux-armel", + "linux-i686" + ] + } + ], "version_cmd": [ "esp32ulp-elf-as", "--version" @@ -182,6 +191,15 @@ "install": "always", "license": "GPL-2.0-only", "name": "openocd-esp32", + "platform_overrides": [ + { + "install": "on_request", + "platforms": [ + "linux-armel", + "linux-i686" + ] + } + ], "version_cmd": [ "openocd", "--version" diff --git a/tools/windows/tool_setup/idf_cmd_init.bat b/tools/windows/tool_setup/idf_cmd_init.bat index 853dcf4da7f..039266e7b93 100644 --- a/tools/windows/tool_setup/idf_cmd_init.bat +++ b/tools/windows/tool_setup/idf_cmd_init.bat @@ -18,8 +18,8 @@ if "%~2"=="" ( goto :end ) -set IDF_PYTHON_DIR=%1 -set IDF_GIT_DIR=%2 +set "IDF_PYTHON_DIR=%1" +set "IDF_GIT_DIR=%2" :: Strip quoutes set "IDF_PYTHON_DIR=%IDF_PYTHON_DIR:"=%" @@ -69,7 +69,7 @@ echo Adding ESP-IDF tools to PATH... :: It is possible to do this without a temporary file (running idf_tools.py from for /r command), :: but that way it is impossible to get the exit code of idf_tools.py. set "IDF_TOOLS_EXPORTS_FILE=%TEMP%\idf_export_vars.tmp" -python.exe %IDF_TOOLS_PY_PATH% --tools-json %IDF_TOOLS_JSON_PATH% export --format key-value >"%IDF_TOOLS_EXPORTS_FILE%" +python.exe "%IDF_TOOLS_PY_PATH%" --tools-json "%IDF_TOOLS_JSON_PATH%" export --format key-value >"%IDF_TOOLS_EXPORTS_FILE%" if %errorlevel% neq 0 goto :end for /f "usebackq tokens=1,2 eol=# delims==" %%a in ("%IDF_TOOLS_EXPORTS_FILE%") do ( diff --git a/tools/windows/tool_setup/idf_download_page.iss.inc b/tools/windows/tool_setup/idf_download_page.iss.inc index 3636123e7e0..6f501c059f4 100644 --- a/tools/windows/tool_setup/idf_download_page.iss.inc +++ b/tools/windows/tool_setup/idf_download_page.iss.inc @@ -102,6 +102,7 @@ var Page: TInputOptionWizardPage; IDFPath: String; begin + Result := False; Page := TInputOptionWizardPage(Sender); Log('OnIDFDownloadPageValidate index=' + IntToStr(Page.SelectedValueIndex)); @@ -110,7 +111,13 @@ begin begin MsgBox('Directory already exists and is not empty:' + #13#10 + IDFPath + #13#10 + 'Please choose a different directory.', mbError, MB_OK); - Result := False; + exit; + end; + + if Pos(' ', IDFPath) <> 0 then + begin + MsgBox('ESP-IDF build system does not support spaces in paths.' + #13#10 + 'Please choose a different directory.', mbError, MB_OK); exit; end; diff --git a/tools/windows/tool_setup/idf_page.iss.inc b/tools/windows/tool_setup/idf_page.iss.inc index 87cc5c5d076..e6baef9c8f5 100644 --- a/tools/windows/tool_setup/idf_page.iss.inc +++ b/tools/windows/tool_setup/idf_page.iss.inc @@ -75,6 +75,13 @@ begin exit; end; + if Pos(' ', IDFPath) <> 0 then + begin + MsgBox('ESP-IDF build system does not support spaces in paths.' + #13#10 + 'Please choose a different directory.', mbError, MB_OK); + exit; + end; + IDFPyPath := IDFPath + '\tools\idf.py'; if not FileExists(IDFPyPath) then begin diff --git a/tools/windows/tool_setup/idf_setup.iss.inc b/tools/windows/tool_setup/idf_setup.iss.inc index 30c626a8dc3..c1dd9e11392 100644 --- a/tools/windows/tool_setup/idf_setup.iss.inc +++ b/tools/windows/tool_setup/idf_setup.iss.inc @@ -142,7 +142,7 @@ begin end; ExtractTemporaryFile('7za.exe') - CmdLine := ExpandConstant('{tmp}\7za.exe x -o' + ExpandConstant('{tmp}') + ' -r -aoa ' + IDFZIPFileName); + CmdLine := ExpandConstant('{tmp}\7za.exe x -o' + ExpandConstant('{tmp}') + ' -r -aoa "' + IDFZIPFileName + '"'); IDFTempPath := ExpandConstant('{tmp}\esp-idf-') + IDFZIPFileVersion; Log('Extracting ESP-IDF reference repository: ' + CmdLine); Log('Reference repository path: ' + IDFTempPath); @@ -212,9 +212,9 @@ begin end else begin Log('idf_tools.py does not exist in IDF directory, using a fallback version'); IDFToolsPyCmd := ExpandConstant(PythonExecutablePath - + ' {app}\idf_tools_fallback.py' + + ' "{app}\idf_tools_fallback.py"' + ' --idf-path ' + IDFPath - + ' --tools {app}\tools_fallback.json'); + + ' --tools "{app}\tools_fallback.json"'); end; Log('idf_tools.py command: ' + IDFToolsPyCmd); @@ -238,7 +238,9 @@ begin ForceDirectories(ExpandConstant('{group}')); Destination := ExpandConstant('{group}\{#IDFCmdExeShortcutFile}'); Description := '{#IDFCmdExeShortcutDescription}'; - Command := ExpandConstant('/k {app}\idf_cmd_init.bat "') + PythonPath + '" "' + GitPath + '"'; + { If cmd.exe command argument starts with a quote, the first and last quote chars in the command + will be removed by cmd.exe; each argument needs to be surrounded by quotes as well. } + Command := ExpandConstant('/k ""{app}\idf_cmd_init.bat" "') + PythonPath + '" "' + GitPath + '""'; Log('CreateShellLink Destination=' + Destination + ' Description=' + Description + ' Command=' + Command) try CreateShellLink( diff --git a/tools/windows/tool_setup/idf_tool_setup.iss b/tools/windows/tool_setup/idf_tool_setup.iss index 7fd8b2f735a..13869feaece 100644 --- a/tools/windows/tool_setup/idf_tool_setup.iss +++ b/tools/windows/tool_setup/idf_tool_setup.iss @@ -35,6 +35,7 @@ AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={%USERPROFILE}\.espressif +UsePreviousAppDir=no DirExistsWarning=no DefaultGroupName=ESP-IDF DisableProgramGroupPage=yes @@ -78,7 +79,7 @@ Filename: "{group}\{#IDFCmdExeShortcutFile}"; Flags: postinstall shellexec; Desc [Registry] Root: HKCU; Subkey: "Environment"; ValueType: string; ValueName: "IDF_TOOLS_PATH"; \ - ValueData: "{app}"; Flags: preservestringtype createvalueifdoesntexist; + ValueData: "{app}"; Flags: preservestringtype createvalueifdoesntexist uninsdeletevalue deletevalue; [Code] diff --git a/tools/windows/tool_setup/main.iss.inc b/tools/windows/tool_setup/main.iss.inc index 857f4487965..a023f14d6d1 100644 --- a/tools/windows/tool_setup/main.iss.inc +++ b/tools/windows/tool_setup/main.iss.inc @@ -17,6 +17,23 @@ begin idpDownloadAfter(wpReady); end; +{ If IDF_TOOLS_PATH is set in the environment, + set the default installation directory accordingly. + Note: here we read IDF_TOOLS_PATH using GetEnv rather than + by getting it from registry, in case the user has set + IDF_TOOLS_PATH as a system environment variable manually. } + +procedure UpdateInstallDir(); +var + EnvToolsPath: String; +begin + EnvToolsPath := GetEnv('IDF_TOOLS_PATH'); + if EnvToolsPath <> '' then + begin + WizardForm.DirEdit.Text := EnvToolsPath; + end; +end; + function PreInstallSteps(CurPageID: Integer): Boolean; var @@ -75,6 +92,11 @@ begin Log('Setting PATH for this process: ' + EnvPath); SetEnvironmentVariable('PATH', EnvPath); + { Set IDF_TOOLS_PATH variable, in case it was set to a different value in the environment. + The installer will set the variable to the new value in the registry, but we also need the + new value to be visible to this process. } + SetEnvironmentVariable('IDF_TOOLS_PATH', ExpandConstant('{app}')) + { Log and clear PYTHONPATH variable, as it might point to libraries of another Python version} PythonLibPath := GetEnv('PYTHONPATH') Log('PYTHONPATH=' + PythonLibPath)