blob: 44535339c31a7d08711f84fa957549b406057922 [file] [log] [blame]
# Copyright 2018 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Recipe for downloading and packaging Vulkan SDK."""
from recipe_engine.recipe_api import Property
DEPS = [
"fuchsia/status_check",
"fuchsia/upload",
"recipe_engine/archive",
"recipe_engine/cipd",
"recipe_engine/path",
"recipe_engine/properties",
"recipe_engine/step",
"recipe_engine/url",
]
PROPERTIES = {"version": Property(kind=str, help="SDK version", default="1.1.92.1")}
# These target spellings are used by Vulkan SDK.
PLATFORMS_TO_TARGETS = {
"linux-amd64": "linux-x86_64",
"mac-amd64": "macos",
}
PLATFORMS = PLATFORMS_TO_TARGETS.keys()
URL_TEMPLATE = "https://sdk.lunarg.com/sdk/download/{0}/{1}/vulkansdk-{2}-{0}.tar.gz"
def RunSteps(api, version):
for platform in PLATFORMS:
with api.step.nest(platform):
url = URL_TEMPLATE.format(
version, platform.split("-")[0], PLATFORMS_TO_TARGETS[platform]
)
sdk_tarball = api.path["start_dir"].join("vulkansdk-%s.tar.gz" % platform)
api.url.get_file(url, sdk_tarball, step_name="fetch sdk")
sdk_path = api.path["start_dir"].join("vulkansdk-%s" % platform)
api.archive.extract("extract sdk", sdk_tarball, sdk_path)
pkg_dir = sdk_path.join(
{"linux-amd64": version, "mac-amd64": "vulkansdk-macos-" + version,}[
platform
]
)
api.upload.cipd_package(
"fuchsia/third_party/vulkansdk/%s" % platform,
pkg_dir,
[api.upload.DirectoryPath(pkg_dir)],
{"version": version},
)
def GenTests(api):
version = "1.2.30.4"
cipd_search_step_data = []
for platform in PLATFORMS:
pkg_name = "fuchsia/third_party/vulkansdk/" + platform
cipd_search_step_data.append(
api.step_data(
platform + ".cipd.cipd search " + pkg_name + " version:" + version,
api.cipd.example_search(pkg_name + platform, []),
)
)
yield (
api.status_check.test("existing")
+ api.properties(version=version)
+ reduce(lambda a, b: a + b, cipd_search_step_data)
)
yield api.status_check.test("new") + api.properties(version=version)