platformio / platform-atmelavr

Atmel AVR: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelavr
Apache License 2.0
140 stars 105 forks source link

toolchain-atmelavr source code and build scripts? #324

Open mid-kid opened 12 months ago

mid-kid commented 12 months ago

Hi, I'm trying to figure out a few details about the toolchain-atmelavr package:

valeros commented 12 months ago

Hi @mid-kid,

Where are the current binaries obtained from, if anywhere?

We use binaries provided by the Arduino IDE, for example: https://github.com/arduino/Arduino/blob/master/hardware/package_index_bundled.json#L74-L116

How is it built? With what kind of options?

You can find the used option if you run avr-gcc -v, for example:

Target: avr
Configured with: ../gcc/configure --enable-fixed-point --enable-languages=c,c++ --prefix=/home/jenkins-mingw32/workspace/avr-gcc-staging/label/Ubuntu14.04x64-mingw32/objdir --disable-nls --disable-libssp --disable-libada --disable-shared --with-avrlibc=yes --with-dwarf2 --disable-doc --target=avr --host=i686-w64-mingw32

Which specific version of the code is used? Is it patched?

It's GCC 7.3.0 with some additional patches, you can find sources here https://github.com/arduino/toolchain-avr

mid-kid commented 11 months ago

Thanks! That answers most of my Qs.

Is that the json file being used as a definition, or are the package definitions for platformio hosted elsewhere?

valeros commented 11 months ago

Package definitions are specified in this file https://github.com/platformio/platform-atmelavr/blob/develop/platform.json, the packages are hosted on the PlatformIO Package Registry and delivered through our CDN network.

mid-kid commented 11 months ago

I see the toolchain-atmelavr entry in there but nothing that'd tell it where to download it from or checksum information so I'm a bit confused.

ivankravets commented 11 months ago

PlatformIO Core handles all these things automatically. When you build a project for the first time, PlatformIO Core pulls dependencies from the PlatformIO Registry and validates checksum for each downloaded package. See https://github.com/platformio/platformio-core/blob/develop/platformio/package/download.py#L122

mid-kid commented 11 months ago

Yeah, I'm just trying to understand the "repository" structure and how it decides to download what from where. Mostly out of personal interest, but also because I'm wary of package managers downloading random binaries from the internet. Thanks for all the answers thus far.

ivankravets commented 11 months ago

PlatformIO Core is an OSS project. You learn more about PlatformIO Package Manager from its sources https://github.com/platformio/platformio-core/tree/develop/platformio/package/manager

The core logic is based on get_systype(). Having information about host architecture, PlatormIO Core goes to the PlatformIO Registry and looks for the best package corresponding to the https://semver.org/

mid-kid commented 11 months ago

I see, it's querying https://api.registry.platformio.org/v3/packages/platformio/tool/toolchain-atmelavr for all the information, including download URL (from dl.registry.platformio.org) and checksum.

Is the data obtained from api.registry.platformio.org hosted in a git somewhere, or is it entered into a live database? Is the backend published anywhere?

thirstyice commented 6 months ago

Hi, I'm also having trouble understanding how this works. Where is the source for the toolchain-atmelavr package? I haven't been able to find it anywhere, even though the license is listed as GPL-2.0-or-later

valeros commented 6 months ago

@thirstyice

Where is the source for the toolchain-atmelavr package? I haven't been able to find it anywhere, even though the license is listed as GPL-2.0-or-later

It's generic GCC 7.3.0 with some additional patches, you can find sources here https://github.com/arduino/toolchain-avr

thirstyice commented 6 months ago

How are they packaged for platformio?

valeros commented 6 months ago

How are they packaged for platformio?

We use compiled packages provided by Arduino IDE from their manifest.