This document outlines a step by step process for converting the stub platform's GN files to GN files that will be able to be built for your platform. It assumes you have an already working port of Starboard using GYP.
This is one way for migrating your platform from GYP to GN. The benefit of following this is that you can have regular checkpoints to see if your migration is going correctly, rather than trying to do the entire migration at once where it's uncertain how much progress is being made.
Here are the steps to do your migration:
After each step, you should be able to build the starboard_platform target. For example, you would build raspi2 starboard_platform target with the following commands:
$gn gen out/raspi-2gn_devel --args='target_platform="raspi-2" build_type="devel"' $ninja -C out/raspi-2gn_devel/ starboard
Here is a list of steps outlining which files to copy over and how to build those files:
Follow instructions here for migrating the toolchain. Resolve errors and build the starboard_platform target with the stubbed files.
This involves migrating the compiler flags and build variables as referenced here.
It’s good to turn off the
treat_warnings_as_errors flaguntil you can compile the starboard_platform target with the platform files. If this flag is not disabled you might run into a lot of warnings turned errors and it might take time to solve all those errors. Meanwhile you won‘t be in a buildable state which might make it uncertain as to how much progress you are actually making. For disabling the flag you can pass that as an argument to gn. Here’s an example for disabling the flag for raspi2:$gn gen out/raspi-2gn_devel --args='target_platform="raspi-2" build_type="devel" treat_warnings_as_errors=false'
Resolve errors and build the starboard_platform target with the stubbed files.
This involves adding files for the starboard_platform target as suggested here.
While building any target, follow the recommendation above of building the target with
Once you can build your platform files, you can remove the
treat_warnings_as_errors=false flag and resolve the warning errors.
I’m getting a build error! What should I do?
Some common questions to ask yourself:
Is the same target building with GYP + ninja (as GN + Ninja)?
For example if the
nplbtarget is not being built by GN, check first if it can be built with GYP. If GYP cannot build it, this indicates that some flags are missing in GYP itself so it might be prudent to solve that first before migrating to GN.
Am I missing a config/dependency to include the missing file?
gn check can help point out missing dependencies.
Is the same file being included in the build by GYP?
Add a preprocessor directive like #error “This file is included” in that file and see if GYP + Ninja prints out that error message.
Is the same code path being followed by GYP + ninja ?
Use the same method as above.
Are the compiler flags for this file the same as in GYP ?
Have you passed in the default arguments for your platform correctly?
Default variables such as
target_osand others can be overridden by passing arguments to gn while building. Here's an example of passing the default argument
target_cpufor raspi2:$gn gen out/raspi-2gn_devel --args='target_platform="raspi-2" build_type="devel" target_cpu="arm"'