mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 14:47:34 +00:00
Meta: Add file download and archive extraction tools to gn build
Use them to download and extract the TZDB files
This commit is contained in:
parent
05f56e09b5
commit
0e24bfb464
7 changed files with 367 additions and 2 deletions
80
Meta/gn/build/download_file.gni
Normal file
80
Meta/gn/build/download_file.gni
Normal file
|
@ -0,0 +1,80 @@
|
|||
#
|
||||
# This file introduces a template for calling download_file.py
|
||||
#
|
||||
# download_file behaves like CMake's file(DOWNLOAD) with the addtion
|
||||
# of version checking the file against a build system defined version.
|
||||
#
|
||||
# Parameters:
|
||||
# url (required) [string]
|
||||
#
|
||||
# output (required) [string]
|
||||
#
|
||||
# version (required) [string]
|
||||
# Version of the file for caching purposes
|
||||
#
|
||||
# version_file (reqiured) [string]
|
||||
# Filename to write the version to in the filesystem
|
||||
#
|
||||
# cache [String]
|
||||
# Directory to clear on version mismatch
|
||||
#
|
||||
#
|
||||
# Example use:
|
||||
#
|
||||
# download_file("my_tarball") {
|
||||
# url = "http://example.com/xyz.tar.gz"
|
||||
# output = "$root_gen_dir/MyModule/xyz.tar.gz"
|
||||
# version = "1.2.3"
|
||||
# version_file = "$root_gen_dir/MyModule/xyz_version.txt"
|
||||
# }
|
||||
#
|
||||
|
||||
template("download_file") {
|
||||
assert(defined(invoker.url), "must set 'url' in $target_name")
|
||||
assert(defined(invoker.output), "must set 'output' in $target_name")
|
||||
assert(defined(invoker.version), "must set 'version' in $target_name")
|
||||
assert(defined(invoker.version_file),
|
||||
"must set 'version_file' in $target_name")
|
||||
|
||||
action(target_name) {
|
||||
script = "//Meta/gn/build/download_file.py"
|
||||
|
||||
sources = []
|
||||
if (defined(invoker.cache)) {
|
||||
outputs = [
|
||||
invoker.cache + "/" + invoker.output,
|
||||
invoker.cache + "/" + invoker.version_file,
|
||||
]
|
||||
} else {
|
||||
outputs = [
|
||||
invoker.output,
|
||||
invoker.version_file,
|
||||
]
|
||||
}
|
||||
args = [
|
||||
"-o",
|
||||
rebase_path(outputs[0], root_build_dir),
|
||||
"-f",
|
||||
rebase_path(outputs[1], root_build_dir),
|
||||
"-v",
|
||||
invoker.version,
|
||||
invoker.url,
|
||||
]
|
||||
if (defined(invoker.cache)) {
|
||||
args += [
|
||||
"-c",
|
||||
rebase_path(invoker.cache, 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