| # 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 building FFmpeg and uploading it and required source files.""" |
| |
| from PB.recipes.fuchsia.ffmpeg import InputProperties |
| |
| DEPS = [ |
| "fuchsia/build", |
| "fuchsia/buildbucket_util", |
| "fuchsia/checkout", |
| "fuchsia/jiri", |
| "fuchsia/status_check", |
| "fuchsia/upload", |
| "recipe_engine/buildbucket", |
| "recipe_engine/cipd", |
| "recipe_engine/context", |
| "recipe_engine/file", |
| "recipe_engine/path", |
| "recipe_engine/properties", |
| "recipe_engine/python", |
| "recipe_engine/step", |
| ] |
| |
| PROPERTIES = InputProperties |
| |
| # Patterns of source code to include in the archive that this recipe produces. |
| # All relative to third_party/ffmpeg. |
| SOURCE_PATTERNS = ["fuchsia/config/**/*", "lib*/*.h"] |
| |
| |
| def RunSteps(api, props): |
| checkout = api.checkout.fuchsia_with_options( |
| path=api.path["start_dir"], manifest=props.manifest, remote=props.remote, |
| ) |
| |
| staging_dir = api.path.mkdtemp("ffmpeg") |
| pkg_dir = staging_dir.join("root") |
| |
| # Build and archive for all targets before uploading any to avoid an |
| # incomplete upload. |
| for build in props.builds: |
| with api.step.nest(build.target): |
| build_results = api.build.with_options( |
| checkout=checkout, |
| target=build.target, |
| build_type=build.build_type, |
| product=build.product, |
| ninja_targets=build.ninja_targets, |
| variants=build.variants, |
| build_images=not build.exclude_images, |
| fint_params_path=build.fint_params_path, |
| ) |
| with api.context(infra_steps=True): |
| shared_build_dir = build_results.build_dir.join( |
| "%s-shared" % build.target |
| ) |
| lib_dir = pkg_dir.join("arch", build.target, "lib") |
| api.file.ensure_directory("create lib dir", lib_dir) |
| api.file.copy( |
| "copy libffmpeg.so", shared_build_dir.join("libffmpeg.so"), lib_dir |
| ) |
| debug_dir = pkg_dir.join("arch", build.target, "debug") |
| api.file.ensure_directory("create debug dir", debug_dir) |
| api.file.copy( |
| "copy libffmpeg.so (debug)", |
| shared_build_dir.join("lib.unstripped", "libffmpeg.so"), |
| debug_dir, |
| ) |
| |
| for variant in build.variants: |
| with api.step.nest(variant): |
| shared_variant_build_dir = build_results.build_dir.join( |
| "%s-%s-shared" % (build.target, variant) |
| ) |
| lib_variant_dir = lib_dir.join(variant) |
| api.file.ensure_directory("create lib dir", lib_variant_dir) |
| api.file.copy( |
| "copy libffmpeg.so", |
| shared_variant_build_dir.join("libffmpeg.so"), |
| lib_variant_dir, |
| ) |
| debug_variant_dir = debug_dir.join(variant) |
| api.file.ensure_directory("create debug dir", debug_variant_dir) |
| api.file.copy( |
| "copy libffmpeg.so (debug)", |
| shared_variant_build_dir.join( |
| "lib.unstripped", "libffmpeg.so" |
| ), |
| debug_variant_dir, |
| ) |
| |
| ffmpeg_dir = checkout.root_dir.join("third_party", "ffmpeg") |
| api.python( |
| "copy files", |
| api.resource("copy_files.py"), |
| args=[ffmpeg_dir, pkg_dir.join("pkg", "ffmpeg", "include"),] + SOURCE_PATTERNS, |
| ) |
| docs_dir = pkg_dir.join("pkg", "ffmpeg", "docs") |
| api.file.ensure_directory("create docs dir", docs_dir) |
| api.file.copy( |
| "copy license", ffmpeg_dir.join("LICENSE.md"), docs_dir.join("LICENSE.md") |
| ) |
| |
| if api.buildbucket_util.is_tryjob: |
| return |
| |
| with api.context(infra_steps=True): |
| project = checkout.project("third_party/ffmpeg") |
| |
| api.upload.cipd_package( |
| "fuchsia/lib/ffmpeg/fuchsia", |
| pkg_dir, |
| [api.upload.DirectoryPath(pkg_dir)], |
| {"git_revision": project["revision"]}, |
| repository=project["remote"], |
| ) |
| |
| |
| def GenTests(api): |
| def properties(): |
| return api.properties( |
| manifest="third_party/ffmpeg", |
| remote="https://fuchsia.googlesource.com/integration", |
| builds=[ |
| { |
| "target": "arm64", |
| "build_type": "release", |
| "variants": ["lto", "asan"], |
| "exclude_images": True, |
| "ninja_targets": ["arm64/libffmpeg.so"], |
| "fint_params_path": "specs/ffmpeg-arm64.fint.textproto", |
| }, |
| { |
| "target": "x64", |
| "build_type": "release", |
| "variants": ["lto", "asan"], |
| "exclude_images": True, |
| "ninja_targets": ["x64/libffmpeg.so"], |
| "fint_params_path": "specs/ffmpeg-x64.fint.textproto", |
| }, |
| ], |
| ) |
| |
| yield ( |
| api.status_check.test("default") |
| + properties() |
| + api.buildbucket.ci_build( |
| git_repo="https://fuchsia.googlesource.com/third_party/ffmpeg" |
| ) |
| + api.step_data( |
| "cipd.cipd search fuchsia/lib/ffmpeg/fuchsia git_revision:%s" |
| % api.jiri.example_revision, |
| api.cipd.example_search("fuchsia/lib/ffmpeg/fuchsia", []), |
| ) |
| ) |
| yield ( |
| api.status_check.test("cq") |
| + properties() |
| + api.buildbucket.try_build( |
| git_repo="https://fuchsia.googlesource.com/third_party/ffmpeg" |
| ) |
| ) |