idf_page.iss.inc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. { Copyright 2019 Espressif Systems (Shanghai) PTE LTD
  2. SPDX-License-Identifier: Apache-2.0 }
  3. { ------------------------------ Page to select whether to download ESP-IDF, or use an existing copy ------------------------------ }
  4. var
  5. IDFPage: TInputOptionWizardPage;
  6. IDFSelectionDownloadIndex: Integer;
  7. IDFSelectionCustomPathIndex: Integer;
  8. IDFUseExisting: Boolean;
  9. IDFExistingPath: String;
  10. function IDFDownloadRequired(): Boolean;
  11. begin
  12. Result := not IDFUseExisting;
  13. end;
  14. procedure IDFPageUpdateInput();
  15. var
  16. Enable: Boolean;
  17. begin
  18. if IDFPage.SelectedValueIndex = IDFSelectionCustomPathIndex then
  19. Enable := True;
  20. ChoicePageSetInputEnabled(IDFPage, Enable);
  21. end;
  22. procedure OnIDFPagePrepare(Sender: TObject);
  23. var
  24. Page: TInputOptionWizardPage;
  25. begin
  26. Page := TInputOptionWizardPage(Sender);
  27. Log('OnIDFPagePrepare');
  28. if Page.CheckListBox.Items.Count > 0 then
  29. exit;
  30. IDFSelectionDownloadIndex := Page.Add('Download ESP-IDF')
  31. IDFSelectionCustomPathIndex := Page.Add('Use an existing ESP-IDF directory');
  32. Page.SelectedValueIndex := 0;
  33. IDFPageUpdateInput();
  34. end;
  35. procedure OnIDFSelectionChange(Sender: TObject);
  36. var
  37. Page: TInputOptionWizardPage;
  38. begin
  39. Page := TInputOptionWizardPage(Sender);
  40. Log('OnIDFSelectionChange index=' + IntToStr(Page.SelectedValueIndex));
  41. IDFPageUpdateInput();
  42. end;
  43. function OnIDFPageValidate(Sender: TWizardPage): Boolean;
  44. var
  45. Page: TInputOptionWizardPage;
  46. NotSupportedMsg, IDFPath, IDFPyPath, RequirementsPath: String;
  47. begin
  48. Page := TInputOptionWizardPage(Sender);
  49. Log('OnIDFPageValidate index=' + IntToStr(Page.SelectedValueIndex));
  50. if Page.SelectedValueIndex = IDFSelectionDownloadIndex then
  51. begin
  52. IDFUseExisting := False;
  53. Result := True;
  54. end else begin
  55. IDFUseExisting := True;
  56. Result := False;
  57. NotSupportedMsg := 'The selected version of ESP-IDF is not supported:' + #13#10;
  58. IDFPath := ChoicePageGetInputText(Page);
  59. if not DirExists(IDFPath) then
  60. begin
  61. MsgBox('Directory doesn''t exist: ' + IDFPath + #13#10 +
  62. 'Please choose an existing ESP-IDF directory', mbError, MB_OK);
  63. exit;
  64. end;
  65. if Pos(' ', IDFPath) <> 0 then
  66. begin
  67. MsgBox('ESP-IDF build system does not support spaces in paths.' + #13#10
  68. 'Please choose a different directory.', mbError, MB_OK);
  69. exit;
  70. end;
  71. IDFPyPath := IDFPath + '\tools\idf.py';
  72. if not FileExists(IDFPyPath) then
  73. begin
  74. MsgBox(NotSupportedMsg +
  75. 'Can not find idf.py in ' + IDFPath + '\tools', mbError, MB_OK);
  76. exit;
  77. end;
  78. RequirementsPath := IDFPath + '\requirements.txt';
  79. if not FileExists(RequirementsPath) then
  80. begin
  81. MsgBox(NotSupportedMsg +
  82. 'Can not find requirements.txt in ' + IDFPath, mbError, MB_OK);
  83. exit;
  84. end;
  85. IDFExistingPath := IDFPath;
  86. Result := True;
  87. end;
  88. end;
  89. <event('InitializeWizard')>
  90. procedure CreateIDFPage();
  91. begin
  92. IDFPage := ChoicePageCreate(
  93. wpLicense,
  94. 'Download or use ESP-IDF', 'Please choose ESP-IDF version to download, or use an existing ESP-IDF copy',
  95. 'Available ESP-IDF versions',
  96. 'Choose existing ESP-IDF directory',
  97. True,
  98. @OnIDFPagePrepare,
  99. @OnIDFSelectionChange,
  100. @OnIDFPageValidate);
  101. end;