-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
616 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Enable Bzlmod for every Bazel command | ||
common --enable_bzlmod | ||
|
||
# Always use the pre-configured toolchain. | ||
build --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 | ||
build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 | ||
|
||
# Use a static value for `PATH` and does not inherit `LD_LIBRARY_PATH`. Doesn't let environment | ||
# variables like `PATH` sneak into the build, which can cause massive cache misses when they change. | ||
# Use `--action_env=ENV_VARIABLE` if you want to inherit specific environment variables from the | ||
# client, but note that doing so can prevent cross-user caching if a shared cache is used. | ||
# Docs: https://bazel.build/reference/command-line-reference#flag--incompatible_strict_action_env | ||
build --incompatible_strict_action_env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
filegroup( | ||
name = "all_files", | ||
srcs = glob([ | ||
"lib/x86_64-linux-gnu/ld*", | ||
"lib/x86_64-linux-gnu/libc*", | ||
"lib/x86_64-linux-gnu/libdl*", | ||
"lib/x86_64-linux-gnu/libgcc*", | ||
"lib/x86_64-linux-gnu/libm*", | ||
"lib/x86_64-linux-gnu/libpthread*", | ||
"lib/x86_64-linux-gnu/librt*", | ||
"lib/x86_64-linux-gnu/libutil*", | ||
"lib64/**", | ||
"usr/include/*.h", | ||
"usr/include/arpa/**", | ||
"usr/include/asm-generic/**", | ||
"usr/include/linux/**", | ||
"usr/include/net/**", | ||
"usr/include/netinet/**", | ||
"usr/include/rpc/**", | ||
"usr/include/sys/**", | ||
"usr/include/x86_64-linux-gnu/**", | ||
"usr/lib/gcc/**", | ||
"usr/lib/x86_64-linux-gnu/*crt*.o", | ||
"usr/lib/x86_64-linux-gnu/libc_nonshared.a", | ||
"usr/lib/x86_64-linux-gnu/libc.a", | ||
"usr/lib/x86_64-linux-gnu/libc.so", | ||
"usr/lib/x86_64-linux-gnu/libdl*", | ||
"usr/lib/x86_64-linux-gnu/libm*", | ||
"usr/lib/x86_64-linux-gnu/libpthread*", | ||
"usr/lib/x86_64-linux-gnu/libresolv.so", | ||
"usr/lib/x86_64-linux-gnu/librt*", | ||
"usr/lib/x86_64-linux-gnu/libutil*", | ||
], | ||
exclude = [ | ||
# The sysroot contains libstdc++, but we use libc++ from our toolchain | ||
# repo. Exclude these files so we don't pull them into the sandbox | ||
# unnecessarily. When upgrading, make sure the newest libstdc++ is | ||
# excluded. | ||
"usr/include/c++/**", | ||
"usr/include/x86_64-linux-gnu/c++/**", | ||
"usr/lib/gcc/x86_64-linux-gnu/6/libstdc++*", | ||
"usr/lib/gcc/x86_64-linux-gnu/10/libstdc++*", | ||
], | ||
), | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
bazel_dep(name = "rules_foreign_cc") | ||
local_path_override( | ||
module_name = "rules_foreign_cc", | ||
path = "../..", | ||
) | ||
|
||
bazel_dep(name = "nasm", version = "2.14.02") | ||
bazel_dep(name = "platforms", version = "0.0.9") | ||
bazel_dep(name = "rules_cc", version = "0.0.9") | ||
bazel_dep(name = "rules_python", version = "0.23.1") | ||
bazel_dep(name = "rules_license", version = "0.0.8") | ||
|
||
non_module_deps = use_extension("//:repositories.bzl", "repositories_ext") | ||
use_repo( | ||
non_module_deps, | ||
"com_googleapis_storage_chrome_linux_amd64_sysroot", | ||
"ffmpeg", | ||
"libaom", | ||
"libdav1d", | ||
"libsvtav1", | ||
"libvpx", | ||
"libyuv", | ||
"yasm", | ||
) | ||
|
||
# C++ toolchain | ||
bazel_dep(name = "toolchains_llvm", version = "1.2.0") | ||
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True) | ||
llvm.toolchain(llvm_version = "19.1.0") | ||
llvm.sysroot( | ||
label = "@com_googleapis_storage_chrome_linux_amd64_sysroot//:all_files", | ||
targets = ["linux-x86_64"], | ||
) | ||
use_repo(llvm, "llvm_toolchain") | ||
register_toolchains("@llvm_toolchain//:all", dev_dependency = True) | ||
|
||
|
||
# Python toolchain | ||
python = use_extension("@rules_python//python/extensions:python.bzl", "python") | ||
python.toolchain( | ||
configure_coverage_tool = True, | ||
# Only set when you have mulitple toolchain versions. | ||
is_default = True, | ||
python_version = "3.10", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
|
||
exports_files( | ||
[ | ||
"BUILD.ffmpeg.bazel", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
build_test( | ||
name = "ffmpeg_build_test", | ||
targets = [ | ||
"@ffmpeg//:ffmpeg", | ||
], | ||
visibility = ["//:__pkg__"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
load("@rules_license//rules:license.bzl", "license") | ||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make") | ||
|
||
package( | ||
default_applicable_licenses = [":license"], | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
exports_files(["LICENSE"]) | ||
|
||
license( | ||
name = "license", | ||
package_name = "ffmpeg", | ||
license_kinds = [ | ||
"@rules_license//licenses/spdx:LGPL-3.0-or-later", | ||
], | ||
license_text = "LICENSE", | ||
package_url = "https://github.com/FFmpeg/FFmpeg", | ||
) | ||
|
||
LGPL_LIBRARIES = [ | ||
"libavcodec", | ||
"libavdevice", | ||
"libavfilter", | ||
"libavformat", | ||
"libavutil", | ||
"libswresample", | ||
"libswscale", | ||
] | ||
|
||
LGPL_LIBRARY_VERSIONS = { | ||
"libavcodec": [ | ||
"libavcodec.so", | ||
"libavcodec.so.61", | ||
"libavcodec.so.61.3.100", | ||
], | ||
"libavdevice": [ | ||
"libavdevice.so", | ||
"libavdevice.so.61", | ||
"libavdevice.so.61.1.100", | ||
], | ||
"libavfilter": [ | ||
"libavfilter.so", | ||
"libavfilter.so.10", | ||
"libavfilter.so.10.1.100", | ||
], | ||
"libavformat": [ | ||
"libavformat.so", | ||
"libavformat.so.61", | ||
"libavformat.so.61.1.100", | ||
], | ||
"libavutil": [ | ||
"libavutil.so", | ||
"libavutil.so.59", | ||
"libavutil.so.59.8.100", | ||
], | ||
"libswresample": [ | ||
"libswresample.so", | ||
"libswresample.so.5", | ||
"libswresample.so.5.1.100", | ||
], | ||
"libswscale": [ | ||
"libswscale.so", | ||
"libswscale.so.8", | ||
"libswscale.so.8.1.100", | ||
], | ||
} | ||
|
||
filegroup( | ||
name = "all_srcs", | ||
srcs = glob(["**"]), | ||
) | ||
|
||
config_setting( | ||
name = "opt_mode", | ||
values = { | ||
"compilation_mode": "opt", | ||
}, | ||
) | ||
|
||
# NOTE FFmpeg's configure script is not autoconf-based: https://trac.ffmpeg.org/ticket/9310 | ||
# NOTE Bazel always uses the C++ compiler: https://github.com/bazelbuild/bazel/issues/4644 | ||
configure_make( | ||
name = "ffmpeg", | ||
args = [ | ||
"-j4", | ||
], | ||
build_data = [ | ||
"@yasm//:yasm_bin", | ||
], | ||
configure_options = [ | ||
"--cc=$$EXT_BUILD_ROOT/$(CC)", | ||
"--host-cc=$$EXT_BUILD_ROOT/$(CC)", | ||
"--cxx=$$EXT_BUILD_ROOT/$(CC)", | ||
"--host-cflags=\"--sysroot=$$EXT_BUILD_ROOT/external/_main~repositories_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/\"", | ||
"--extra-cflags=\"--sysroot=$$EXT_BUILD_ROOT/external/_main~repositories_ext~com_googleapis_storage_chrome_linux_amd64_sysroot/\"", | ||
"--pkg-config-flags=\"--static\"", | ||
"--enable-pic", # TODO base on global config setting? | ||
"--disable-stripping", # TODO define hermetic executable via --strip= | ||
"--enable-shared", | ||
"--disable-static", | ||
"--x86asmexe=$$EXT_BUILD_ROOT/$(execpath @yasm//:yasm_bin)", | ||
"--enable-version3", | ||
"--enable-libaom", | ||
"--enable-libsvtav1", | ||
"--enable-libvpx", | ||
"--enable-libdav1d", | ||
"--disable-programs", | ||
"--disable-doc", | ||
] + select({ | ||
":opt_mode": ["--disable-debug"], | ||
"//conditions:default": [], | ||
}), | ||
lib_source = ":all_srcs", | ||
out_shared_libs = [so for lib in LGPL_LIBRARIES for so in LGPL_LIBRARY_VERSIONS[lib]], | ||
deps = [ | ||
"@libaom", | ||
"@libsvtav1", | ||
"@libvpx", | ||
"@libdav1d", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
load("@rules_license//rules:license.bzl", "license") | ||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") | ||
|
||
package( | ||
default_applicable_licenses = [":license"], | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
exports_files(["LICENSE"]) | ||
|
||
license( | ||
name = "license", | ||
package_name = "libaom", | ||
license_kinds = [ | ||
"@rules_license//licenses/spdx:BSD-3-Clause", | ||
], | ||
license_text = "LICENSE", | ||
package_url = "https://aomedia.googlesource.com/aom", | ||
) | ||
|
||
filegroup( | ||
name = "all_srcs", | ||
srcs = glob(["**"]), | ||
) | ||
|
||
cmake( | ||
name = "libaom", | ||
build_data = [ | ||
"@yasm//:yasm_bin", | ||
], | ||
cache_entries = { | ||
"BUILD_SHARED_LIBS": "OFF", | ||
"ENABLE_EXAMPLES": "OFF", | ||
"ENABLE_TOOLS": "OFF", | ||
"ENABLE_TESTS": "OFF", | ||
}, | ||
env = { | ||
"CMAKE_BUILD_TYPE": "Release", | ||
"CMAKE_BUILD_PARALLEL_LEVEL": "4", | ||
"PATH": "$$PATH:$$(dirname $(execpath @yasm//:yasm_bin))", | ||
}, | ||
lib_source = ":all_srcs", | ||
out_static_libs = ["libaom.a"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
load("@rules_license//rules:license.bzl", "license") | ||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "meson") | ||
|
||
package( | ||
default_applicable_licenses = [":license"], | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
exports_files(["LICENSE"]) | ||
|
||
license( | ||
name = "license", | ||
package_name = "libdav1d", | ||
license_kinds = [ | ||
"@rules_license//licenses/spdx:BSD-3-Clause-Clear", | ||
], | ||
license_text = "LICENSE", | ||
package_url = "https://code.videolan.org/videolan/dav1d", | ||
) | ||
|
||
filegroup( | ||
name = "all_srcs", | ||
srcs = glob(["**"]), | ||
) | ||
|
||
meson( | ||
name = "libdav1d", | ||
build_data = [ | ||
"@nasm", | ||
], | ||
build_args = [ | ||
"-j4", | ||
], | ||
lib_source = ":all_srcs", | ||
options = { | ||
"enable_tools": "false", | ||
"enable_tests": "false", | ||
}, | ||
env = { | ||
"PATH": "$$PATH:$$(dirname $(execpath @nasm))", | ||
}, | ||
out_lib_dir = "lib64", | ||
#out_shared_libs = ["libdav1d.so", "libdav1d.so.7", "libdav1d.so.7.0.0"], | ||
out_static_libs = ["libdav1d.a"], | ||
setup_args = [ | ||
"--buildtype=release", | ||
"--default-library=static", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
load("@rules_license//rules:license.bzl", "license") | ||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") | ||
|
||
package( | ||
default_applicable_licenses = [":license"], | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
exports_files(["LICENSE"]) | ||
|
||
license( | ||
name = "license", | ||
package_name = "libsvtav1", | ||
license_kinds = [ | ||
"@rules_license//licenses/spdx:BSD-3-Clause-Clear", | ||
], | ||
license_text = "LICENSE", | ||
package_url = "https://gitlab.com/AOMediaCodec/SVT-AV1", | ||
) | ||
|
||
filegroup( | ||
name = "all_srcs", | ||
srcs = glob(["**"]), | ||
) | ||
|
||
cmake( | ||
name = "libsvtav1", | ||
build_data = [ | ||
"@yasm//:yasm_bin", | ||
], | ||
cache_entries = { | ||
"BUILD_SHARED_LIBS": "OFF", | ||
"BUILD_DEC": "OFF", | ||
"BUILD_APPS": "ON", | ||
"BUILD_TESTING": "OFF", | ||
"ENABLE_AVX512": "ON", | ||
}, | ||
env = { | ||
"CMAKE_BUILD_TYPE": "Release", | ||
"CMAKE_BUILD_PARALLEL_LEVEL": "4", | ||
"PATH": "$$PATH:$$(dirname $(execpath @yasm//:yasm_bin))", | ||
}, | ||
lib_source = ":all_srcs", | ||
out_binaries = ["SvtAv1EncApp"], | ||
out_static_libs = ["libSvtAv1Enc.a"], | ||
) |
Oops, something went wrong.