Skip to content

Latest commit

 

History

History
146 lines (110 loc) · 9.24 KB

BUILDING.md

File metadata and controls

146 lines (110 loc) · 9.24 KB

Development

This page includes technical documentation for developers who want to build the IDE locally and contribute to the project.

Architecture overview

The IDE consists of three major parts:

  • the Electron main process,
  • the backend, and
  • the frontend.

The Electron main process is responsible for:

  • creating the application,
  • managing the application lifecycle via listeners, and
  • creating and managing the web pages for the app.

In Electron, the process that runs the main entry JavaScript file is called the main process. The Electron main process can display a GUI by creating web pages. An Electron app always has exactly one main process.

By default, whenever the Electron main process creates a web page, it will instantiate a new BrowserWindow instance. Since Electron uses Chromium for displaying web pages, Chromium's multi-process architecture is also used. Each web page in Electron runs in its own process, which is called the renderer process. Each BrowserWindow instance runs the web page in its own renderer process. When a BrowserWindow instance is destroyed, the corresponding renderer process is also terminated. The main process manages all web pages and their corresponding renderer processes. Each renderer process is isolated and only cares about the web page running in it.[1]

In normal browsers, web pages usually run in a sandboxed environment, and accessing native resources are disallowed. However, Electron has the power to use Node.js APIs in the web pages allowing lower-level OS interactions. Due to security reasons, accessing native resources is an undesired behavior in the IDE. So by convention, we do not use Node.js APIs. (Note: the Node.js integration is not yet disabled although it is not used). In the IDE, only the backend allows OS interaction.

The backend process is responsible for:

  • providing access to the filesystem,
  • communicating with the Arduino CLI via gRPC,
  • running your terminal,
  • exposing additional RESTful APIs,
  • performing the Git commands in the local repositories,
  • hosting and running any VS Code extensions, or
  • executing VS Code tasks[2].

The Electron main process spawns the backend process. There is always exactly one backend process. However, due to performance considerations, the backend spawns several sub-processes for the filesystem watching, Git repository discovery, etc. The communication between the backend process and its sub-processes is established via IPC. Besides spawning sub-processes, the backend will start an HTTP server on a random available port, and serves the web application as static content. When the sub-processes are up and running, and the HTTP server is also listening, the backend process sends the HTTP server port to the Electron main process via IPC. The Electron main process will load the backend's endpoint in the BrowserWindow.

The frontend is running as an Electron renderer process and can invoke services implemented on the backend. The communication between the backend and the frontend is done via JSON-RPC over a websocket connection. This means, the services running in the frontend are all proxies, and will ask the corresponding service implementation on the backend.

Build from source

If you’re familiar with TypeScript, the Theia IDE, and if you want to contribute to the project, you should be able to build the Arduino IDE locally. Please refer to the Theia IDE prerequisites documentation for the setup instructions.

Once you have all the tools installed, you can build the editor following these steps

  1. Install the dependencies and build

    yarn
  2. Rebuild the dependencies

    yarn rebuild:browser
  3. Rebuild the electron dependencies

    cd electron-app
    yarn theia rebuild:electron
    cd ..
  4. Start the application

    yarn start

CI

This project is built on GitHub Actions.

  • Snapshot builds run when changes are pushed to the main branch, or when a PR is created against the main branch. For the sake of the review and verification process, the build artifacts for each operating system can be downloaded from the GitHub Actions page.
  • Nightly builds run every day at 03:00 GMT from the main branch.
  • Release builds run when a new tag is pushed to the remote. The tag must follow the semver. For instance, 1.2.3 is a correct tag, but v2.3.4 won't work. Steps to trigger a new release build:
    • Create a local tag:
    git tag -a 1.2.3 -m "Creating a new tag for the `1.2.3` release."
    • Push it to the remote:
     git push origin 1.2.3

Notes for macOS contributors

Beginning in macOS 10.14.5, the software must be notarized to run. The signing and notarization processes for the Arduino IDE are managed by our Continuous Integration (CI) workflows, implemented with GitHub Actions. On every push and pull request, the Arduino IDE is built and saved to a workflow artifact. These artifacts can be used by contributors and beta testers who don't want to set up a build system locally. For security reasons, signing and notarization are disabled for workflow runs for pull requests from forks of this repository. This means that macOS will block you from running those artifacts. Due to this limitation, Mac users have two options for testing contributions from forks:

The Safe approach (recommended)

Follow the instructions above to create the build environment locally, then build the code you want to test.

The Risky approach

Please note that this approach is risky as you are lowering the security on your system, therefore we strongly discourage you from following it.

  1. Use this guide, in order to disable Gatekeeper (at your own risk!).
  2. Download the unsigned artifact provided by the CI workflow run related to the Pull Request at each push.
  3. Re-enable Gatekeeper after tests are done, following the guide linked above.

Creating a release

You will not need to create a new release yourself as the Arduino team takes care of this on a regular basis, but we are documenting the process here. Let's assume the current version is 0.1.3 and you want to release 0.2.0.

  • Make sure the main state represents what you want to release and you're on main.
  • Prepare a release-candidate build on a branch:
git branch 0.2.0-rc \
&& git checkout 0.2.0-rc
  • Bump up the version number. It must be a valid semver and must be greater than the current one:
yarn update:version 0.2.0
  • This should generate multiple outgoing changes with the version update.
  • Commit your changes and push to the remote:
git add . \
&& git commit -s -m "Updated versions to 0.2.0" \
&& git push
  • Create the GH PR the workflow starts automatically.
  • Once you're happy with the RC, merge the changes to the main.
  • Create a tag and push it:
git tag -a 0.2.0 -m "0.2.0" \
&& git push origin 0.2.0
  • The release build starts automatically and uploads the artifacts with the changelog to the release page.
  • If you do not want to release the EXE and MSI installers, wipe them manually.
  • If you do not like the generated changelog, modify it and update the GH release.

FAQ

  • Can I manually change the version of the arduino-cli used by the IDE?

    Yes. It is possible but not recommended. The CLI exposes a set of functionality via gRPC and the IDE uses this API to communicate with the CLI. Before we build a new version of IDE, we pin a specific version of CLI and use the corresponding proto files to generate TypeScript modules for gRPC. This means, a particular version of IDE is compliant only with the pinned version of CLI. Mismatching IDE and CLI versions might not be able to communicate with each other. This could cause unpredictable IDE behavior.

  • I have understood that not all versions of the CLI are compatible with my version of IDE but how can I manually update the arduino-cli inside the IDE?

    Get the desired version of arduino-cli for your platform and manually replace the one inside the IDE. The CLI can be found inside the IDE at:

    • Windows: C:\path\to\Arduino IDE\resources\app\node_modules\arduino-ide-extension\build\arduino-cli.exe,
    • macOS: /path/to/Arduino IDE.app/Contents/Resources/app/node_modules/arduino-ide-extension/build/arduino-cli, and
    • Linux: /path/to/Arduino IDE/resources/app/node_modules/arduino-ide-extension/build/arduino-cli.