Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call platform.system() once #79

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions scripts/build-ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@

dest_dir = sys.argv[1]
output_dir = os.path.abspath("output")
system = platform.system()
if system == "Linux" and os.environ.get("CIBUILDWHEEL") == "1":

plat = platform.system()

if plat == "Linux" and os.environ.get("CIBUILDWHEEL") == "1":
output_dir = "/output"
output_tarball = os.path.join(output_dir, f"ffmpeg-{get_platform()}.tar.gz")

# FFmpeg has native TLS backends for macOS and Windows
use_gnutls = system == "Linux"
use_gnutls = plat == "Linux"

if not os.path.exists(output_tarball):
builder = Builder(dest_dir=dest_dir)
Expand All @@ -36,7 +38,7 @@
# install packages

available_tools = set()
if system == "Linux" and os.environ.get("CIBUILDWHEEL") == "1":
if plat == "Linux" and os.environ.get("CIBUILDWHEEL") == "1":
with log_group("install packages"):
run(
[
Expand All @@ -50,7 +52,7 @@
]
)
available_tools.update(["gperf"])
elif system == "Windows":
elif plat == "Windows":
available_tools.update(["gperf", "nasm"])

# print tool locations
Expand Down Expand Up @@ -146,7 +148,7 @@
"--with-glib=no",
],
# parallel build fails on Windows
build_parallel=platform.system() != "Windows",
build_parallel=plat != "Windows",
),
]

Expand Down Expand Up @@ -227,7 +229,7 @@
name="opencore-amr",
source_url="http://deb.debian.org/debian/pool/main/o/opencore-amr/opencore-amr_0.1.5.orig.tar.gz",
# parallel build hangs on Windows
build_parallel=platform.system() != "Windows",
build_parallel=plat != "Windows",
),
Package(
name="openjpeg",
Expand Down Expand Up @@ -270,7 +272,7 @@
name="x264",
source_url="https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.bz2",
# parallel build runs out of memory on Windows
build_parallel=platform.system() != "Windows",
build_parallel=plat != "Windows",
),
Package(
name="x265",
Expand Down Expand Up @@ -340,9 +342,7 @@
"--enable-libvpx",
"--enable-libx264",
"--enable-libx265",
"--enable-libxcb"
if platform.system() == "Linux"
else "--disable-libxcb",
"--enable-libxcb" if plat == "Linux" else "--disable-libxcb",
"--enable-libxml2",
"--enable-libxvid",
"--enable-lzma",
Expand All @@ -360,7 +360,7 @@
for package in packages:
builder.build(package)

if system == "Windows" and (build_stage is None or build_stage == 2):
if plat == "Windows" and (build_stage is None or build_stage == 2):
# fix .lib files being installed in the wrong directory
for name in [
"avcodec",
Expand Down Expand Up @@ -394,15 +394,15 @@
shutil.copy(os.path.join(mingw_bindir, name), os.path.join(dest_dir, "bin"))

# find libraries
if system == "Darwin":
if plat == "Darwin":
libraries = glob.glob(os.path.join(dest_dir, "lib", "*.dylib"))
elif system == "Linux":
elif plat == "Linux":
libraries = glob.glob(os.path.join(dest_dir, "lib", "*.so"))
elif system == "Windows":
elif plat == "Windows":
libraries = glob.glob(os.path.join(dest_dir, "bin", "*.dll"))

# strip libraries
if system == "Darwin":
if plat == "Darwin":
run(["strip", "-S"] + libraries)
run(["otool", "-L"] + libraries)
else:
Expand Down
Loading