From aaf3dcbda01e8c22da88184922465155441cd20a Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 22 Jul 2019 08:56:43 +0200 Subject: [PATCH 1/6] tools: installer: fix quoting of IDF_TOOLS_PATH IDF_TOOLS_PATH may contain spaces, so needs to be properly quoted. Closes https://github.com/espressif/esp-idf/issues/3807 --- tools/windows/tool_setup/idf_cmd_init.bat | 6 +++--- tools/windows/tool_setup/idf_setup.iss.inc | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/windows/tool_setup/idf_cmd_init.bat b/tools/windows/tool_setup/idf_cmd_init.bat index 853dcf4da..039266e7b 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_setup.iss.inc b/tools/windows/tool_setup/idf_setup.iss.inc index 30c626a8d..c1dd9e113 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( From 9c5284e7b580a757ad7ecc3ef814a269d5f58eb9 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 22 Jul 2019 08:57:21 +0200 Subject: [PATCH 2/6] tools: installer: verify that IDF_PATH doesn't contain spaces --- tools/windows/tool_setup/idf_download_page.iss.inc | 9 ++++++++- tools/windows/tool_setup/idf_page.iss.inc | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/windows/tool_setup/idf_download_page.iss.inc b/tools/windows/tool_setup/idf_download_page.iss.inc index 3636123e7..6f501c059 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 87cc5c5d0..e6baef9c8 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 From f38c1c18a871e3d587aac48da6f9d0c0ba79e0b7 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 23 Jul 2019 06:20:52 +0200 Subject: [PATCH 3/6] tools: install.bat: bail out if idf_tools.py call fails Makes installation errors easier to spot. --- install.bat | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/install.bat b/install.bat index fdb9771a4..784fd850c 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 From b70ac4deb7e6fa27aa2a930cd7db0963a29515f7 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 23 Jul 2019 06:55:30 +0200 Subject: [PATCH 4/6] tools: idf_tools.py: improve error message when no downloads found ...for the given platform. Previously would raise AssertionError. --- tools/idf_tools.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/idf_tools.py b/tools/idf_tools.py index 7cdd18236..b5cfb0803 100755 --- a/tools/idf_tools.py +++ b/tools/idf_tools.py @@ -441,6 +441,9 @@ class IDFTool(object): 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) From 1271008dd80a75dd564e425bc76f3e6684692830 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 23 Jul 2019 06:57:36 +0200 Subject: [PATCH 5/6] tools: tools.json: don't require ulp-binutils and openocd on x86 Linux Fixes https://esp32.com/viewtopic.php?f=13&t=11540 --- tools/tools.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/tools.json b/tools/tools.json index 5bbed7e8b..3204ec3ad 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" From 80ad09f230acae80a6a7b3dce4b89b0204ca472e Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 24 Jul 2019 06:44:30 +0200 Subject: [PATCH 6/6] tools: installer: allow changing installation path Installation path can now be changed in a subsequent install, without uninstalling and logging out. The default value of the installation path is set to IDF_TOOLS_PATH environment variable, if it was already set by the previous installation, or by the user. Closes https://github.com/espressif/esp-idf/issues/3806 --- tools/windows/tool_setup/idf_tool_setup.iss | 3 ++- tools/windows/tool_setup/main.iss.inc | 22 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/windows/tool_setup/idf_tool_setup.iss b/tools/windows/tool_setup/idf_tool_setup.iss index 7fd8b2f73..13869feae 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 857f44879..a023f14d6 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)