mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:17:35 +00:00
Meta: Add gn build rules for LibWeb
This commit is contained in:
parent
7b3d0fb002
commit
85c8cd5205
60 changed files with 1966 additions and 0 deletions
64
Meta/gn/build/embed_as_string_view.gni
Normal file
64
Meta/gn/build/embed_as_string_view.gni
Normal file
|
@ -0,0 +1,64 @@
|
|||
# This file introduces a template for calling embed_as_string_view.py.
|
||||
#
|
||||
# embed_as_string_view behaves like C++23 #embed, converting an input file into
|
||||
# an AK::StringView literal rather than a C-string literal. The literal will
|
||||
# be placed into a global variable, optionally with a namespace wrapping it.
|
||||
#
|
||||
# Note that the file must not contain any tokens that need to be escaped
|
||||
# in C++, or the script will fail to produce a valid C++ translation unit.
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# input (required) [string]
|
||||
#
|
||||
# output (required) [string]
|
||||
#
|
||||
# variable_name (required) [string]
|
||||
#
|
||||
# namespace (optional) [string]
|
||||
#
|
||||
# Example use:
|
||||
#
|
||||
# embed_as_string_view("embed_my_file") {
|
||||
# input = "MyFile.txt"
|
||||
# output = "$root_gen_dir/MyDirectory/MyFile.cpp"
|
||||
# variable_name = "my_file_contents"
|
||||
# namespace = "My::NS"
|
||||
# }
|
||||
|
||||
template("embed_as_string_view") {
|
||||
assert(defined(invoker.input), "must set 'input' in $target_name")
|
||||
assert(defined(invoker.output), "must set 'output' in $target_name")
|
||||
assert(defined(invoker.variable_name),
|
||||
"must set 'variable_name' in $target_name")
|
||||
|
||||
action(target_name) {
|
||||
script = "//Meta/gn/build/embed_as_string_view.py"
|
||||
|
||||
sources = [ invoker.input ]
|
||||
outputs = [ invoker.output ]
|
||||
args = [
|
||||
"-o",
|
||||
rebase_path(outputs[0], root_build_dir),
|
||||
"-n",
|
||||
invoker.variable_name,
|
||||
]
|
||||
if (defined(invoker.namespace)) {
|
||||
args += [
|
||||
"-s",
|
||||
invoker.namespace,
|
||||
]
|
||||
}
|
||||
args += [ rebase_path(sources[0], root_build_dir) ]
|
||||
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"configs",
|
||||
"deps",
|
||||
"public_configs",
|
||||
"public_deps",
|
||||
"testonly",
|
||||
"visibility",
|
||||
])
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue