Skip to content

Development

per1234 edited this page Mar 13, 2024 · 10 revisions

Prerequisites

To build the Arduino CLI from sources, you need the following tools to be available in your local environment:

  • Go You must use the version specified by the go directive in the project's go.mod file:
    https://github.com/arduino/arduino-create-agent/blob/main/go.mod
    gvm is recommended if you need to work with multiple versions of Go on your machine.
  • Task to help you run the most common tasks from the command line
  • libappindicator (Linux only on Ubuntu sudo apt-get install gcc libgtk-3-dev libayatana-appindicator3-dev)
  • go-selfupdate if you want to test automatic updates

Building the source code

From the project folder root, just run:

task go:build

The project uses Go modules, so dependencies will be downloaded automatically. At the end of the build, you should find an arduino-create-agent executable in the same folder.

Windows

Since we are using the https://github.com/lxn/walk library, we need to ship a manifest.xml file, otherwise the error would be:

panic: Unable to create main window: TTM_ADDTOOL failed

To do it make sure to install the required tool:

$ go get github.com/akavel/rsrc

and build it with

$ rsrc -arch=386 -manifest=manifest.xml
$ go build

Keep in mind that the presence of rsrc.syso file will break other builds, for example

$ GOOS=linux go build
# github.com/arduino/arduino-create-agent
/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/sbin/ld: i386 architecture of input file `/tmp/go-link-084341451/000000.o' is incompatible with i386:x86-64 output
collect2: error: ld returned 1 exit status
Clone this wiki locally