The GN SDK frontend produces a GN workspace.
generate.py
: the script that generates the SDK;templates
: Mako templates used to produce various SDK files;base
: SDK contents that are copied verbatim;testdata
: files used as input during testsgolden
: files used to verify generator output during testsGenerating the GN SDK requires the download of an existing Core SDK, e.g.:
$ BUILD_ID="$(gsutil cat gs://fuchsia/development/LATEST_LINUX)" && gsutil cp gs://fuchsia/development/$BUILD_ID/sdk/linux-amd64/core.tar.gz my_sdk_archive.tar.gz
Generate the GN SDK by pointing the generate.py
script to an SDK archive, e.g.:
$ scripts/sdk/gn/generate.py \ --archive my_sdk_archive.tar.gz \ --output gn_sdk_dir/
The internal GN SDK helper scripts can be executed after the GN SDK has been generated.
$ gn_sdk_dir/bin/fserve.sh $ gn_sdk_dir/bin/fpave.sh $ gn_sdk_dir/bin/fssh.sh $ gn_sdk_dir/bin/femu.sh
To test the generator, run the test_generate.py
script.
$ scripts/sdk/gn/test_generate.py
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 update_golden.py
script to fix the golden
files.
$ scripts/sdk/gn/update_golden.py
Commit your changes to the generator, testdata
contents, and golden
contents together.
To test the bash scripts, run the bash_tests/run_bash_tests.sh
script.
$ scripts/sdk/gn/bash_tests/run_bash_tests.sh
This runs the tests in the scripts/sdk/gn/bash_tests
which tests the scripts found in scripts/sdk/gn/base/bin
.
To test the SDK on a test project, the generate.py
must be run with the --tests
flag. generate.py
requires a IDK (integrator development kit) build
Create a temporary directory with subdirectories for the SDK and test workspaces:
mkdir -p temp/gn_sdk_dir temp/test_workspace
Download the latest IDK (integrator development kit) to a temporary directory:
$ BUILD_ID="$(gsutil cat gs://fuchsia/development/LATEST_LINUX)" gsutil cp gs://fuchsia/development/$BUILD_ID/sdk/linux-amd64/core.tar.gz temp/idk.tar.gz
Generate the test workspace into a temporary directory:
$ scripts/sdk/gn/generate.py \ --archive temp/idk.tar.gz \ --output temp/gn_sdk_dir/ \ --tests temp/test_workspace
Run the run.py
file in the test workspace:
$ temp/test_workspace/run.py