The GN SDK frontend produces a GN workspace. Note that this directory has been deprecated. The GN SDK will be removed soon. Changes made to this directory will no longer take effect. Further changes should be made to https://chromium.googlesource.com/chromium/src/third_party/fuchsia-gn-sdk/ instead.
generate.py
: the script that generates the SDKBUILD.gn
: GN build rules to build & test the GN SDK and generation processtemplates
: Mako templates used to produce various SDK filesbase
: SDK contents that are copied verbatimtest_generate.py
: script to test the GN SDK generation processupdate_golden.py
: script to update the contents of the golden directoryhost_test.go
: Go script to run test defined in GN build rulestestdata
: files used as input during testsgolden
: files used to verify generator output during teststest_project
: GN project used to test building a projects with the GN SDKbash_tests
: contains test for bash scripts in base/binGenerate a IDK/core SDK:
fx set minimal.x64 fx build sdk:final_fuchsia_idk
Run the generate script:
$ fuchsia-vendored-python scripts/sdk/gn/generate.py \ --archive out/default/sdk/archive/fuchsia_idk.tar.gz \ --output gn_sdk_dir
Note: many of these tests require ${FUCHSIA_DIR}/.jiri_root/bin
to be on $PATH
. This might need to be added.
The internal GN SDK helper scripts/tools can be executed after the GN SDK has been generated.
$ gn_sdk_dir/tools/x64/fserve
To test the generator, run the test_generate.py
script.
$ fuchsia-vendored-python 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.
$ fuchsia-vendored-python scripts/sdk/gn/update_golden.py
Commit your changes to the generator, testdata
contents, and golden
contents together.
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
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
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
Generate the test workspace into a temporary directory:
$ fuchsia-vendored-python scripts/sdk/gn/generate.py \ --archive out/temp/idk.tar.gz \ --output out/temp/gn_sdk_dir/ \ --tests out/temp/test_workspace
Run the run.py
file in the test workspace:
$ fuchsia-vendored-python out/temp/test_workspace/run.py