esp-idf/tools/windows/tool_setup
2021-01-19 13:34:32 +01:00
..
cmdlinerunner Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00
Languages tools: add system check to verify Python versions and Windows Defender status 2020-12-07 14:44:56 +01:00
Scripts tools: support for embedded python 2021-01-18 08:10:56 +01:00
system_check tools: add system check to verify Python versions and Windows Defender status 2020-12-07 14:44:56 +01:00
.gitignore tools: new installer for Windows 2019-07-01 18:08:02 +02:00
build_installer.sh tools: fix: ubounded variable in win installer build script 2021-01-19 13:34:32 +01:00
choice_page.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
cmdline_page.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
docker-compose.yml tools: support for embedded python 2021-01-18 08:10:56 +01:00
git_find_installed.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
git_page.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
idf_cmd_init.bat tools: installer: fix quoting of IDF_TOOLS_PATH 2019-07-22 09:29:49 +02:00
idf_download_page.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
idf_page.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
idf_setup.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
idf_tool_setup.iss tools: support for embedded python 2021-01-18 08:10:56 +01:00
license.txt Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00
main.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
python_find_installed.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
python_page.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
README.md tools: support for embedded python 2021-01-18 08:10:56 +01:00
sign_installer.sh global: use '/usr/bin/env bash' instead of '/usr/bin/bash' in shebangs 2020-04-03 01:10:02 +02:00
summary.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
system_check_page.iss.inc tools: support for embedded python 2021-01-18 08:10:56 +01:00
tools_fallback.json tools: update idf_exe to 1.0.1 2019-07-09 14:15:09 +02:00
tools_WD_clean.ps1 Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00
tools_WD_excl.ps1 Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00
utils.iss.inc tools: add system check to verify Python versions and Windows Defender status 2020-12-07 14:44:56 +01:00

ESP-IDF Tools Installer for Windows

This directory contains source files required to build the tools installer for Windows.

The installer is built using Inno Setup. At the time of writing, the installer can be built with Inno Setup version 6.0.2.

The main source file of the installer is idf_tools_setup.iss. PascalScript code is split into multiple *.iss.inc files.

Some functionality of the installer depends on additional programs:

  • Inno Download Plugin — used to download additional files during the installation.

  • 7-zip — used to extract downloaded IDF archives.

  • cmdlinerunner — a helper DLL used to run external command-line programs from the installer, capture live console output, and get the exit code.

Installation of dependencies via Chocolatey

Run with Administrator privileges:

choco install inno-download-plugin

Building the installer

In Docker

This uses wine-innosetup Docker image and build_installer.sh script. This is how the installer is built in CI.

docker run --rm -v $IDF_PATH:/idf -w /idf/tools/windows/tool_setup -it $CI_DOCKER_REGISTRY/wine-innosetup:1 /bin/bash build_installer.sh

Manually, step by step

  • Build cmdlinerunner DLL.

    • On Linux/Mac, install mingw-w64 toolchain (i686-w64-mingw32-gcc). Then build the DLL using CMake:
      mkdir -p cmdlinerunner/build
      cd cmdlinerunner/build
      cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-i686-w64-mingw32.cmake -DCMAKE_BUILD_TYPE=Release ..
      cmake --build .
      
      This will produce cmdlinerunner.dll in the build directory.
    • On Windows, it is possible to build using Visual Studio, with CMake support installed. By default, VS produces build artifacts in some hard to find directory. You can adjust this in CmakeSettings.json file generated by VS.
  • Download 7zip.exe ("standalone console version") and put it into unzip directory (to get unzip/7za.exe).

  • Download idf_versions.txt and place it into the current directory. The installer will use it as a fallback, if it can not download idf_versions.txt at run time.

  • Create the dist directory and populate it with the tools which should be bundled with the installer. At the moment the easiest way to obtain it is to use install.sh/install.bat in IDF, and then copy the contents of $HOME/.espressif/dist directory. If the directory is empty, the installer should still work, and the tools will be downloaded during the installation.

  • Build the installer using Inno Setup Compiler: ISCC.exe idf_tools_setup.iss.

Signing the installer

  • Obtain the signing key (e.g key.pem) and the certificate chain (e.g. certchain.pem). Set the environment variables to point to these files:

    • export KEYFILE=key.pem
    • export CERTCHAIN=certchain.pem
  • Run sign_installer.sh script. This will ask for the key.pem password, and produce the signed installer in the Output directory. If you plan to run the script multiple times, you may also set KEYPASSWORD environment variable to the key.pem password, to avoid the prompt.

Development and testing of the installer

Development and testing of the installer can be simplified by using command line parameters which can be passed to the installer.

Select Run - Parameters in Inno Setup and add parameters.

Example of parameters:

/SKIPSYSTEMCHECK=yes /IDFVERSIONSURL=http://localhost:8000/idf_versions.txt /GITRESET=no /GITREPO=C:/projects/esp-idf /GITRECURSIVE=no

These combinations of parameters will result:

  • SKIPSYSTEMCHECK=yes - The screen with System Check will be skipped.
  • IDFVERSIONURL - idf_versions.txt will be downloaded from localhost:8000
    • it's possible to add branch name into idf_versions.txt, e.g. feature/win_inst
  • GITRESET=no - Git repository won't be reset after clone, it can save time and add custom changes in case of the zip archive with repository
  • GITREPO - The version will be cloned from the specific location, e.g. from a local directory
  • GITRECURSIVE=no - The clone of the repo won't contain modules, it speeds up the cloning process. Use when modules are not necessary.

Documentation of parameters is available in api-guides/tools/idf-windows-installer.rst

Testing installation in Docker with Windows containers

The testing script is stored in docker-compose.yml. The test perform full silent installation and executes build of get-started example.

Commands for testing multiple versions:

$env:IDF_VERSION="v4.1"; docker-compose.exe run idf-setup-test
$env:IDF_VERSION="v4.0.2"; docker-compose.exe run idf-setup-test
$env:IDF_VERSION="v3.3.4"; docker-compose.exe run idf-setup-test
$env:IDF_VERSION="release/v4.2"; docker-compose.exe run idf-setup-test
$env:IDF_VERSION="release/v4.1"; docker-compose.exe run idf-setup-test
$env:IDF_VERSION="release/v4.0"; docker-compose.exe run idf-setup-test
$env:IDF_VERSION="release/v3.3"; docker-compose.exe run idf-setup-test
$env:IDF_VERSION="master"; docker-compose.exe run idf-setup-test

The installation log is not displayed immediately on the screen. It's stored in the file and it's displayed when the installation finishes. The glitch of Inno Setup is that in case of failed installation it won't terminate and it keeps hanging.

Recommendation: Use Visual Studio Code with Docker plugin to work with container. The log file is then accessible under Docker - Containers - Container - Files - Temp - install.txt - right click - Open.