[vlc-commits] [Git][videolan/vlc][3.0.x] 11 commits: videotoolbox: fix linkage of shared plugins on iOS
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Fri Jun 9 07:39:02 UTC 2023
Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC
Commits:
68f257f6 by Alexandre Janniaux at 2023-06-07T15:10:02+02:00
videotoolbox: fix linkage of shared plugins on iOS
Without the link to UIKit, UIDevice is left missing and leads to link
error.
- - - - -
01cbbf75 by Alexandre Janniaux at 2023-06-07T15:10:19+02:00
video_filter: Makefile.am: fix ci_filters's LDFLAGS
The libci_filter_plugin_la_LDFLAGS must always contains the value of
$(AM_LDFLAGS) since it is at least defined once. Otherwise, automake
won't automatically define it to $(AM_LDFLAGS) $(LDFLAGS) and the plugin
won't be built correctly (ie, built as a convenience library because of
the lack of -rpath definition in LDFLAGS).
In addition, the frameworks were not correctly set for iOS, which was
not a problem in static build because there is no linkage, nor in
dynamic build before because the plugin was built as a convenience
library, thus not linked nor installed to the device with the bundle
script.
Since the frameworks are mostly common between MacOSX and iOS, just add
the corresponding OpenGL framework for each target, and define the other
frameworks out of any automake condition.
Cherry-picked from commit c82c99522446be5f50296721d5716ae604eed426 but
partially modified to remove OpenGL/ES frameworks that are not needed
without the commit cb6b1d5fb6c28893479f737a94da2bc753cbe8b9.
- - - - -
38f89ca3 by Alexandre Janniaux at 2023-06-07T15:10:19+02:00
audio_output: Makefile.am: fix audiounit_ios link
Remove AudioUnit framework as it is not found on iOS and only
AudioToolbox is needed.
In addition CoreServices cannot be linked for the iOS/tvOS targets as it
is available starting with iOS/tvOS 12.0+.
Cherry-picked from commit e69c8fbacd8edc031ed6ada3babab39f367e3e95.
- - - - -
9f6cfa80 by Alexandre Janniaux at 2023-06-07T18:01:37+02:00
codec: Makefile.am: remove AudioUnit for audiotoolboxmidi
AudioUnit framework is not found on iOS and is not needed on MacOSX.
Cherry-picked from commit f68267079d9e9450d290fab486be6e4b825cea33.
Manual change where AudioUnit is still needed in this version of the
plugin for OSX.
- - - - -
4ee99b80 by Alexandre Janniaux at 2023-06-07T18:01:37+02:00
video_output: Makefile.am: fix link for glconv_cvpx on ios
There were no LDFLAGS for iOS/tvOS and vt_utils were not compiled but
linking worked because videotoolbox was linked in the final static
library archive.
Manual backport from commit 1b9a3f4687292d7393c08b72bf879acee487f246
since interop_cvpx doesn't exist in 3.0.x and the code was pretty
different.
- - - - -
850801f9 by Alexandre Janniaux at 2023-06-07T18:01:37+02:00
src: Makefile.am: link CFNetwork on iOS
Fix the following link errors when building for iOS with shared
libraries:
Undefined symbols for architecture arm64:
"_CFNetworkCopySystemProxySettings", referenced from:
_vlc_getProxyUrl in netconf.o
"_kCFNetworkProxiesHTTPPort", referenced from:
_vlc_getProxyUrl in netconf.o
"_kCFNetworkProxiesHTTPProxy", referenced from:
_vlc_getProxyUrl in netconf.o
ld: symbol(s) not found for architecture arm64
- - - - -
9f2ebc0f by Alexandre Janniaux at 2023-06-07T18:01:37+02:00
package: apple: backport build script for iOS
The build script allows building for iOS/tvOS without pulling the whole
VLCKit project, to build a standalone library for integrating libvlc in
applications.
The main goal is being able to maintain libVLC 3.0 without requiring the
whole VLCKit environment to run tests.
Cherry-picked from master branch at commit version
44d44176aaadd4f742a70e9188f6ba578d65fab1, and modified the build.conf to
have all enabled contribs building and have the target version match the
3.0.x system requirements.
- - - - -
85b22197 by Alexandre Janniaux at 2023-06-07T18:01:37+02:00
test: add iosvlc.m for iOS development
iosvlc.m provides a binary usable as an iOS application, forwarding the
VLC arguments just like VLC on desktop. It allows easier iteration on
vlccore development for iOS, without the need to test in a VLCKit
application like VLC for iOS or new external application.
It is currently designed for usage with dynamic plugins.
To develop with it, you must generate a .ipa archive containing both
the resulting binary as executable, a PkgInfo file, an Info.plist file
describing the package and the libs (libvlc.dylib, libvlccore.dylib, and
every plugin .dylib or additional convenience libraries that are not
linked statically in the Frameworks/ directory. It must then be signed
with a developer certificate allowed by Apple and provisionned with a
mobileprovision file allowing installation on the given device for the
same developer certificate.
Then, tools like libimobiledevice can be used to start the application
with additional arguments or environment variables. They can also be
added in XCode through the "Edit Scheme" menu.
A big part of the iOS-specific code has been originally written by
Marvin Scholz in a more complete libVLC ios sample.
Co-authored-by: Marvin Scholz <epirat07 at gmail.com>
Cherry-picked and adapted from commits:
e16f4d9bb6830fd5ad257a60babc0377a3ab39a2
0bfe88030104d2e9c962c24c144ce5c17294f146
96bee41831849597448a2414aa06faa1ee837a38
904998afec0b2d4192e877c19c7e5295bcaf4c67
54c392d7be7f73af6fabcf542c3c2670db00ff1a
- - - - -
068bfba7 by Alexandre Janniaux at 2023-06-07T18:01:37+02:00
bank: add support for browsing frameworks
Darwin platforms are using frameworks to embed libraries. Some of them
like iOS and tvOS even forbid the use of dynamic libraries that are not
wrapped into a framework.
Since frameworks can contain various things (headers, resources, etc),
we don't necessarily want to browse their whole tree if their structure
is well-defined. In our case, since plugins are bundles and not dylibs,
there's not linking and there's no point in supporting versionning so we
can expect the plugin's dynamic library in the root of the framework,
named like the framework without the .framework part.
Since MacOSX can also make use of frameworks, this is enabled for all
darwin platforms, though it might not use them.
Cherry-picked from commit 70d3002be1eaf1b78f1555733d02de4266b7f6ec.
- - - - -
cf1baa09 by Alexandre Janniaux at 2023-06-07T18:01:37+02:00
module: bank: fix typo in framework loading
The arguments to AllocatePluginFile were written in reverse, leading to
vlc_stat failing to find the file. In addition the value that should
have been written `-(sizeof ".framework" -1)` was actually written as
`-sizeof ".framework" -1` and thus `foo_plugin` was instead `foo_plug`.
Typo from function refactor in 70d3002be1eaf1b78f1555733d02de4266b7f6ec.
Cherry-picked from commit eb47c931a06ca8460a3720e4640559e83121bbb7.
- - - - -
370b1ae8 by Alexandre Janniaux at 2023-06-07T18:01:37+02:00
darwin: redirect VLC_PKG_LIB_DIR/plugins on iOS
On iOS and tvOS, dylibs must be wrapped into a framework and frameworks
must be flattened into the frameworks/ application directory (or global
to the system which is not possible in the general case), so dylibs
can't be in the VLC_PKG_LIB_DIR/plugins folder. Redirect
VLC_PKG_LIB_DIR/plugins toward VLC_PKG_LIB_DIR/ on those platforms.
Manual cherry-pick from commit 89e90672db4a10243ae802c32272da8c062bc7bb.
The code is written directly in the src/modules/bank.c code given that
config_GetSysPath doesn't exist in 3.0.
- - - - -
14 changed files:
- + extras/package/apple/Info.plist
- + extras/package/apple/build.conf
- + extras/package/apple/build.sh
- + extras/package/apple/bundle.sh
- + extras/package/macosx/env.build.sh
- modules/audio_output/Makefile.am
- modules/codec/Makefile.am
- modules/video_filter/Makefile.am
- modules/video_output/Makefile.am
- src/Makefile.am
- src/darwin/dirs.c
- src/modules/bank.c
- test/Makefile.am
- + test/iosvlc.m
Changes:
=====================================
extras/package/apple/Info.plist
=====================================
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>BuildMachineOSBuild</key>
+ <string>18E2034</string>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>vlccore</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.videolan.vlccore</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>vlccore</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSupportedPlatforms</key>
+ <array>
+ <string>iPhoneOS</string>
+ </array>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>DTCompiler</key>
+ <string>com.apple.compilers.llvm.clang.1_0</string>
+ <key>DTPlatformBuild</key>
+ <string>17B102</string>
+ <key>DTPlatformName</key>
+ <string>iphoneos</string>
+ <key>DTPlatformVersion</key>
+ <string>13.2</string>
+ <key>DTSDKBuild</key>
+ <string>17B102</string>
+ <key>DTSDKName</key>
+ <string>iphoneos13.2</string>
+ <key>DTXcode</key>
+ <string>1130</string>
+ <key>DTXcodeBuild</key>
+ <string>11C505</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>MinimumOSVersion</key>
+ <string>9.0</string>
+ <key>UIDeviceFamily</key>
+ <array>
+ <integer>1</integer>
+ <integer>2</integer>
+ </array>
+ <key>UIFileSharingEnabled</key>
+ <true/>
+ <key>UILaunchImages</key>
+ <array>
+ <dict>
+ <key>UILaunchImageMinimumOSVersion</key>
+ <string>7.0</string>
+ <key>UILaunchImageName</key>
+ <string>LaunchImage-700-568h</string>
+ <key>UILaunchImageOrientation</key>
+ <string>Portrait</string>
+ <key>UILaunchImageSize</key>
+ <string>{320, 568}</string>
+ </dict>
+ </array>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>arm64</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ </array>
+ <key>UISupportedInterfaceOrientations~ipad</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
=====================================
extras/package/apple/build.conf
=====================================
@@ -0,0 +1,172 @@
+# Copyright (C) Marvin Scholz
+#
+# This is a configuration file with various
+# variables used by the build.sh script.
+#
+# This is just a bash script and sourced in
+# build.sh, so keep that in mind when editing!
+
+#
+# General options
+#
+
+# macOS deployment target
+export VLC_DEPLOYMENT_TARGET_MACOSX="10.9"
+# iOS deployment target
+export VLC_DEPLOYMENT_TARGET_IOS="9.0"
+# tvOS deployment target
+export VLC_DEPLOYMENT_TARGET_TVOS="10.2"
+
+#
+# Contrib options
+#
+
+# Base contrib bootstrap options used on all OSes
+export VLC_CONTRIB_OPTIONS_BASE=(
+ --disable-gpl
+ --disable-all
+ --enable-fribidi
+ --enable-libxml2
+ --enable-libplacebo
+ --enable-soxr
+)
+
+# Additional contrib bootstrap options for macOS
+export VLC_CONTRIB_OPTIONS_MACOSX=(
+ --disable-twolame
+ --disable-microdns
+ --disable-cddb
+)
+
+# Additional contrib bootstrap options for iOS
+export VLC_CONTRIB_OPTIONS_IOS=(
+)
+
+# Additional contrib bootstrap options for tvOS
+export VLC_CONTRIB_OPTIONS_TVOS=(
+)
+
+#
+# VLC options
+#
+
+# Base configure options for VLC
+export VLC_CONFIG_OPTIONS_BASE=(
+ --disable-sse
+ --disable-mmx
+ --disable-a52
+ --disable-vcd
+ --disable-libcddb
+ --disable-macosx
+ --disable-macosx-avfoundation
+ --disable-lua
+ --disable-qt
+ --disable-skins2
+ --disable-vlc
+ --disable-vlm
+ --disable-nls
+ --disable-notify
+ --disable-projectm
+ --disable-goom
+ --disable-dvdread
+ --disable-dvdnav
+ --disable-bluray
+ --disable-linsys
+ --disable-libva
+ --disable-gme
+ --disable-tremor
+ --disable-fluidsynth
+ --disable-jack
+ --disable-pulse
+ --disable-mtp
+ --disable-screen
+ --disable-sparkle
+ --disable-addonmanagermodules
+ --disable-mad
+)
+
+# Additional configure options for macOS
+export VLC_CONFIG_OPTIONS_MACOSX=()
+
+# Additional configure options for iOS
+export VLC_CONFIG_OPTIONS_IOS=()
+
+# Additional configure options for tvOS
+export VLC_CONFIG_OPTIONS_TVOS=()
+
+#
+# VLC module options
+#
+
+# Module removal list
+# Modules on this list are removed after VLC is built
+# and before it is (in case of static modules) archived
+# together to one big static library
+export VLC_MODULE_REMOVAL_LIST_BASE=(
+ stats
+ stream_out_stats
+ shm
+ rc
+ hotkeys
+ gestures
+ dynamicoverlay
+ rss
+ ball
+ magnify
+ audiobargraph_v
+ audiobargraph_a
+ clone
+ mosaic
+ stream_out_mosaic_bridge
+ puzzle
+ t140
+ ripple
+ motiondetect
+ motionblur
+ sharpen
+ grain
+ posterize
+ mirror
+ wall
+ scene
+ blendbench
+ psychedelic
+ alphamask
+ audioscrobbler
+ export
+ smf
+ podcast
+ bluescreen
+ erase
+ speex_resampler
+ magnify
+ gradient
+ visual
+ invert
+ sepia
+ wave
+ hqdn3d
+ headphone_channel_mixer
+ gaussianblur
+ gradfun
+ extract
+ colorthres
+ antiflicker
+ anaglyph
+ remap
+ oldmovie
+ vhs
+ demuxdump
+ fingerprinter
+ access_output_udp
+ access_output_livehttp
+)
+
+# Additional modules to remove for macOS
+export VLC_MODULE_REMOVAL_LIST_MACOSX=()
+
+# Additional modules to remove for iOS
+export VLC_MODULE_REMOVAL_LIST_IOS=()
+
+# Additional modules to remove for tvOS
+export VLC_MODULE_REMOVAL_LIST_TVOS=()
=====================================
extras/package/apple/build.sh
=====================================
@@ -0,0 +1,825 @@
+#!/usr/bin/env bash
+# Copyright (C) Marvin Scholz
+#
+# Script to help build VLC or libVLC for Apple OSes
+# Supported OSes: iOS, tvOS, macOS
+#
+# Currently this script builds a full static library,
+# with all modules and contribs combined into one .a
+# file.
+#
+# Settings that need to be changed from time to time,
+# like the target OS versions or contrib/configure options
+# can be found in the build.conf file in the same folder.
+
+# TODO:
+# - Add packaging support and right options to build a macOS app
+# - Support shared build where you get a dylib for libvlc,
+# libvlccore and dylibs for the individual modules.
+# - Support a mixed shared build where you only have a
+# libvlc.dylib that includes libvlccore and the modules
+# statically.
+# Proposed interface for this:
+# --buildmode=<fullstatic, pseudoshared, shared>
+# fullstatic: One resulting static library with libvlc and modules
+# pseudoshared: Shared library with all modules statically linked
+# shared: Shared libraries and modules
+
+# Dir of this script
+readonly VLC_SCRIPT_DIR="$(cd "${BASH_SOURCE%/*}"; pwd)"
+
+# Verify script run location
+[ ! -f "$(pwd)/../src/libvlc.h" ] \
+ && echo "ERROR: This script must be run from a" \
+ "build subdirectory in the VLC source" >&2 \
+ && exit 1
+
+# Include vlc env script
+. "$VLC_SCRIPT_DIR/../macosx/env.build.sh" "none"
+
+# Include build config file
+. "$VLC_SCRIPT_DIR/build.conf"
+
+##########################################################
+# Global variables #
+##########################################################
+
+# Name of this script
+readonly VLC_SCRIPT_NAME=$(basename "$0")
+# VLC source dir root
+readonly VLC_SRC_DIR="${VLC_SCRIPT_DIR}/../../../"
+# VLC build dir
+readonly VLC_BUILD_DIR=$(pwd)
+# Whether verbose output is enabled or not
+VLC_SCRIPT_VERBOSE=0
+# Architecture of the host (OS that the result will run on)
+VLC_HOST_ARCH="x86_64"
+# Host platform information
+VLC_HOST_PLATFORM=
+VLC_HOST_TRIPLET=
+VLC_BUILD_TRIPLET=
+# Set to "1" when building for simulator
+VLC_HOST_PLATFORM_SIMULATOR=
+# The host OS name (without the simulator suffix)
+# as used by the Apple tools for flags like the
+# min version or clangs target option
+VLC_HOST_OS=
+# Lowest OS version (iOS, tvOS or macOS) to target
+# Do NOT edit this to set a specific target, instead
+# edit the VLC_DEPLOYMENT_TARGET_* variables above.
+VLC_DEPLOYMENT_TARGET=
+# Flags for linker and compiler that set the min target OS
+# Those will be set by the set_deployment_target function
+VLC_DEPLOYMENT_TARGET_LDFLAG=
+VLC_DEPLOYMENT_TARGET_CFLAG=
+# SDK name (optionally with version) to build with
+# We default to macOS builds, so this is set to macosx
+VLC_APPLE_SDK_NAME="macosx"
+# SDK path
+# Set in the validate_sdk_name function
+VLC_APPLE_SDK_PATH=
+# SDK version
+# Set in the validate_sdk_name function
+VLC_APPLE_SDK_VERSION=
+# Indicated if prebuilt contribs package
+# should be created
+VLC_MAKE_PREBUILT_CONTRIBS=0
+# Indicates that prebuit contribs should be
+# used instead of building the contribs from source
+VLC_USE_PREBUILT_CONTRIBS=0
+# User-provided URL from where to fetch contribs, empty
+# for the default chosen by contrib system
+VLC_PREBUILT_CONTRIBS_URL=${VLC_PREBUILT_CONTRIBS_URL:-""}
+# The number of cores to compile on
+CORE_COUNT=$(sysctl -n machdep.cpu.core_count || nproc || echo 0)
+let VLC_USE_NUMBER_OF_CORES=$CORE_COUNT+1
+VLC_REQUESTED_CORE_COUNT=0
+# whether to disable debug mode (the default) or not
+VLC_DISABLE_DEBUG=0
+# whether to compile with bitcode or not
+VLC_USE_BITCODE=0
+VLC_BITCODE_FLAG="-fembed-bitcode"
+# whether to build static or dynamic plugins
+VLC_BUILD_DYNAMIC=0
+
+# Tools to be used
+VLC_HOST_CC="$(xcrun --find clang)"
+VLC_HOST_CPP="$(xcrun --find clang) -E"
+VLC_HOST_CXX="$(xcrun --find clang++)"
+VLC_HOST_OBJC="$(xcrun --find clang)"
+VLC_HOST_LD="$(xcrun --find ld)"
+VLC_HOST_AR="$(xcrun --find ar)"
+VLC_HOST_STRIP="$(xcrun --find strip)"
+VLC_HOST_RANLIB="$(xcrun --find ranlib)"
+VLC_HOST_NM="$(xcrun --find nm)"
+
+##########################################################
+# Helper functions #
+##########################################################
+
+# Print command line usage
+usage()
+{
+ echo "Usage: $VLC_SCRIPT_NAME [options]"
+ echo " --arch=ARCH Architecture to build for"
+ echo " (i386|x86_64|armv7|arm64)"
+ echo " --sdk=SDK Name of the SDK to build with (see 'xcodebuild -showsdks')"
+ echo " --enable-bitcode Enable bitcode for compilation, same as with =full"
+ echo " --enable-bitcode=marker Enable bitcode marker for compilation"
+ echo " --disable-debug Disable libvlc debug mode (for release)"
+ echo " --verbose Print verbose output and disable multi-core use"
+ echo " --help Print this help"
+ echo ""
+ echo "Advanced options:"
+ echo " --package-contribs Create a prebuilt contrib package"
+ echo " --with-prebuilt-contribs Use prebuilt contribs instead of building"
+ echo " them from source"
+ echo " --enable-shared Build dynamic libraries and plugins"
+ echo "Environment variables:"
+ echo " VLC_PREBUILT_CONTRIBS_URL URL to fetch the prebuilt contrib archive"
+ echo " from when --with-prebuilt-contribs is used"
+}
+
+# Print error message and terminate script with status 1
+# Arguments:
+# Message to print
+abort_err()
+{
+ echo "ERROR: $1" >&2
+ exit 1
+}
+
+# Print message if verbose, else silent
+# Globals:
+# VLC_SCRIPT_VERBOSE
+# Arguments:
+# Message to print
+verbose_msg()
+{
+ if [ "$VLC_SCRIPT_VERBOSE" -gt "0" ]; then
+ echo "$1"
+ fi
+}
+
+# Check if tool exists, if not error out
+# Arguments:
+# Tool name to check for
+check_tool()
+{
+ command -v "$1" >/dev/null 2>&1 || {
+ abort_err "This script requires '$1' but it was not found"
+ }
+}
+
+# Set the VLC_DEPLOYMENT_TARGET* flag options correctly
+# Globals:
+# VLC_DEPLOYMENT_TARGET
+# VLC_DEPLOYMENT_TARGET_LDFLAG
+# VLC_DEPLOYMENT_TARGET_CFLAG
+# Arguments:
+# Deployment target version
+set_deployment_target()
+{
+ VLC_DEPLOYMENT_TARGET="$1"
+ VLC_DEPLOYMENT_TARGET_LDFLAG="-Wl,-$VLC_HOST_OS"
+ VLC_DEPLOYMENT_TARGET_CFLAG="-m$VLC_HOST_OS"
+
+ if [ -n "$VLC_HOST_PLATFORM_SIMULATOR" ]; then
+ VLC_DEPLOYMENT_TARGET_LDFLAG="${VLC_DEPLOYMENT_TARGET_LDFLAG}_simulator"
+ VLC_DEPLOYMENT_TARGET_CFLAG="${VLC_DEPLOYMENT_TARGET_CFLAG}-simulator"
+ fi
+
+ VLC_DEPLOYMENT_TARGET_LDFLAG="${VLC_DEPLOYMENT_TARGET_LDFLAG}_version_min,${VLC_DEPLOYMENT_TARGET}"
+ VLC_DEPLOYMENT_TARGET_CFLAG="${VLC_DEPLOYMENT_TARGET_CFLAG}-version-min=${VLC_DEPLOYMENT_TARGET}"
+}
+
+# Validates the architecture and sets VLC_HOST_ARCH
+# This MUST set the arch to what the compiler accepts
+# for the -arch argument!
+# Globals:
+# VLC_HOST_ARCH
+# Arguments:
+# Architecture string
+validate_architecture()
+{
+ case "$1" in
+ i386|x86_64|armv7|arm64)
+ VLC_HOST_ARCH="$1"
+ ;;
+ aarch64)
+ VLC_HOST_ARCH="arm64"
+ ;;
+ *)
+ abort_err "Invalid architecture '$1'"
+ ;;
+ esac
+}
+
+# Set the VLC_HOST_TRIPLET based on the architecture
+# by querying the compiler for it, as the VLC_HOST_ARCH
+# can not be used in the triplet directly, like in
+# case of arm64.
+# Globals:
+# CC
+# VLC_HOST_TRIPLET
+# Arguments:
+# Architecture string
+set_host_triplet()
+{
+ local triplet_arch=$(${VLC_HOST_CC:-cc} -arch "$1" -dumpmachine | cut -d- -f 1)
+ # We can not directly use the compiler value here as when building for
+ # x86_64 iOS Simulator the triplet will match the build machine triplet
+ # exactly, which will cause autoconf to assume we are not cross-compiling.
+ # Therefore we construct a triplet here without a version number, which
+ # will not match the autoconf "guessed" host machine triplet.
+ VLC_HOST_TRIPLET="${triplet_arch}-apple-darwin"
+ VLC_HOST_TRIPLET="${VLC_HOST_TRIPLET/arm64/aarch64}"
+}
+
+# Set the VLC_BUILD_TRIPLET based on the architecture
+# that we run on.
+# Globals:
+# VLC_BUILD_TRIPLET
+# Arguments:
+# None
+set_build_triplet()
+{
+ local build_arch="$(uname -m | cut -d. -f1)"
+ VLC_BUILD_TRIPLET="$(${VLC_HOST_CC} -arch "${build_arch}" -dumpmachine)"
+ VLC_BUILD_TRIPLET="${VLC_BUILD_TRIPLET/arm64/aarch64}"
+}
+
+# Take SDK name, verify it exists and populate
+# VLC_HOST_*, VLC_APPLE_SDK_PATH variables based
+# on the SDK and calls the set_deployment_target
+# function with the rigth target version
+# Globals:
+# VLC_DEPLOYMENT_TARGET_IOS
+# VLC_DEPLOYMENT_TARGET_TVOS
+# VLC_DEPLOYMENT_TARGET_MACOSX
+# Arguments:
+# SDK name
+validate_sdk_name()
+{
+ xcrun --sdk "$1" --show-sdk-path >/dev/null 2>&1 || {
+ abort_err "Failed to find SDK '$1'"
+ }
+
+ VLC_APPLE_SDK_PATH="$(xcrun --sdk "$1" --show-sdk-path)"
+ VLC_APPLE_SDK_VERSION="$(xcrun --sdk "$1" --show-sdk-version)"
+ if [ ! -d "$VLC_APPLE_SDK_PATH" ]; then
+ abort_err "SDK at '$VLC_APPLE_SDK_PATH' does not exist"
+ fi
+
+ case "$1" in
+ iphoneos*)
+ VLC_HOST_PLATFORM="iOS"
+ VLC_HOST_OS="ios"
+ set_deployment_target "$VLC_DEPLOYMENT_TARGET_IOS"
+ ;;
+ iphonesimulator*)
+ VLC_HOST_PLATFORM="iOS-Simulator"
+ VLC_HOST_PLATFORM_SIMULATOR="yes"
+ VLC_HOST_OS="ios"
+ set_deployment_target "$VLC_DEPLOYMENT_TARGET_IOS"
+ ;;
+ appletvos*)
+ VLC_HOST_PLATFORM="tvOS"
+ VLC_HOST_OS="tvos"
+ set_deployment_target "$VLC_DEPLOYMENT_TARGET_TVOS"
+ ;;
+ appletvsimulator*)
+ VLC_HOST_PLATFORM="tvOS-Simulator"
+ VLC_HOST_PLATFORM_SIMULATOR="yes"
+ VLC_HOST_OS="tvos"
+ set_deployment_target "$VLC_DEPLOYMENT_TARGET_TVOS"
+ ;;
+ macosx*)
+ VLC_HOST_PLATFORM="macOS"
+ VLC_HOST_OS="macosx"
+ set_deployment_target "$VLC_DEPLOYMENT_TARGET_MACOSX"
+ ;;
+ watch*)
+ abort_err "Building for watchOS is not supported by this script"
+ ;;
+ *)
+ abort_err "Unhandled SDK name '$1'"
+ ;;
+ esac
+}
+
+# Set env variables used to define compilers and flags
+# Arguments:
+# Additional flags for use with C-like compilers
+# Globals:
+# VLC_DEPLOYMENT_TARGET_CFLAG
+# VLC_DEPLOYMENT_TARGET_LDFLAG
+# VLC_APPLE_SDK_PATH
+# VLC_HOST_ARCH
+set_host_envvars()
+{
+ # Flags to be used for C-like compilers (C, C++, Obj-C)
+ local clike_flags="$VLC_DEPLOYMENT_TARGET_CFLAG -arch $VLC_HOST_ARCH -isysroot $VLC_APPLE_SDK_PATH $1"
+ local bitcode_flag=""
+ if [ "$VLC_USE_BITCODE" -gt "0" ]; then
+ clike_flags+=" $VLC_BITCODE_FLAG"
+ bitcode_flag=" $VLC_BITCODE_FLAG"
+ fi
+
+ export CPPFLAGS="-arch $VLC_HOST_ARCH -isysroot $VLC_APPLE_SDK_PATH"
+
+ export CFLAGS="$clike_flags"
+ export CXXFLAGS="$clike_flags"
+ export OBJCFLAGS="$clike_flags"
+
+ # Vanilla clang doesn't use VLC_DEPLOYMENT_TAGET_LDFLAGS but only the CFLAGS variant
+ export LDFLAGS="$VLC_DEPLOYMENT_TARGET_LDFLAG $VLC_DEPLOYMENT_TARGET_CFLAG -arch $VLC_HOST_ARCH ${bitcode_flag}"
+}
+
+hostenv()
+{
+ CC="${VLC_HOST_CC}" \
+ CPP="${VLC_HOST_CPP}" \
+ CXX="${VLC_HOST_CXX}" \
+ OBJC="${VLC_HOST_OBJC}" \
+ LD="${VLC_HOST_LD}" \
+ AR="${VLC_HOST_AR}" \
+ STRIP="${VLC_HOST_STRIP}" \
+ RANLIB="${VLC_HOST_RANLIB}" \
+ NM="${VLC_HOST_NM}" \
+ "$@"
+}
+
+ac_var_to_export_ac_var()
+{
+ for ac_var in "$@"; do
+ echo "export $ac_var"
+ done
+}
+
+# Write config.mak for contribs
+# Globals:
+# VLC_DEPLOYMENT_TARGET_CFLAG
+# VLC_DEPLOYMENT_TARGET_LDFLAG
+# VLC_APPLE_SDK_PATH
+# VLC_HOST_ARCH
+write_config_mak()
+{
+ # Flags to be used for C-like compilers (C, C++, Obj-C)
+ local clike_flags="$VLC_DEPLOYMENT_TARGET_CFLAG -arch $VLC_HOST_ARCH -isysroot $VLC_APPLE_SDK_PATH $1"
+
+ local vlc_cppflags="-arch $VLC_HOST_ARCH -isysroot $VLC_APPLE_SDK_PATH"
+ local vlc_cflags="$clike_flags"
+ local vlc_cxxflags="$clike_flags"
+ local vlc_objcflags="$clike_flags"
+
+ # Vanilla clang doesn't use VLC_DEPLOYMENT_TAGET_LDFLAGS but only the CFLAGS variant
+ local vlc_ldflags="$VLC_DEPLOYMENT_TARGET_LDFLAG $VLC_DEPLOYMENT_TARGET_CFLAG -arch $VLC_HOST_ARCH"
+
+ echo "Creating makefile..."
+ test -e config.mak && unlink config.mak
+ exec 3>config.mak || return $?
+
+ printf '# This file was automatically generated!\n\n' >&3
+ printf '%s := %s\n' "CPPFLAGS" "${vlc_cppflags}" >&3
+ printf '%s := %s\n' "CFLAGS" "${vlc_cflags}" >&3
+ printf '%s := %s\n' "CXXFLAGS" "${vlc_cxxflags}" >&3
+ printf '%s := %s\n' "OBJCFLAGS" "${vlc_objcflags}" >&3
+ printf '%s := %s\n' "LDFLAGS" "${vlc_ldflags}" >&3
+ printf '%s := %s\n' "CC" "${VLC_HOST_CC}" >&3
+ printf '%s := %s\n' "CPP" "${VLC_HOST_CPP}" >&3
+ printf '%s := %s\n' "CXX" "${VLC_HOST_CXX}" >&3
+ printf '%s := %s\n' "OBJC" "${VLC_HOST_OBJC}" >&3
+ printf '%s := %s\n' "LD" "${VLC_HOST_LD}" >&3
+ printf '%s := %s\n' "AR" "${VLC_HOST_AR}" >&3
+ printf '%s := %s\n' "STRIP" "${VLC_HOST_STRIP}" >&3
+ printf '%s := %s\n' "RANLIB" "${VLC_HOST_RANLIB}" >&3
+ printf '%s := %s\n' "NM" "${VLC_HOST_NM}" >&3
+
+ # Add the ac_cv_ var exports in the config.mak for the contribs
+ echo "Appending ac_cv_ vars to config.mak"
+ vlcSetSymbolEnvironment ac_var_to_export_ac_var >&3
+}
+
+# Generate the source file with the needed array for
+# the static VLC module list. This has to be compiled
+# and linked into the static library
+# Arguments:
+# Path of the output file
+# Array with module entry symbol names
+gen_vlc_static_module_list()
+{
+ local output="$1"
+ shift
+ local symbol_array=( "$@" )
+ touch "$output" || abort_err "Failure creating static module list file"
+
+ local array_list
+ local declarations_list
+
+ for symbol in "${symbol_array[@]}"; do
+ declarations_list+="VLC_ENTRY_FUNC(${symbol});\\n"
+ array_list+=" ${symbol},\\n"
+ done
+
+ printf "\
+#include <stddef.h>\\n\
+#define VLC_ENTRY_FUNC(funcname)\
+int funcname(int (*)(void *, void *, int, ...), void *)\\n\
+%b\\n\
+const void *vlc_static_modules[] = {\\n
+%b
+ NULL\\n
+};" \
+ "$declarations_list" "$array_list" >> "$output" \
+ || abort_err "Failure writing static module list file"
+}
+
+##########################################################
+# Main script logic #
+##########################################################
+
+# Parse arguments
+while [ -n "$1" ]
+do
+ case "$1" in
+ --help|-h)
+ usage
+ exit 0
+ ;;
+ --verbose)
+ VLC_SCRIPT_VERBOSE=1
+ VLC_USE_NUMBER_OF_CORES=1
+ ;;
+ --disable-debug)
+ VLC_DISABLE_DEBUG=1
+ ;;
+ --enable-bitcode|--enable-bitcode=full)
+ VLC_USE_BITCODE=1
+ ;;
+ --enable-bitcode=marker)
+ VLC_USE_BITCODE=1
+ VLC_BITCODE_FLAG="-fembed-bitcode-marker"
+ ;;
+ --arch=*)
+ VLC_HOST_ARCH="${1#--arch=}"
+ ;;
+ --sdk=*)
+ VLC_APPLE_SDK_NAME="${1#--sdk=}"
+ ;;
+ --package-contribs)
+ VLC_MAKE_PREBUILT_CONTRIBS=1
+ ;;
+ --with-prebuilt-contribs)
+ VLC_USE_PREBUILT_CONTRIBS=1
+ ;;
+ --enable-shared)
+ VLC_BUILD_DYNAMIC=1
+ ;;
+ VLC_PREBUILT_CONTRIBS_URL=*)
+ VLC_PREBUILT_CONTRIBS_URL="${1#VLC_PREBUILT_CONTRIBS_URL=}"
+ ;;
+ -j*)
+ VLC_REQUESTED_CORE_COUNT=${1#-j}
+ ;;
+ *)
+ echo >&2 "ERROR: Unrecognized option '$1'"
+ usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+export MAKEFLAGS="-j${VLC_USE_NUMBER_OF_CORES} ${MAKEFLAGS}"
+if [ "${VLC_REQUESTED_CORE_COUNT}" != "0" ]; then
+ export MAKEFLAGS="${MAKEFLAGS} -j${VLC_REQUESTED_CORE_COUNT}"
+fi
+
+# Validate arguments
+if [ "$VLC_MAKE_PREBUILT_CONTRIBS" -gt "0" ] &&
+ [ "$VLC_USE_PREBUILT_CONTRIBS" -gt "0" ]; then
+ echo >&2 "ERROR: The --package-contribs and --with-prebuilt-contribs options"
+ echo >&2 " can not be used together."
+ usage
+ exit 1
+fi
+
+# Check for some required tools before proceeding
+check_tool xcrun
+
+# TODO: Better command to get SDK name if none is set:
+# xcodebuild -sdk $(xcrun --show-sdk-path) -version | awk -F '[()]' '{ print $2; exit; }'
+# Aditionally a lot more is reported by this command, so this needs some more
+# awk parsing or something to get other values with just one query.
+
+# Validate given SDK name
+validate_sdk_name "$VLC_APPLE_SDK_NAME"
+
+# Validate architecture argument
+validate_architecture "$VLC_HOST_ARCH"
+
+# Set triplet (needs to be called after validating the arch)
+set_host_triplet "$VLC_HOST_ARCH"
+set_build_triplet
+
+# Set pseudo-triplet
+# FIXME: This should match the actual clang triplet and should be used for compiler invocation too!
+readonly VLC_PSEUDO_TRIPLET="${VLC_HOST_ARCH}-apple-${VLC_HOST_PLATFORM}_${VLC_DEPLOYMENT_TARGET}"
+# Contrib install dir
+readonly VLC_CONTRIB_INSTALL_DIR="$VLC_BUILD_DIR/contrib/${VLC_HOST_ARCH}-${VLC_APPLE_SDK_NAME}"
+# VLC install dir
+readonly VLC_INSTALL_DIR="$VLC_BUILD_DIR/vlc-${VLC_APPLE_SDK_NAME}-${VLC_HOST_ARCH}"
+
+echo "Build configuration"
+echo " Platform: $VLC_HOST_PLATFORM"
+echo " Architecture: $VLC_HOST_ARCH"
+echo " SDK Version: $VLC_APPLE_SDK_VERSION"
+echo " Number of Cores: $VLC_USE_NUMBER_OF_CORES"
+if [ "$VLC_USE_BITCODE" -gt 0 ]; then
+echo " Bitcode: enabled"
+else
+echo " Bitcode: disabled"
+fi
+echo ""
+
+##########################################################
+# Prepare environment #
+##########################################################
+
+# Set PKG_CONFIG_LIBDIR to an empty string to prevent
+# pkg-config from finding dependencies on the build
+# machine, so that it only finds deps in contribs
+export PKG_CONFIG_LIBDIR=""
+
+# Add extras/tools to path
+export PATH="$VLC_SRC_DIR/extras/tools/build/bin:$PATH"
+
+# Do NOT set SDKROOT, as that is used by various Apple
+# tools and clang and would lead to wrong results!
+# Instead for now we set VLCSDKROOT which is needed
+# to make the contrib script happy.
+# TODO: Actually for macOS the contrib bootstrap script
+# expects SDKROOT to be set, although we can't just do that
+# due to the previously mentioned problem this causes.
+export VLCSDKROOT="$VLC_APPLE_SDK_PATH"
+
+# TODO: Adjust how that is handled in contrib script, to
+# get rid of these env varibles that we need to set
+if [ "$VLC_HOST_OS" = "ios" ]; then
+ export BUILDFORIOS="yes"
+elif [ "$VLC_HOST_OS" = "tvos" ]; then
+ export BUILDFORIOS="yes"
+ export BUILDFORTVOS="yes"
+fi
+
+# Default to "make" if there is no MAKE env variable
+MAKE=${MAKE:-make}
+
+# Attention! Do NOT use just "libtool" here and
+# do NOT use the LIBTOOL env variable as this is
+# expected to be Apple's libtool NOT GNU libtool!
+APPL_LIBTOOL=$(xcrun -f libtool) \
+ || abort_err "Failed to find Apple libtool with xcrun"
+
+##########################################################
+# Extras tools build #
+##########################################################
+
+echo "Building needed tools (if missing)"
+
+cd "$VLC_SRC_DIR/extras/tools" || abort_err "Failed cd to tools dir"
+./bootstrap || abort_err "Bootstrapping tools failed"
+$MAKE || abort_err "Building tools failed"
+if [ $VLC_HOST_ARCH = "armv7" ]; then
+$MAKE .buildgas \
+ || abort_err "Building gas-preprocessor tool failed"
+fi
+echo ""
+
+##########################################################
+# Contribs build #
+##########################################################
+if [ "$VLC_USE_PREBUILT_CONTRIBS" -gt "0" ]; then
+ echo "Fetching prebuilt contribs"
+else
+ echo "Building contribs for $VLC_HOST_ARCH"
+fi
+
+# Combine settings from config file
+VLC_CONTRIB_OPTIONS=( "${VLC_CONTRIB_OPTIONS_BASE[@]}" )
+
+if [ "$VLC_HOST_OS" = "macosx" ]; then
+ VLC_CONTRIB_OPTIONS+=( "${VLC_CONTRIB_OPTIONS_MACOSX[@]}" )
+elif [ "$VLC_HOST_OS" = "ios" ]; then
+ VLC_CONTRIB_OPTIONS+=( "${VLC_CONTRIB_OPTIONS_IOS[@]}" )
+elif [ "$VLC_HOST_OS" = "tvos" ]; then
+ VLC_CONTRIB_OPTIONS+=( "${VLC_CONTRIB_OPTIONS_TVOS[@]}" )
+fi
+
+# Create dir to build contribs in
+cd "$VLC_SRC_DIR/contrib" || abort_err "Failed cd to contrib dir"
+mkdir -p "contrib-$VLC_PSEUDO_TRIPLET"
+cd "contrib-$VLC_PSEUDO_TRIPLET" || abort_err "Failed cd to contrib build dir"
+
+# Create contrib install dir if it does not already exist
+mkdir -p "$VLC_CONTRIB_INSTALL_DIR"
+
+# Write config.mak with flags for the build and compiler overrides
+# Set flag to error on partial availability
+write_config_mak "-Werror=partial-availability"
+
+if [ "$VLC_USE_BITCODE" -gt "0" ]; then
+ VLC_CONTRIB_OPTIONS+=( "--enable-bitcode" )
+fi
+
+# Bootstrap contribs
+../bootstrap \
+ --host="$VLC_HOST_TRIPLET" \
+ --build="$VLC_BUILD_TRIPLET" \
+ --prefix="$VLC_CONTRIB_INSTALL_DIR" \
+ "${VLC_CONTRIB_OPTIONS[@]}" \
+|| abort_err "Bootstrapping contribs failed"
+
+if [ "$VLC_USE_PREBUILT_CONTRIBS" -gt "0" ]; then
+ # Fetch prebuilt contribs
+ if [ -z "$VLC_PREBUILT_CONTRIBS_URL" ]; then
+ $MAKE prebuilt || abort_err "Fetching prebuilt contribs failed"
+ else
+ $MAKE prebuilt PREBUILT_URL="$VLC_PREBUILT_CONTRIBS_URL" \
+ || abort_err "Fetching prebuilt contribs from ${VLC_PREBUILT_CONTRIBS_URL} failed"
+ fi
+else
+ # Print list of contribs that will be built
+ $MAKE list
+
+ # Download source packages
+ $MAKE fetch
+
+ # Build contribs
+ $MAKE || abort_err "Building contribs failed"
+
+ # Make prebuilt contribs package
+ if [ "$VLC_MAKE_PREBUILT_CONTRIBS" -gt "0" ]; then
+ $MAKE package || abort_err "Creating prebuilt contribs package failed"
+ fi
+fi
+
+echo ""
+
+##########################################################
+# VLC build #
+##########################################################
+
+echo "Building VLC for $VLC_HOST_ARCH"
+
+# Set flags for VLC build
+set_host_envvars "-g"
+
+# Combine settings from config file
+VLC_CONFIG_OPTIONS=( "${VLC_CONFIG_OPTIONS_BASE[@]}" )
+
+if [ "$VLC_HOST_OS" = "macosx" ]; then
+ VLC_CONFIG_OPTIONS+=( "${VLC_CONFIG_OPTIONS_MACOSX[@]}" )
+elif [ "$VLC_HOST_OS" = "ios" ]; then
+ VLC_CONFIG_OPTIONS+=( "${VLC_CONFIG_OPTIONS_IOS[@]}" )
+elif [ "$VLC_HOST_OS" = "tvos" ]; then
+ VLC_CONFIG_OPTIONS+=( "${VLC_CONFIG_OPTIONS_TVOS[@]}" )
+fi
+
+if [ "$VLC_DISABLE_DEBUG" -eq "0" ]; then
+ VLC_CONFIG_OPTIONS+=( "--enable-debug" )
+fi
+
+if [ "$VLC_BUILD_DYNAMIC" -gt "0" ]; then
+ VLC_CONFIG_OPTIONS+=( "--enable-shared" )
+else
+ VLC_CONFIG_OPTIONS+=( "--disable-shared" "--enable-static" )
+fi
+
+# Bootstrap VLC
+cd "$VLC_SRC_DIR" || abort_err "Failed cd to VLC source dir"
+if ! [ -e configure ]; then
+ echo "Bootstraping vlc"
+ ./bootstrap
+fi
+
+# Build
+mkdir -p "${VLC_BUILD_DIR}/build"
+cd "${VLC_BUILD_DIR}/build" || abort_err "Failed cd to VLC build dir"
+
+# Create VLC install dir if it does not already exist
+mkdir -p "$VLC_INSTALL_DIR"
+
+vlcSetSymbolEnvironment \
+hostenv ../../configure \
+ --with-contrib="$VLC_CONTRIB_INSTALL_DIR" \
+ --host="$VLC_HOST_TRIPLET" \
+ --build="$VLC_BUILD_TRIPLET" \
+ --prefix="$VLC_INSTALL_DIR" \
+ "${VLC_CONFIG_OPTIONS[@]}" \
+ || abort_err "Configuring VLC failed"
+
+$MAKE || abort_err "Building VLC failed"
+
+$MAKE install || abort_err "Installing VLC failed"
+
+echo ""
+# Shortcut the build of the static bundle when using the dynamic loader
+if [ "$VLC_BUILD_DYNAMIC" -gt "0" ]; then
+ echo "Build succeeded!"
+ exit 0
+fi
+
+##########################################################
+# Remove unused modules #
+##########################################################
+
+echo "Removing modules that are on the removal list"
+
+# Combine settings from config file
+VLC_MODULE_REMOVAL_LIST=( "${VLC_MODULE_REMOVAL_LIST_BASE[@]}" )
+
+if [ "$VLC_HOST_OS" = "macosx" ]; then
+ VLC_MODULE_REMOVAL_LIST+=( "${VLC_MODULE_REMOVAL_LIST_MACOSX[@]}" )
+elif [ "$VLC_HOST_OS" = "ios" ]; then
+ VLC_MODULE_REMOVAL_LIST+=( "${VLC_MODULE_REMOVAL_LIST_IOS[@]}" )
+elif [ "$VLC_HOST_OS" = "tvos" ]; then
+ VLC_MODULE_REMOVAL_LIST+=( "${VLC_MODULE_REMOVAL_LIST_TVOS[@]}" )
+fi
+
+for module in "${VLC_MODULE_REMOVAL_LIST[@]}"; do
+ find "$VLC_INSTALL_DIR/lib/vlc/plugins" \
+ -name "lib${module}_plugin.a" \
+ -type f \
+ -exec rm '{}' \;
+done
+
+echo ""
+
+##########################################################
+# Compile object with static module list #
+##########################################################
+
+echo "Compile VLC static modules list object"
+
+mkdir -p "${VLC_BUILD_DIR}/static-lib"
+cd "${VLC_BUILD_DIR}/static-lib" \
+ || abort_err "Failed cd to VLC static-lib build dir"
+
+# Collect paths of all static libraries needed (plugins and contribs)
+VLC_STATIC_FILELIST_NAME="static-libs-list"
+rm -f "$VLC_STATIC_FILELIST_NAME"
+touch "$VLC_STATIC_FILELIST_NAME"
+
+VLC_PLUGINS_SYMBOL_LIST=()
+
+# Find all static plugins in build dir
+while IFS= read -r -d $'\0' plugin_path; do
+ # Get module entry point symbol name (_vlc_entry__MODULEFULLNAME)
+ nm_symbol_output=( $(${VLC_HOST_NM} "$plugin_path" | grep _vlc_entry__) ) \
+ || abort_err "Failed to find module entry function in '$plugin_path'"
+
+ symbol_name="${nm_symbol_output[2]:1}"
+ VLC_PLUGINS_SYMBOL_LIST+=( "$symbol_name" )
+
+ echo "$plugin_path" >> "$VLC_STATIC_FILELIST_NAME"
+
+done < <(find "$VLC_INSTALL_DIR/lib/vlc/plugins" -name "*.a" -print0)
+
+# Generate code with module list
+VLC_STATIC_MODULELIST_NAME="static-module-list"
+rm -f "${VLC_STATIC_MODULELIST_NAME}.c" "${VLC_STATIC_MODULELIST_NAME}.o"
+gen_vlc_static_module_list "${VLC_STATIC_MODULELIST_NAME}.c" "${VLC_PLUGINS_SYMBOL_LIST[@]}"
+
+${VLC_HOST_CC:-cc} -c ${CFLAGS} "${VLC_STATIC_MODULELIST_NAME}.c" \
+ || abort_err "Compiling module list file failed"
+
+echo "${VLC_BUILD_DIR}/static-lib/${VLC_STATIC_MODULELIST_NAME}.o" \
+ >> "$VLC_STATIC_FILELIST_NAME"
+
+echo ""
+
+##########################################################
+# Link together full static library #
+##########################################################
+
+echo "Linking VLC modules and contribs statically"
+
+echo "$VLC_INSTALL_DIR/lib/libvlc.a" >> "$VLC_STATIC_FILELIST_NAME"
+echo "$VLC_INSTALL_DIR/lib/libvlccore.a" >> "$VLC_STATIC_FILELIST_NAME"
+echo "$VLC_INSTALL_DIR/lib/vlc/libcompat.a" >> "$VLC_STATIC_FILELIST_NAME"
+
+# Find all static contribs in build dir
+find "$VLC_CONTRIB_INSTALL_DIR/lib" -name '*.a' -print >> "$VLC_STATIC_FILELIST_NAME" \
+ || abort_err "Failed finding installed static contribs in '$VLC_CONTRIB_INSTALL_DIR/lib'"
+
+# Link static libs together using libtool
+$APPL_LIBTOOL -static \
+ -no_warning_for_no_symbols \
+ -filelist "$VLC_STATIC_FILELIST_NAME" \
+ -o "libvlc-full-static.a" \
+ || abort_err "Failed running Apple libtool to combine static libraries together"
+
+echo ""
+echo "Build succeeded!"
=====================================
extras/package/apple/bundle.sh
=====================================
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+
+set -eu
+
+readonly SCRIPT_DIR="$(cd "${BASH_SOURCE%/*}"; pwd)"
+readonly BUILD_DIR="$(cd "$1"; pwd)"
+readonly APP_NAME="$2"
+readonly APP_EXECUTABLE="${3:-${APP_NAME}}"
+readonly APP="Payload/${APP_NAME}.app"
+readonly IPA="${APP_NAME}_unsigned.ipa"
+
+# CONVERT_PLIST <input file> <output file>
+# Convert a plist file into binary1 format in order to put it
+# into an Apple bundle.
+CONVERT_PLIST()
+{
+ INPUT=$1
+ OUTPUT=$2
+ if [ which plutil > /dev/null 2>&1 ]; then
+ plutil -convert binary1 -o "$OUTPUT" -- "$INPUT"
+ else
+ plistutil -o "$OUTPUT" -i "$INPUT"
+ fi
+}
+
+# Cleanup previous archive
+rm -f "$IPA"
+rm -rf "Payload/"
+mkdir -p "$APP"
+
+# VLC core test binary compiled for iOS
+cp "${BUILD_DIR}/test/${APP_EXECUTABLE}" "${APP}/${APP_NAME}"
+
+# Convert Info.plist from XML to binary
+CONVERT_PLIST "${SCRIPT_DIR}/Info.plist" "Payload/vlccore.app/Info.plist"
+
+# Set the bundle type
+echo "APPL????" > "$APP/PkgInfo"
+
+# Copy the dylib into the bundle, in Frameworks/. In order to ship on the
+# AppStore, each dylib should be bundled into a framework inside the
+# Frameworks/ directory, but since it is only designed for development usage
+# we can just put them there without further processing.
+mkdir -p "$APP/Frameworks"
+if [ -f "${BUILD_DIR}/lib/.libs/libvlc.dylib" ]; then
+cp "${BUILD_DIR}/lib/.libs/libvlc.dylib" "$APP/Frameworks"
+cp "${BUILD_DIR}/src/.libs/libvlccore.dylib" "$APP/Frameworks"
+find "${BUILD_DIR}/modules/.libs/" -name "*.dylib" -exec cp {} "$APP/Frameworks" \;
+fi
+
+# Archive the bundle into a .ipa file.
+zip -r "$IPA" Payload
=====================================
extras/package/macosx/env.build.sh
=====================================
@@ -0,0 +1,222 @@
+#!/bin/bash
+
+HOST_ARCH="x86_64"
+BUILD_ARCH=`uname -m | cut -d. -f1`
+MINIMAL_OSX_VERSION="10.11"
+
+get_actual_arch() {
+ if [ "$1" = "aarch64" ]; then
+ echo "arm64"
+ else
+ echo "$1"
+ fi
+}
+
+get_buildsystem_arch() {
+ if [ "$1" = "arm64" ]; then
+ echo "aarch64"
+ else
+ echo "$1"
+ fi
+}
+
+vlcGetOSXKernelVersion() {
+ local OSX_KERNELVERSION=$(uname -r | cut -d. -f1)
+ if [ ! -z "$VLC_FORCE_KERNELVERSION" ]; then
+ OSX_KERNELVERSION="$VLC_FORCE_KERNELVERSION"
+ fi
+
+ echo "$OSX_KERNELVERSION"
+}
+
+vlcGetBuildTriplet() {
+ echo "$BUILD_ARCH-apple-darwin$(vlcGetOSXKernelVersion)"
+}
+
+vlcGetHostTriplet() {
+ echo "$HOST_ARCH-apple-darwin$(vlcGetOSXKernelVersion)"
+}
+
+# Gets VLCs root dir based on location of this file, also follow symlinks
+vlcGetRootDir() {
+ local SOURCE="${BASH_SOURCE[0]}"
+ while [ -h "$SOURCE" ]; do
+ local DIR="$(cd -P "$( dirname "$SOURCE" )" && pwd)"
+ SOURCE="$(readlink "$SOURCE")"
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # Relative symlink needs dir prepended
+ done
+ echo "$(cd -P "$(dirname "$SOURCE")/../../../" && pwd)"
+}
+
+# If VLC_CCACHE_BINS_PATH is set, it is assumed it contains
+# clang and clang++ symlinks to the ccache binary which will
+# then act as a compiler wrapper
+vlcSetBaseEnvironment() {
+ local LOCAL_BUILD_TRIPLET="$BUILD_TRIPLET"
+ if [ -z "$LOCAL_BUILD_TRIPLET" ]; then
+ LOCAL_BUILD_TRIPLET="$(vlcGetBuildTriplet)"
+ fi
+
+ local VLC_ROOT_DIR="$(vlcGetRootDir)"
+
+ echo "Setting base environment"
+ echo "Using VLC root dir $VLC_ROOT_DIR, build triplet $LOCAL_BUILD_TRIPLET and host triplet $(vlcGetHostTriplet)"
+
+ export AR="$(xcrun --find ar)"
+ export CC="$(xcrun --find clang)"
+ export CXX="$(xcrun --find clang++)"
+ export NM="$(xcrun --find nm)"
+ export OBJC="$(xcrun --find clang)"
+ export OBJCXX="$(xcrun --find clang++)"
+ export RANLIB="$(xcrun --find ranlib)"
+ export STRIP="$(xcrun --find strip)"
+
+ if [ -n "${VLC_CCACHE_BINS_PATH}" ]; then
+ if [ -d "${VLC_CCACHE_BINS_PATH}" ]; then
+ echo "Using ccache compiler wrappers in '${VLC_CCACHE_BINS_PATH}'"
+ export CC="${VLC_CCACHE_BINS_PATH}/cc"
+ export CXX="${VLC_CCACHE_BINS_PATH}/c++"
+ export OBJC="${VLC_CCACHE_BINS_PATH}/cc"
+ export OBJCXX="${VLC_CCACHE_BINS_PATH}/c++"
+ else
+ echo "Invalid VLC_CCACHE_BINS_PATH given, directory not found: '${VLC_CCACHE_BINS_PATH}'"
+ echo "Proceeding without ccache wrappers"
+ fi
+ fi
+
+ python3Path=$(echo /Library/Frameworks/Python.framework/Versions/3.*/bin | awk '{print $1;}')
+ if [ ! -d "$python3Path" ]; then
+ python3Path=""
+ fi
+
+ export PATH="${VLC_ROOT_DIR}/extras/tools/build/bin:${VLC_ROOT_DIR}/contrib/${LOCAL_BUILD_TRIPLET}/bin:$python3Path:${VLC_PATH}:/bin:/sbin:/usr/bin:/usr/sbin"
+}
+
+vlcSetSymbolEnvironment() {
+ # If the command is called without argument, default to exporting
+ # all the ac_cv_* symbols to the environment. Else we'll pass the
+ # symbol values to the command in the first argument, after the
+ # command's arguments.
+ #
+ # It's typically made to work with cmd="configure" to write the
+ # configuration into the config.status script or cmd="echo" to
+ # write the variables into a config.mak file for the contribs.
+ local cmd="${1:-export}"; [ "$#" -ge 1 ] && shift
+
+ # The following symbols do not exist on the minimal macOS / iOS, so they are disabled
+ # here. This allows compilation also with newer macOS SDKs.
+ # List assumes macOS 10.10 / iOS 8 at minimum.
+
+ # - Added symbols in macOS 10.12 / iOS 10 / watchOS 3
+ # - Added symbols in macOS 10.13 / iOS 11 / watchOS 4 / tvOS 11
+ # - Added symbol in macOS 10.14 / iOS 12 / tvOS 9
+ # - Added symbols in macOS 10.15 / iOS 13 / tvOS 13
+ "${cmd}" "$@" \
+ \
+ ac_cv_func_basename_r=no \
+ ac_cv_func_clock_getres=no \
+ ac_cv_func_clock_gettime=no \
+ ac_cv_func_clock_settime=no \
+ ac_cv_func_dirname_r=no \
+ ac_cv_func_getentropy=no \
+ ac_cv_func_mkostemp=no \
+ ac_cv_func_mkostemps=no \
+ ac_cv_func_timingsafe_bcmp=no \
+ \
+ ac_cv_func_open_wmemstream=no \
+ ac_cv_func_fmemopen=no \
+ ac_cv_func_open_memstream=no \
+ ac_cv_func_futimens=no \
+ ac_cv_func_utimensat=no \
+ \
+ ac_cv_func_thread_get_register_pointer_values=no \
+ \
+ ac_cv_func_aligned_alloc=no \
+ ac_cv_func_timespec_get=no
+}
+
+vlcSetContribEnvironment() {
+ if [ -z "$1" ]; then
+ return 1
+ fi
+ local MINIMAL_OSX_VERSION="$1"
+
+ if [ -z "$SDKROOT" ]; then
+ export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
+ fi
+
+ echo "Setting contrib environment with minimum macOS version $MINIMAL_OSX_VERSION and SDK $SDKROOT"
+
+ # Usually, VLCs contrib libraries do not support partial availability at runtime.
+ # Forcing those errors has two reasons:
+ # - Some custom configure scripts include the right header for testing availability.
+ # Those configure checks fail (correctly) with those errors, and replacements are
+ # enabled. (e.g. ffmpeg)
+ # - This will fail the build if a partially available symbol is added later on
+ # in contribs and not mentioned in the list of symbols above.
+ export CFLAGS="-Werror=partial-availability"
+ export CXXFLAGS="-Werror=partial-availability"
+ export OBJCFLAGS="-Werror=partial-availability"
+
+ export EXTRA_CFLAGS="-isysroot $SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -DMACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -arch $ACTUAL_HOST_ARCH"
+ export EXTRA_LDFLAGS="-isysroot $SDKROOT -mmacosx-version-min=$MINIMAL_OSX_VERSION -DMACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -arch $ACTUAL_HOST_ARCH"
+ export XCODE_FLAGS="MACOSX_DEPLOYMENT_TARGET=$MINIMAL_OSX_VERSION -sdk $SDKROOT WARNING_CFLAGS=-Werror=partial-availability"
+}
+
+vlcUnsetContribEnvironment() {
+ echo "Unsetting contrib flags"
+
+ unset CFLAGS
+ unset CXXFLAGS
+ unset OBJCFLAGS
+
+ unset EXTRA_CFLAGS
+ unset EXTRA_LDFLAGS
+ unset XCODE_FLAGS
+}
+
+vlcSetLibVLCEnvironment() {
+ echo "Setting libVLC flags"
+
+ # Enable debug symbols by default
+ export CFLAGS="-g -arch $ACTUAL_HOST_ARCH"
+ export CXXFLAGS="-g -arch $ACTUAL_HOST_ARCH"
+ export OBJCFLAGS="-g -arch $ACTUAL_HOST_ARCH"
+ export LDFLAGS="-arch $ACTUAL_HOST_ARCH"
+}
+
+vlcUnsetLibVLCEnvironment() {
+ echo "Unsetting libVLC flags"
+
+ unset CFLAGS
+ unset CXXFLAGS
+ unset OBJCFLAGS
+ unset LDFLAGS
+}
+
+# Parameter handling
+
+
+# First parameter: mode to use this script:
+# vlc (default): auto-setup environment suitable for building vlc itself
+# contrib: auto-setup environment suitable for building vlc contribs
+# none: do not perform any auto-setup (used for scripts)
+VLC_ENV_MODE="vlc"
+if [ "$1" = "contrib" ]; then
+ VLC_ENV_MODE="contrib"
+fi
+if [ "$1" = "none" ]; then
+ VLC_ENV_MODE="none"
+fi
+
+if [ "$VLC_ENV_MODE" = "contrib" ]; then
+ vlcSetBaseEnvironment
+ vlcSetSymbolEnvironment
+ vlcUnsetLibVLCEnvironment
+ vlcSetContribEnvironment "$MINIMAL_OSX_VERSION"
+elif [ "$VLC_ENV_MODE" = "vlc" ]; then
+ vlcSetBaseEnvironment
+ vlcSetSymbolEnvironment
+ vlcUnsetContribEnvironment
+ vlcSetLibVLCEnvironment
+fi
=====================================
modules/audio_output/Makefile.am
=====================================
@@ -110,7 +110,7 @@ endif
libaudiounit_ios_plugin_la_SOURCES = audio_output/audiounit_ios.m \
audio_output/coreaudio_common.c audio_output/coreaudio_common.h
libaudiounit_ios_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(aoutdir)' \
- -Wl,-framework,CoreAudio,-framework,AudioUnit,-framework,AudioToolbox,-framework,CoreServices,-framework,UIKit,-framework,AVFoundation
+ -Wl,-framework,Foundation,-framework,CoreAudio,-framework,AudioToolbox,-framework,UIKit,-framework,AVFoundation
if HAVE_IOS
aout_LTLIBRARIES += libaudiounit_ios_plugin.la
endif
=====================================
modules/codec/Makefile.am
=====================================
@@ -62,7 +62,10 @@ endif
libaudiotoolboxmidi_plugin_la_SOURCES = codec/audiotoolbox_midi.c
libaudiotoolboxmidi_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)'
-libaudiotoolboxmidi_plugin_la_LDFLAGS += -Wl,-framework,CoreFoundation,-framework,AudioUnit,-framework,AudioToolbox
+libaudiotoolboxmidi_plugin_la_LDFLAGS += -Wl,-framework,CoreFoundation,-framework,AudioToolbox
+if HAVE_OSX
+libaudiotoolboxmidi_plugin_la_LDFLAGS += -Wl,-framework,AudioUnit
+endif
EXTRA_LTLIBRARIES += libaudiotoolboxmidi_plugin.la
codec_LTLIBRARIES += $(LTLIBaudiotoolboxmidi)
@@ -347,17 +350,19 @@ libvideotoolbox_plugin_la_SOURCES = \
packetizer/h264_slice.c packetizer/h264_slice.h \
packetizer/h264_nal.c packetizer/h264_nal.h \
packetizer/hevc_nal.c packetizer/hevc_nal.h
+libvideotoolbox_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)' -Wl,-framework,Foundation -Wl,-framework,VideoToolbox -Wl,-framework,CoreMedia -Wl,-framework,CoreVideo
if HAVE_OSX
libvideotoolbox_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -mmacosx-version-min=10.8
endif
if HAVE_IOS
libvideotoolbox_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -miphoneos-version-min=8.0
+libvideotoolbox_plugin_la_LDFLAGS += -Wl,-framework,UIKit
endif
if HAVE_TVOS
libvideotoolbox_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -mtvos-version-min=10.2
+libvideotoolbox_plugin_la_LDFLAGS += -Wl,-framework,UIKit
endif
libvideotoolbox_plugin_la_LIBADD = libchroma_copy.la
-libvideotoolbox_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)' -Wl,-framework,Foundation -Wl,-framework,VideoToolbox -Wl,-framework,CoreMedia -Wl,-framework,CoreVideo
EXTRA_LTLIBRARIES += libvideotoolbox_plugin.la
codec_LTLIBRARIES += $(LTLIBvideotoolbox)
=====================================
modules/video_filter/Makefile.am
=====================================
@@ -109,9 +109,10 @@ video_filter_LTLIBRARIES = \
# macOS / iOS hardware video filters
libci_filters_plugin_la_SOURCES = video_filter/ci_filters.m codec/vt_utils.c codec/vt_utils.h
-if HAVE_OSX
libci_filters_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(video_filterdir)' \
- -Wl,-framework,Foundation -Wl,-framework,CoreGraphics -Wl,-framework,CoreImage -Wl,-framework,CoreVideo
+ -Wl,-framework,Foundation -Wl,-framework,CoreGraphics -Wl,-framework,CoreImage \
+ -Wl,-framework,CoreVideo
+if HAVE_OSX
video_filter_LTLIBRARIES += libci_filters_plugin.la
endif
=====================================
modules/video_output/Makefile.am
=====================================
@@ -20,7 +20,10 @@ endif
libglconv_cvpx_plugin_la_SOURCES = video_output/opengl/converter_cvpx.c \
video_output/opengl/converter.h
+libglconv_cvpx_plugin_la_SOURCES += codec/vt_utils.c codec/vt_utils.h
libglconv_cvpx_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)'
+libglconv_cvpx_plugin_la_LDFLAGS += -Wl,-framework,IOSurface \
+ -Wl,-framework,Foundation,-framework,CoreVideo
if HAVE_OSX
libvout_macosx_plugin_la_SOURCES = video_output/macosx.m $(OPENGL_COMMONSOURCES)
@@ -35,21 +38,23 @@ libcaopengllayer_plugin_la_LIBADD = $(OPENGL_COMMONLIBS)
libcaopengllayer_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)' \
-Wl,-framework,OpenGL,-framework,Cocoa,-framework,QuartzCore
-libglconv_cvpx_plugin_la_SOURCES += codec/vt_utils.c codec/vt_utils.h
-libglconv_cvpx_plugin_la_LDFLAGS += -Wl,-framework,IOSurface \
- -Wl,-framework,Foundation,-framework,CoreVideo,-framework,OpenGL
vout_LTLIBRARIES += libvout_macosx_plugin.la libcaopengllayer_plugin.la \
libglconv_cvpx_plugin.la
endif
-if HAVE_IOS
+if HAVE_OSX
+libglconv_cvpx_plugin_la_CFLAGS = $(AM_CFLAGS)
+libglconv_cvpx_plugin_la_LDFLAGS += -Wl,-framework,OpenGL
+else
libglconv_cvpx_plugin_la_CFLAGS = $(AM_CFLAGS) -DUSE_OPENGL_ES2
+libglconv_cvpx_plugin_la_LDFLAGS += -Wl,-framework,OpenGLES
endif
libvout_ios_plugin_la_SOURCES = video_output/ios.m $(OPENGL_COMMONSOURCES)
libvout_ios_plugin_la_CFLAGS = $(AM_CFLAGS) $(OPENGL_COMMONCLFAGS) -DUSE_OPENGL_ES2
libvout_ios_plugin_la_LIBADD = $(OPENGL_COMMONLIBS)
libvout_ios_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)' \
- -Wl,-framework,OpenGLES,-framework,QuartzCore,-framework,UIKit
+ -Wl,-framework,OpenGLES,-framework,QuartzCore,-framework,UIKit \
+ -Wl,-framework,Foundation
if HAVE_IOS
vout_LTLIBRARIES += libvout_ios_plugin.la libglconv_cvpx_plugin.la
endif
=====================================
src/Makefile.am
=====================================
@@ -481,6 +481,9 @@ libvlccore_la_LIBADD += $(DBUS_LIBS)
endif
if HAVE_DARWIN
libvlccore_la_LDFLAGS += -Xlinker -install_name -Xlinker @rpath/libvlccore.dylib
+if !HAVE_OSX
+libvlccore_la_LDFLAGS += -Wl,-framework,CFNetwork
+endif
endif
libvlc_win32_rc.$(OBJEXT): libvlc_win32_rc.rc $(top_srcdir)/extras/package/win32/libvlc.dll.manifest
=====================================
src/darwin/dirs.c
=====================================
@@ -36,6 +36,7 @@
#include <mach-o/dyld.h>
#include <CoreFoundation/CoreFoundation.h>
+#include <TargetConditionals.h>
char *config_GetLibDir (void)
{
=====================================
src/modules/bank.c
=====================================
@@ -49,6 +49,10 @@
#include "config/configuration.h"
#include "modules/modules.h"
+#ifdef __APPLE__
+#include <TargetConditionals.h>
+#endif
+
typedef struct vlc_modcap
{
char *name;
@@ -314,6 +318,56 @@ static int AllocatePluginFile (module_bank_t *bank, const char *abspath,
return 0;
}
+#ifdef __APPLE__
+/* Apple specific framework library browsing */
+
+static int AllocatePluginFramework (module_bank_t *bank, const char *file,
+ const char *relpath, const char *abspath)
+{
+ int i_ret = VLC_EGENERIC;
+ size_t len_name = strlen (file);
+
+ /* Skip frameworks not matching plugins naming conventions. */
+ if (len_name < strlen("_plugin.framework")
+ || strncmp(file + len_name - strlen("_plugin.framework"),
+ "_plugin", strlen("_plugin")) != 0)
+ {
+ /* The framework doesn't contain plugins, there's no need to
+ * browse the rest of the framework folder. */
+ return VLC_EGENERIC;
+ }
+
+ /* The framework is a plugin, extract the dylib from it. */
+ int filename_len = len_name - strlen(".framework");
+
+ char *framework_relpath = NULL, *framework_abspath = NULL;
+ /* Compute absolute path */
+ if (asprintf (&framework_abspath, "%s"DIR_SEP"%.*s",
+ abspath, filename_len, file) == -1)
+ {
+ framework_abspath = NULL;
+ goto end;
+ }
+
+ struct stat framework_st;
+ if (vlc_stat (framework_abspath, &framework_st) == -1
+ || !S_ISREG (framework_st.st_mode))
+ goto end;
+
+ if (asprintf (&framework_relpath, "%s"DIR_SEP"%.*s",
+ relpath, filename_len, file) == -1)
+ framework_relpath = NULL;
+
+ i_ret = AllocatePluginFile (bank, framework_abspath, framework_relpath, &framework_st);
+
+end:
+ free(framework_relpath);
+ free(framework_abspath);
+ return i_ret;
+}
+#endif
+
+
/**
* Recursively browses a directory to look for plug-ins.
*/
@@ -382,8 +436,24 @@ static void AllocatePluginDir (module_bank_t *bank, unsigned maxdepth,
AllocatePluginFile (bank, abspath, relpath, &st);
}
else if (S_ISDIR (st.st_mode))
+ {
+#ifdef __APPLE__
+ size_t len_name = strlen (file);
+ const char *framework_extension =
+ file + len_name - strlen(".framework");
+
+ if (len_name > strlen(".framework")
+ && strcmp(framework_extension, ".framework") == 0)
+ {
+ AllocatePluginFramework (bank, file, relpath, abspath);
+ /* Don't browse framework directories. */
+ goto skip;
+ }
+#endif
+
/* Recurse into another directory */
AllocatePluginDir (bank, maxdepth, abspath, relpath);
+ }
skip:
free (relpath);
free (abspath);
@@ -459,6 +529,11 @@ static void AllocateAllPlugins (vlc_object_t *p_this)
#if VLC_WINSTORE_APP
/* Windows Store Apps can not load external plugins with absolute paths. */
AllocatePluginPath (p_this, "plugins", mode);
+#elif defined(__APPLE__) && defined(HAVE_DYNAMIC_PLUGINS) && TARGET_OS_IPHONE
+ /* Redirect to the application folder, plugins/ is flattened. */
+ char *vlcpath = config_GetLibDir ();
+ AllocatePluginPath (p_this, vlcpath, mode);
+ free(vlcpath);
#else
/* Contruct the special search path for system that have a relocatable
* executable. Set it to <vlc path>/plugins. */
=====================================
test/Makefile.am
=====================================
@@ -250,3 +250,14 @@ vlc_demux_dec_libfuzzer_LDADD = libvlc_demux_dec_run.la
if HAVE_LIBFUZZER
noinst_PROGRAMS += vlc-demux-libfuzzer vlc-demux-dec-libfuzzer vlc-demux-run vlc-demux-dec-run
endif
+
+vlccoreios_SOURCES = iosvlc.m
+vlccoreios_LDFLAGS = $(LDFLAGS_vlc) -Wl,-framework,Foundation,-framework,UIKit
+vlccoreios_LDFLAGS += -Xlinker -rpath -Xlinker "@executable_path/Frameworks/"
+vlccoreios_OBJCFLAGS = -fobjc-arc
+vlccoreios_LDADD = ../lib/libvlc.la ../src/libvlccore.la
+if HAVE_DARWIN
+if !HAVE_OSX
+noinst_PROGRAMS += vlccoreios
+endif
+endif
=====================================
test/iosvlc.m
=====================================
@@ -0,0 +1,167 @@
+/*****************************************************************************
+ * iosvlc.m: iOS specific development main executable for VLC media player
+ *****************************************************************************
+ * Copyright (C) 2020 Videolabs
+ *
+ * Authors: Marvin Scholz <epirat07 at gmail dot com>
+ * Alexandre Janniaux <ajanni at videolabs.io>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#import <UIKit/UIKit.h>
+#include <vlc/vlc.h>
+
+#include <vlc_common.h>
+#include <vlc_variables.h>
+#include <vlc_plugin.h>
+
+#include <TargetConditionals.h>
+
+ at interface AppDelegate : UIResponder <UIApplicationDelegate> {
+ @public
+ libvlc_instance_t *_libvlc;
+ UIWindow *window;
+ UIView *subview;
+
+#if TARGET_OS_IOS
+ UIPinchGestureRecognizer *_pinchRecognizer;
+#endif
+
+ CGRect _pinchRect;
+ CGPoint _pinchOrigin;
+ CGPoint _pinchPreviousCenter;
+}
+ at end
+
+
+ at implementation AppDelegate
+#if TARGET_OS_IOS
+- (void)pinchRecognized:(UIPinchGestureRecognizer *)pinchRecognizer
+{
+ UIGestureRecognizerState state = [pinchRecognizer state];
+
+ switch (state)
+ {
+ case UIGestureRecognizerStateBegan:
+ _pinchRect = [subview frame];
+ _pinchOrigin = [pinchRecognizer locationInView:nil];
+ _pinchPreviousCenter = [subview center];
+ return;
+ case UIGestureRecognizerStateEnded:
+ return;
+ case UIGestureRecognizerStateChanged:
+ break;
+ default:
+ return;
+ }
+
+ CGFloat scale = pinchRecognizer.scale;
+ CGRect viewBounds = _pinchRect;
+ if (scale >= 1.0 && (viewBounds.size.width == 0 || viewBounds.size.height == 0))
+ viewBounds.size.width = viewBounds.size.height = 1;
+ viewBounds.size.width *= scale;
+ viewBounds.size.height *= scale;
+ subview.frame = viewBounds;
+ CGPoint newPosition = [pinchRecognizer locationInView:nil];
+ subview.center = CGPointMake(
+ _pinchPreviousCenter.x + newPosition.x - _pinchOrigin.x,
+ _pinchPreviousCenter.y + newPosition.y - _pinchOrigin.y);
+}
+#endif
+
+/* Called after application launch */
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ /* Set VLC_PLUGIN_PATH for dynamic loading */
+ NSString *pluginsDirectory = [[NSBundle mainBundle] privateFrameworksPath];
+ setenv("VLC_PLUGIN_PATH", [pluginsDirectory UTF8String], 1);
+
+ /* Store startup arguments to forward them to libvlc */
+ NSArray *arguments = [[NSProcessInfo processInfo] arguments];
+ unsigned vlc_argc = [arguments count];
+ const char **vlc_argv = malloc(vlc_argc * sizeof *vlc_argv);
+ if (vlc_argv == NULL)
+ return NO;
+
+ for (unsigned i = 0; i < vlc_argc; i++)
+ vlc_argv[i] = [[arguments objectAtIndex:i] UTF8String];
+
+ /* Initialize libVLC */
+ _libvlc = libvlc_new(vlc_argc, (const char * const*)vlc_argv);
+ free(vlc_argv);
+
+ if (_libvlc == NULL)
+ return NO;
+
+ /* Initialize main window */
+ window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
+ window.rootViewController = [UIViewController alloc];
+ window.backgroundColor = [UIColor whiteColor];
+
+ subview = [[UIView alloc] initWithFrame:window.bounds];
+ subview.backgroundColor = [UIColor blueColor];
+ [window addSubview:subview];
+ [window makeKeyAndVisible];
+
+#if TARGET_OS_IOS
+ _pinchRecognizer = [[UIPinchGestureRecognizer alloc]
+ initWithTarget:self action:@selector(pinchRecognized:)];
+ [window addGestureRecognizer:_pinchRecognizer];
+#endif
+
+ /* Start glue interface, see code below */
+ libvlc_add_intf(_libvlc, "ios_interface,none");
+
+ /* Start parsing arguments and eventual playback */
+ libvlc_playlist_play(_libvlc, -1, 0, NULL);
+
+ return YES;
+}
+ at end
+
+int main(int argc, char * argv[]) {
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
+ }
+}
+
+/* Glue interface code, define drawable-nsobject for display module */
+static int Open(vlc_object_t *obj)
+{
+ AppDelegate *d = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+ assert(d != nil && d->subview != nil);
+ var_SetAddress(obj->obj.libvlc, "drawable-nsobject",
+ (__bridge void *)d->subview);
+
+ return VLC_SUCCESS;
+}
+
+#define MODULE_NAME ios_interface
+#define MODULE_STRING "ios_interface"
+vlc_module_begin()
+ set_capability("interface", 0)
+ set_callbacks(Open, NULL)
+vlc_module_end()
+
+/* Inject the glue interface as a static module */
+typedef int (*vlc_plugin_cb)(vlc_set_cb, void*);
+
+__attribute__((visibility("default")))
+vlc_plugin_cb vlc_static_modules[] = { vlc_entry__ios_interface, NULL };
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a7d9910e783dbbad2629f277254d4aa8c5d9d092...370b1ae83727f4e8d47b250dea26b96f0905b942
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a7d9910e783dbbad2629f277254d4aa8c5d9d092...370b1ae83727f4e8d47b250dea26b96f0905b942
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list