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/<platform>/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/<platform>/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 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.
A released SDK holds every platform. pbl sdk builds it:
pbl sdk $VERSION --frozen $FROZEN --tarball
Each platform is packaged from one board, listed in sdk/boards.yml. For
each of them the command configures a build of the SDK shell firmware 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, and the timeline
layouts.
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
<platform>/ include/, lib/, qemu/, platform.json
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 7753e801d. This page is maintained in the pebbleos repository: docs/sdk/building.md.