337337procedure IDFDownloadInstall ();
338338var
339339 CmdLine: String;
340+ IDFTempPath: String;
340341 IDFPath: String;
341342 NeedToClone: Boolean;
342343begin
@@ -356,8 +357,10 @@ begin
356357 NeedToClone := True;
357358 end ;
358359
359- CmdLine := ExpandConstant(' "{tmp}\7za.exe" x "-o' + IDFPath + ' " -r -aoa "' + IDFZIPFileName + ' "' );
360+ CmdLine := ExpandConstant(' "{tmp}\7za.exe" x "-o' + ExpandConstant(' {tmp}' ) + ' " -r -aoa "' + IDFZIPFileName + ' "' );
361+ IDFTempPath := ExpandConstant(' {tmp}\esp-idf-' ) + IDFZIPFileVersion;
360362 Log(' Extracting ESP-IDF reference repository: ' + CmdLine);
363+ Log(' Reference repository path: ' + IDFTempPath);
361364 DoCmdlineInstall(CustomMessage(' ExtractingEspIdf' ), CustomMessage(' SettingUpReferenceRepository' ), CmdLine);
362365 end else begin
363366 { IDFZIPFileName is not set, meaning that we will rely on 'git clone'. }
@@ -385,19 +388,45 @@ begin
385388 CmdLine := CmdLine + ' --recursive ' ;
386389 end ;
387390
391+ if IDFTempPath <> ' ' then
392+ CmdLine := CmdLine + ' --reference ' + IDFTempPath;
393+
388394 CmdLine := CmdLine + ' ' + GitRepository +' "' + IDFPath + ' "' ;
389395 Log(' Cloning IDF: ' + CmdLine);
390396 DoCmdlineInstall(CustomMessage(' DownloadingEspIdf' ), CustomMessage(' UsingGitToClone' ), CmdLine);
391397
398+ if IDFTempPath <> ' ' then
399+ GitRepoDissociate(IDFPath);
400+
392401 if (GitUseMirror) then begin
393402 ApplyIdfMirror(IDFPath, GitRepository, GitSubmoduleUrl);
394403 end ;
395404
396405 end else begin
397406
407+ Log(' Copying ' + IDFTempPath + ' to ' + IDFPath);
408+ if DirExists(IDFPath) then
409+ begin
410+ if not DirIsEmpty(IDFPath) then
411+ begin
412+ MessageBox(' Destination directory exists and is not empty: ' + IDFPath, mbError, MB_OK);
413+ RaiseException(' Failed to copy ESP-IDF' )
414+ end ;
415+ end ;
416+
417+ { If cmd.exe command argument starts with a quote, the first and last quote chars in the command
418+ will be removed by cmd.exe.
419+ Keys explanation: /s+/e includes all subdirectories, /i assumes that destination is a directory,
420+ /h copies hidden files, /q disables file name logging (making copying faster!)
421+ }
422+
423+ CmdLine := ExpandConstant(' cmd.exe /c ""xcopy.exe" /s /e /i /h /q "' + IDFTempPath + ' " "' + IDFPath + ' ""' );
424+ DoCmdlineInstall(CustomMessage(' ExtractingEspIdf' ), CustomMessage(' CopyingEspIdf' ), CmdLine);
425+
398426 GitRepoFixFileMode(IDFPath);
399427 GitResetHard(IDFPath);
400428
429+ DelTree(IDFTempPath, True, True, True);
401430 end ;
402431end ;
403432
@@ -543,11 +572,10 @@ begin
543572 Log(' Installing Python environment:' + CmdLine);
544573 DoCmdlineInstall(CustomMessage(' InstallingPythonVirtualEnv' ), ' ' , CmdLine);
545574
546- { Install addiional wheels which are not covered by default tooling }
575+ { Install addional wheels which are not covered by default tooling }
547576 PipExecutable := GetPythonVirtualEnvPipExecutable()
548577 CmdLine := PipExecutable + ' install windows-curses' ;
549578 Log(' Installing additional wheels:' + CmdLine);
550579 DoCmdlineInstall(CustomMessage(' InstallingPythonVirtualEnv' ), ' ' , CmdLine);
551580
552581end ;
553-
0 commit comments