Skip to content

FR: Allow configuring SDK path and ConnectIQ directory via BuildConfig #85

Description

@zmullett

Summary

Allow the SDK path and ConnectIQ installation directory to be specified via BuildConfig options, rather than always auto-discovering them from the platform-default locations.

Motivation

I've been building a Bazel toolchain for Connect IQ development and want to integrate @markw65/monkeyc-optimizer into the build pipeline. In this context, the build system already knows where the SDK and device metadata live — it resolves these paths at repository-rule time and passes them explicitly to each build action.

At the time of writing, my toolchain depends on local filesystem knowledge, but will eventually consume connect-iq-sdk-manager-cli to have its own Bazel-friendlier sandboxed SDK.

Currently, the optimizer hardcodes the ConnectIQ directory in sdk-util.ts:

export const connectiq =
  process.platform === "linux"
    ? `${process.env.HOME}/.Garmin/ConnectIQ`
    : `${appSupport}/Garmin/ConnectIQ`;

And getSdkPath() always reads current-sdk.cfg from that location. getDeviceInfo() and getLanguages() similarly use the hardcoded connectiq path to find device metadata.

This makes it a challenge to:

  • Use the optimizer in sandboxed or hermetic build environments where the CIQ installation may be mounted at a non-standard path
  • Run optimized builds in CI where the SDK is installed to a custom location
  • Use a different SDK version than the one pointed to by current-sdk.cfg

Proposed Change

Add two optional fields to BuildConfig:

export type BuildConfig = {
  // ... existing fields ...
  
  /** Path to the ConnectIQ SDK directory (e.g., "/path/to/connectiq-sdk-..."). 
   *  If set, bypasses reading current-sdk.cfg. */
  sdkPath?: string;
  
  /** Path to the ConnectIQ application support directory 
   *  (e.g., "/path/to/ConnectIQ" containing Devices/, Fonts/, etc.).
   *  If set, overrides the default platform-specific location. */
  connectIQPath?: string;
};

The changes would be localised to a few functions:

  1. getSdkPath() — if config.sdkPath is set, return it directly instead of reading current-sdk.cfg
  2. getDeviceInfo() — if config.connectIQPath is set, look for Devices/ under that path instead of the hardcoded connectiq constant
  3. getLanguages() — same as above
  4. default_jungle() in jungles.ts — uses connectiq for personality paths; would need the override here too

For the CLI driver, these could be exposed as --sdk-path and --connectiq-path arguments.

Alternatives Considered

  • Symlinking the CIQ directory to the expected location — works but is fragile and requires elevated permissions in some CI environments.
  • Environment variables (e.g. CONNECTIQ_HOME) — would also work, but explicit config fields are more discoverable and composable with the existing BuildConfig pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions