Merge branch 'bugfix/tools_installer_fixes' into 'master'

tools: fixes for idf_tools.py and Windows tools installer

Closes IDFGH-1545 and IDFGH-1544

See merge request espressif/esp-idf!5595
This commit is contained in:
Ivan Grokhotkov 2019-07-25 12:20:28 +08:00
commit c19106876c
9 changed files with 76 additions and 10 deletions

View file

@ -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

View file

@ -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)

View file

@ -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"

View file

@ -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 (

View file

@ -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;

View file

@ -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

View file

@ -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(

View file

@ -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]

View file

@ -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. }
<event('InitializeWizard')>
procedure UpdateInstallDir();
var
EnvToolsPath: String;
begin
EnvToolsPath := GetEnv('IDF_TOOLS_PATH');
if EnvToolsPath <> '' then
begin
WizardForm.DirEdit.Text := EnvToolsPath;
end;
end;
<event('NextButtonClick')>
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)