The GN SDK frontend produces a GN workspace.

Directory structure

Generation files & folders

  • the script that generates the SDK
  • GN build rules to build & test the GN SDK and generation process
  • templates: Mako templates used to produce various SDK files
  • base: SDK contents that are copied verbatim

Testing files & folders

  • script to test the GN SDK generation process
  • script to update the contents of the golden directory
  • host_test.go: Go script to run test defined in GN build rules
  • testdata: files used as input during tests
  • golden: files used to verify generator output during tests
  • test_project: GN project used to test building a projects with the GN SDK
  • bash_tests: contains test for bash scripts in base/bin


  1. Create the GN build rules to build the GN SDK: fx set core.x64 --with //scripts/sdk/gn:gn_sdk_test_workspace --args="build_sdk_archives=true"
  2. Build the build rules to build the GN SDK: fx build

The built SDK will be in //${ROOT_OUT_DIR}/sdk/gn/fuchsia-sdk (usually //out/default/sdk/gn/fuchsia-sdk)

Manual generation steps

The above instructions is not what is run during testing and CQ. The GN build step performs the following steps which is run in CQ:

  1. Generate a IDK/core SDK:

    fx set core.x64 --with //sdk:core --args="build_sdk_archives=true"
    fx build
  2. Run the generate script:

    $ prebuilt/third_party/python3/linux-x64/bin/python3.8 scripts/sdk/gn/ \
        --archive out/default/sdk/archive/core.tar.gz \
        --output gn_sdk_dir


Note: many of these tests require python3.8 to be on $PATH. This might need to be added.

Execute GN SDK scripts/tools

The internal GN SDK helper scripts/tools can be executed after the GN SDK has been generated.

$ gn_sdk_dir/tools/x64/fserve
$ gn_sdk_dir/bin/

SDK generator tests

To test the generator, run the script.

$ prebuilt/third_party/python3/linux-x64/bin/python3.8 scripts/sdk/gn/

This runs the generator against the testdata directory and compares the output to the files in the golden directory.

After making changes to the generator, update the contents of testdata as needed to exercise your new code, then run the script to fix the golden files.

$ prebuilt/third_party/python3/linux-x64/bin/python3.8 scripts/sdk/gn/

Commit your changes to the generator, testdata contents, and golden contents together.

Bash scripts test

Make sure the tests are part of your build by adding --with //scripts/sdk/gn:tests to your fx set command.

To test the bash scripts, run fx test host_x64/gn_sdk_script_tests

Test project test

To test the SDK on a test project, the must be run with the --tests flag. requires a IDK (integrator development kit) build

  1. Download the latest IDK (integrator development kit) to a temporary directory (assuming the current directory is $FUCHSIA_DIR):

    $ mkdir -p out/temp
    $ BUILD_ID="$(gsutil cat gs://fuchsia/development/LATEST_LINUX)"
    $ gsutil cp gs://fuchsia/development/$BUILD_ID/sdk/linux-amd64/core.tar.gz out/temp/idk.tar.gz
  2. Generate the test workspace into a temporary directory:

    $ prebuilt/third_party/python3/linux-x64/bin/python3.8 scripts/sdk/gn/ \
     --archive out/temp/idk.tar.gz \
     --output out/temp/gn_sdk_dir/ \
     --tests out/temp/test_workspace
  3. Run the file in the test workspace:

    $ prebuilt/third_party/python3/linux-x64/bin/python3.8 out/temp/test_workspace/