فهرست منبع

Merge branch 'bugfix/win_tools_installer_fixes' into 'master'

tools: Windows tools installer release v2.3

Closes IDFGH-2670 and IDFGH-1929

See merge request espressif/esp-idf!7550
Angus Gratton 6 سال پیش
والد
کامیت
80e03a2d2d

+ 1 - 1
docs/en/get-started/windows-setup.rst

@@ -28,7 +28,7 @@ ESP-IDF Tools Installer
 
 The easiest way to install ESP-IDF's prerequisites is to download the ESP-IDF Tools installer from this URL:
 
-https://dl.espressif.com/dl/esp-idf-tools-setup-2.2.exe
+https://dl.espressif.com/dl/esp-idf-tools-setup-2.3.exe
 
 The installer includes the cross-compilers, OpenOCD, cmake_ and Ninja_ build tool. The installer can also download and run installers for Python_ 3.7 and `Git For Windows`_ if they are not already installed on the computer.
 

+ 1 - 1
docs/zh_CN/get-started/windows-setup.rst

@@ -28,7 +28,7 @@ ESP-IDF 工具安装器
 
 要安装 ESP-IDF 必备工具,最简易的方式是下载 ESP-IDF 工具安装器,地址如下:
 
-https://dl.espressif.com/dl/esp-idf-tools-setup-2.2.exe
+https://dl.espressif.com/dl/esp-idf-tools-setup-2.3.exe
 
 本安装器可为您安装所需的交叉编译器、OpenOCD、cmake_ 和 Ninja_ 编译工具,以及一款 mconf-idf_ 配置工具。此外,本安装器还可在有需要时下载、运行 Python_ 3.7 和 `Git For Windows` 的安装器。
 

+ 42 - 21
tools/windows/tool_setup/idf_setup.iss.inc

@@ -87,7 +87,7 @@ begin
   CmdLine := GitExecutablePath + ' -C ' + Path + ' submodule foreach git repack -d -a'
   DoCmdlineInstall('Finishing ESP-IDF installation', 'Re-packing the submodules', CmdLine);
 
-  FindFileRecusive(Path + '\.git', 'alternates', @RemoveAlternatesFile);
+  FindFileRecursive(Path + '\.git', 'alternates', @RemoveAlternatesFile);
 end;
 
 { Run git reset --hard in the repo and in the submodules, to fix the newlines. }
@@ -122,7 +122,6 @@ var
   IDFTempPath: String;
   IDFPath: String;
   NeedToClone: Boolean;
-  Res: Boolean;
 
 begin
   IDFPath := IDFDownloadPath;
@@ -168,7 +167,7 @@ begin
       GitRepoDissociate(IDFPath);
 
   end else begin
-    Log('Moving ' + IDFTempPath + ' to ' + IDFPath);
+    Log('Copying ' + IDFTempPath + ' to ' + IDFPath);
     if DirExists(IDFPath) then
     begin
       if not DirIsEmpty(IDFPath) then
@@ -176,47 +175,69 @@ begin
         MsgBox('Destination directory exists and is not empty: ' + IDFPath, mbError, MB_OK);
         RaiseException('Failed to copy ESP-IDF')
       end;
-
-      Res := RemoveDir(IDFPath);
-      if not Res then
-      begin
-        MsgBox('Failed to remove destination directory: ' + IDFPath, mbError, MB_OK);
-        RaiseException('Failed to copy ESP-IDF')
-      end;
-    end;
-    Res := RenameFile(IDFTempPath, IDFPath);
-    if not Res then
-    begin
-      MsgBox('Failed to copy ESP-IDF to the destination directory: ' + IDFPath, mbError, MB_OK);
-      RaiseException('Failed to copy ESP-IDF');
     end;
+    { If cmd.exe command argument starts with a quote, the first and last quote chars in the command
+      will be removed by cmd.exe.
+      Keys explanation: /s+/e includes all subdirectories, /i assumes that destination is a directory,
+      /h copies hidden files, /q disables file name logging (making copying faster!)
+    }
+    CmdLine := ExpandConstant('cmd.exe /c ""xcopy" /s /e /i /h /q "' + IDFTempPath + '" "' + IDFPath + '""');
+    DoCmdlineInstall('Extracting ESP-IDF', 'Copying ESP-IDF into the destination directory', CmdLine);
     GitRepoFixNewlines(IDFPath);
+    DelTree(IDFTempPath, True, True, True);
   end;
 end;
 
 { ------------------------------ IDF Tools setup, Python environment setup ------------------------------ }
 
+function UseBundledIDFToolsPy(Version: String) : Boolean;
+begin
+  Result := False;
+  { Use bundled copy of idf_tools.py, as the copy shipped with these IDF versions can not work due to 
+    the --no-site-packages bug.
+  }
+  if (Version = 'v4.0') or (Version = 'v3.3.1') then
+  begin
+    Log('UseBundledIDFToolsPy: version=' + Version + ', using bundled idf_tools.py');
+    Result := True;
+  end;
+end;
+
 procedure IDFToolsSetup();
 var
   CmdLine: String;
   IDFPath: String;
   IDFToolsPyPath: String;
   IDFToolsPyCmd: String;
+  BundledIDFToolsPyPath: String;
+  JSONArg: String;
 begin
   IDFPath := GetIDFPath('');
   IDFToolsPyPath := IDFPath + '\tools\idf_tools.py';
+  BundledIDFToolsPyPath := ExpandConstant('{app}\idf_tools_fallback.py');
+  JSONArg := '';
+
   if FileExists(IDFToolsPyPath) then
   begin
     Log('idf_tools.py exists in IDF directory');
-    IDFToolsPyCmd := PythonExecutablePath + ' ' + IDFToolsPyPath;
+    if UseBundledIDFToolsPy(IDFDownloadVersion) then
+    begin
+      Log('Using the bundled idf_tools.py copy');
+      IDFToolsPyCmd := BundledIDFToolsPyPath;
+    end else begin
+      IDFToolsPyCmd := IDFToolsPyPath;
+    end;
   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"'
-                                    + ' --idf-path ' + IDFPath
-                                    + ' --tools "{app}\tools_fallback.json"');
+    IDFToolsPyCmd := BundledIDFToolsPyPath;
+    JSONArg := ExpandConstant('--tools "{app}\tools_fallback.json"');
   end;
 
+  { IDFPath not quoted, as it can not contain spaces }
+  IDFToolsPyCmd := PythonExecutablePath + ' "' + IDFToolsPyCmd + '" --idf-path ' + IDFPath + JSONArg;
+
+  SetEnvironmentVariable('PYTHONUNBUFFERED', '1')
+
   Log('idf_tools.py command: ' + IDFToolsPyCmd);
   CmdLine := IDFToolsPyCmd + ' install';
   Log('Installing tools:' + CmdLine);

+ 1 - 1
tools/windows/tool_setup/idf_tool_setup.iss

@@ -5,7 +5,7 @@
 #include <idp.iss>
 
 #define MyAppName "ESP-IDF Tools"
-#define MyAppVersion "2.2"
+#define MyAppVersion "2.3"
 #define MyAppPublisher "Espressif Systems (Shanghai) Co. Ltd."
 #define MyAppURL "https://github.com/espressif/esp-idf"
 

+ 2 - 2
tools/windows/tool_setup/utils.iss.inc

@@ -92,7 +92,7 @@ end;
 type
     TFindFileCallback = procedure(Filename: String);
 
-procedure FindFileRecusive(Directory: string; FileName: string; Callback: TFindFileCallback);
+procedure FindFileRecursive(Directory: string; FileName: string; Callback: TFindFileCallback);
 var
   FindRec: TFindRec;
   FilePath: string;
@@ -107,7 +107,7 @@ begin
         FilePath := Directory + '\' + FindRec.Name;
         if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then
         begin
-          FindFileRecusive(FilePath, FileName, Callback);
+          FindFileRecursive(FilePath, FileName, Callback);
         end else if CompareText(FindRec.Name, FileName) = 0 then
         begin
           Callback(FilePath);