The SDK is generated by the firmware build, from the firmware’s own headers, so it always matches the firmware it is built with.
The generator (tools/generate_native_sdk/generate_pebble_native_sdk_files.py)
runs automatically as part of the firmware build (normal variant only — PRF
and test builds skip it). It exports the white-listed functions, typedefs
and #defines from the firmware tree and produces the files needed to build
native watchapps, all under build/:
build/sdk/<abi>/include/pebble.h — typedefs, defines and function
prototypes for apps (plus pebble_worker.h for background workers and a
few version/fonts headers). Exported declarations are copied verbatim and
use pbl/kernel/compiler.h macros rather than raw __attribute__; the
generator rewrites those into their GCC spellings, so the SDK ships no
firmware headers. Only macros that alias an attribute or forward their
arguments to a builtin can be exported.
build/sdk/<abi>/lib/libpebble.a — static library containing
trampolines that call the exported functions in flash
build/pebble/pebble.auto.c — g_pbl_system_tbl, the table of function
pointers the trampolines use to find an exported function’s address;
compiled into the firmware image
The headers and the library are those of the ABI, armv7m, not of the
platform the firmware is built for: every board of the ABI generates the
same ones. The few defines that differ between platforms, such as
PBL_IF_COLOR_ELSE and PBL_PLATFORM_TYPE_CURRENT, are decided in the
header by the defines the app build passes for the platform it builds for
(PBL_COLOR, PBL_PLATFORM_EMERY, …), see Exporting a function. The generator
checks that this gives the build’s platform what its firmware has.
The rest of the distribution is packaged by the firmware build’s sdk
target, which fills in the same build/sdk/ tree:
pbl configure --board $BOARD
pbl build sdk
tools/cmake/sdk.py copies the common files from sdk/ into
build/sdk/common/ — the app project templates under sdk/defaults/, and
the tools and resource pipeline the app build shares with the firmware —
and the CMake package apps are built with, sdk/cmake/, into
build/sdk/cmake/ (Building apps). It also bundles sdk/waftools/ into
the deprecated waf binary older projects build with. That waf is the only
one left in the tree: everything it needs lives under sdk/, and it is
built out of tree, so packaging leaves the checkout untouched.
It also writes build/sdk/<platform>/platform.json, the description of the
platform out of the build’s Kconfig. The SDK has no other record of what
its platforms are like: the app build derives the PBL_* defines, resource
tags and size limits of each platform from that file. An SDK put together
from several firmware builds needs the platform.json of each, and nothing
else of them: a platform’s directory needs no headers and no library.
The app build takes the headers and the library from the platform’s own
directory if it has them, and from the directory of its ABI otherwise. The
frozen platforms have their own, as their headers stop at the SDK revision
they were frozen at. For tools that only look in a platform’s directory,
include and lib there are links to those of the ABI.
A released SDK holds every platform. pbl sdk builds it:
pbl sdk $VERSION --frozen $FROZEN --tarball
Each platform is built on the board sdk/platforms.yml gives it. For each
of them the command configures a build of the SDK shell firmware for the
platform and builds two targets:
sdk, as above;
sdk_emulator, on boards that run in QEMU, which adds what the pebble
tool emulates the platform with to build/sdk/<platform>/qemu/: the
firmware, the SPI flash image with the system resources, the timeline
layouts, and qemu.json, the machine to run them on.
qemu.json holds the QEMU options of the firmware’s build, so the pebble
tool launches each platform as the firmware describes it:
{
"machine": "pebble,psram-size=0x1000000",
"cpu": "cortex-m33",
"memory": 524288,
"audio": true
}
machine: -machine, with its options (CONFIG_QEMU_MACHINE).
cpu: -cpu (CONFIG_QEMU_CPU), null for the machine’s default.
memory: -m, in bytes (CONFIG_QEMU_RAM_SIZE), null for the
machine’s default.
audio: whether the machine takes an audiodev.
The headers and the library of the ABI have to come out the same from every
platform, and the command stops if they do not. It then adds the frozen platforms, whose headers tools/build_sdk.py
generates at the SDK revision each was frozen at, and whose libpebble.a
and emulator come from the directory given with --frozen, as they are the
ones those platforms were frozen with. The result is build-sdk/sdk-core/:
sdk-core/
manifest.json version and requirements, for the pebble tool
package.json, requirements.txt, use_requirements.json
pebble/
cmake/, common/, waf what the platforms share
armv7m/ include/, lib/: what the platforms of the ABI share
<platform>/ platform.json, qemu/, links to include/ and lib/
<frozen platform>/ include/, lib/, qemu/
Both app builds read package.json through sdk/tools/pebble_project.py;
the CMake build’s steps are sdk/tools/pebble_build.py.
Generated from PebbleOS 7416f78a1. This page is maintained in the pebbleos repository: docs/sdk/building.md.