how do i go about sourcing a .gn file from another BUILD.gn
for example, source skia's .gn file and inherit everything that it exposes so we can then depend on `:skia` as `libs [ ":skia" ]`
for example, so one does not need to do this
# manually copy parts on skia gn we require to build C bindings
# we have copied skia's gn directory to this $pwd
import("gn/shared_sources.gni")
import("gn/skia.gni")
if (defined(skia_settings)) {
import(skia_settings)
}
# Skia public API, generally provided by :skia.
config("skia_public") {
include_dirs = [ ".", "../externals/skia" ]
defines = []
cflags_objcc = []
if (is_component_build) {
defines += [ "SKIA_DLL" ]
}
if (is_fuchsia || is_linux) {
defines += [ "SK_R32_SHIFT=16" ]
}
if (skia_enable_flutter_defines) {
defines += flutter_defines
}
if (!skia_enable_gpu) {
defines += [ "SK_SUPPORT_GPU=0" ]
}
if (skia_enable_sksl) {
defines += [ "SK_ENABLE_SKSL" ]
}
if (skia_enable_precompile) {
defines += [ "SK_ENABLE_PRECOMPILE" ]
}
if (is_fuchsia) {
defines += fuchsia_defines
}
if (is_wasm) {
defines += wasm_defines
}
if (skia_gl_standard == "gles") {
defines += [ "SK_ASSUME_GL_ES=1" ]
} else if (skia_gl_standard == "gl") {
defines += [ "SK_ASSUME_GL=1" ]
} else if (skia_gl_standard == "webgl") {
defines += [
"SK_ASSUME_WEBGL=1",
"SK_USE_WEBGL",
]
}
if (!skia_enable_skgpu_v1) {
defines += [ "SK_GPU_V1=0" ]
}
if (skia_use_perfetto) {
defines += [ "SK_USE_PERFETTO" ]
}
# Temporary define for flutter to control in their GN build
if (skia_use_legacy_layer_bounds) {
defines += [ "SK_LEGACY_LAYER_BOUNDS_EXPANSION" ]
}
# Some older versions of the Clang toolchain change the visibility of
# symbols decorated with API_AVAILABLE macro to be visible. Users of such
# toolchains suppress the use of this macro till toolchain updates are made.
if (is_mac || is_ios) {
if (skia_enable_api_available_macro) {
defines += [ "SK_ENABLE_API_AVAILABLE" ]
} else {
cflags_objcc += [ "-Wno-unguarded-availability" ]
}
}
}
# Skia internal APIs, used by Skia itself and a few test tools.
config("skia_private") {
visibility = [ "./*", "../externals/skia/*" ]
defines = [ "SK_GAMMA_APPLY_TO_A8" ]
if (skia_use_fixed_gamma_text) {
defines += [
"SK_GAMMA_EXPONENT=1.4",
"SK_GAMMA_CONTRAST=0.0",
]
}
if (is_skia_dev_build && !is_wasm) {
defines += [
"SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1",
"GR_TEST_UTILS=1",
]
if (skia_enable_graphite) {
defines += [ "GRAPHITE_TEST_UTILS=1" ]
}
}
if (skia_compare_vm_vs_rp) {
defines += [ "SKIA_COMPARE_VM_VS_RP" ]
}
libs = []
lib_dirs = []
if (skia_use_gl && skia_use_angle) {
defines += [ "SK_ANGLE" ]
}
if (skia_use_vma) {
defines += [ "SK_USE_VMA" ]
}
if (skia_enable_winuwp) {
defines += [ "SK_WINUWP" ]
}
}
# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
config("skia_library") {
visibility = [ "./*", "../externals/skia/*" ]
defines = [ "SKIA_IMPLEMENTATION=1" ]
}
skia_library_configs = [
":skia_public",
":skia_private",
":skia_library",
]
# ALL OF THE ABOVE IS FROM SKIA BUILD.gn FILE
# SkiaSharp + HarfBuzzSharp
# SkiaSharp differs depending on the platform
template("skiasharp_build") {
_skiasharp_mode = "shared_library"
target(_skiasharp_mode, target_name) {
forward_variables_from(invoker, "*")
}
}
set_defaults("skiasharp_build") {
configs = default_configs
}
declare_args() {
# Skia output directory
# this is where we can find skia.lib and friends
SKIA_C_PATH = ""
}
skiasharp_build("SkiaSharp") {
# NOT GOOD ENOUGH
# DIFFERENT PLATFORMS MAY REQUIRE DIFFERENT DEPS
# AND DEPS MAY CHANGE BETWEEN SKIA VERSIONS/COMMITS
#
# additionally different OS's have different link extensions (.lib, .so, .dylib)
libs = [
"$SKIA_C_PATH/skia.lib",
"$SKIA_C_PATH/skottie.lib"
]
and instead can just do this
# SkiaSharp + HarfBuzzSharp
# SkiaSharp differs depending on the platform
template("skiasharp_build") {
_skiasharp_mode = "shared_library"
target(_skiasharp_mode, target_name) {
forward_variables_from(invoker, "*")
}
}
set_defaults("skiasharp_build") {
configs = default_configs
}
# SkiaSharp + HarfBuzzSharp
skiasharp_build("SkiaSharp") {
public_configs = [ ":skia_public" ]
configs += skia_library_configs
defines = [ "SKIA_C_DLL" ]
deps = [
":skia",
":modules/skottie"
]
libs = []