Meta: Get Android dependencies building again

This commit is contained in:
Andrew Kaster 2025-03-19 14:55:49 -06:00
parent 89ecc75ed8
commit c4a0249792
17 changed files with 165 additions and 32 deletions

View file

@ -79,3 +79,7 @@ if (WIN32)
# FIXME: Windows on ARM
target_link_libraries(AK PRIVATE clang_rt.builtins-x86_64.lib)
endif()
if (ANDROID)
target_link_libraries(AK PRIVATE log)
endif()

View file

@ -1,8 +1,5 @@
include(audio)
if (NOT ANDROID)
include(ffmpeg)
endif()
include(ffmpeg)
set(SOURCES
Audio/Loader.cpp
@ -19,21 +16,14 @@ set(SOURCES
serenity_lib(LibMedia media)
target_link_libraries(LibMedia PRIVATE LibCore LibCrypto LibRIFF LibIPC LibGfx LibThreading LibUnicode)
if (NOT ANDROID)
target_sources(LibMedia PRIVATE
Audio/FFmpegLoader.cpp
FFmpeg/FFmpegDemuxer.cpp
FFmpeg/FFmpegIOContext.cpp
FFmpeg/FFmpegVideoDecoder.cpp
)
target_link_libraries(LibMedia PRIVATE PkgConfig::AVCODEC PkgConfig::AVFORMAT PkgConfig::AVUTIL)
else()
# FIXME: Need to figure out how to build or replace ffmpeg libs on Android and Windows
target_sources(LibMedia PRIVATE
FFmpeg/FFmpegDemuxerStub.cpp
FFmpeg/FFmpegVideoDecoderStub.cpp
)
endif()
target_sources(LibMedia PRIVATE
Audio/FFmpegLoader.cpp
FFmpeg/FFmpegDemuxer.cpp
FFmpeg/FFmpegIOContext.cpp
FFmpeg/FFmpegVideoDecoder.cpp
)
target_link_libraries(LibMedia PRIVATE PkgConfig::AVCODEC PkgConfig::AVFORMAT PkgConfig::AVUTIL)
if (LADYBIRD_AUDIO_BACKEND STREQUAL "PULSE")
target_sources(LibMedia PRIVATE

View file

@ -14,7 +14,7 @@ DecoderErrorOr<Vector<Track>> FFmpegDemuxer::get_tracks_for_type(TrackType type)
return DecoderError::format(DecoderErrorCategory::NotImplemented, "FFmpeg not available on this platform");
}
DecoderErrorOr<Optional<AK::Duration>> FFmpegDemuxer::seek_to_most_recent_keyframe(Track track, AK::Duration timestamp, Optional<AK::Duration> earliest_available_sample = OptionalNone())
DecoderErrorOr<Optional<AK::Duration>> FFmpegDemuxer::seek_to_most_recent_keyframe(Track track, AK::Duration timestamp, Optional<AK::Duration> earliest_available_sample)
{
(void)track;
(void)timestamp;

View file

@ -4,7 +4,7 @@
# SPDX-License-Identifier: BSD-2-Clause
#
if (NOT APPLE AND NOT ANDROID AND NOT WIN32 AND NOT LAGOM_USE_LINKER)
if (NOT APPLE AND NOT VCPKG_TARGET_ANDROID AND NOT ANDROID AND NOT WIN32 AND NOT LAGOM_USE_LINKER)
find_program(LLD_LINKER NAMES "ld.lld")
if (LLD_LINKER)
message(STATUS "Using LLD to link Lagom.")

View file

@ -0,0 +1,10 @@
set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Android)
set(VCPKG_MAKE_BUILD_TRIPLET "--host=aarch64-linux-android36")
set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DANDROID_ABI=arm64-v8a)
include(${CMAKE_CURRENT_LIST_DIR}/base.cmake)
cmake_policy(SET CMP0057 NEW)

View file

@ -0,0 +1,2 @@
include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/arm64-android.cmake)
include (${CMAKE_CURRENT_LIST_DIR}/debug.cmake)

View file

@ -0,0 +1,2 @@
include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/arm64-android.cmake)
include (${CMAKE_CURRENT_LIST_DIR}/distribution.cmake)

View file

@ -17,12 +17,17 @@ if (LINUX AND NOT LAGOM_USE_LINKER)
string(APPEND EXTRA_VCPKG_VARIABLES "set(ENV{LDFLAGS} -Wl,-z,noseparate-code)\n")
endif()
string(APPEND EXTRA_VCPKG_VARIABLES [=[
if (POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
endif()
]=])
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/build-vcpkg-variables.cmake" "${EXTRA_VCPKG_VARIABLES}")
# Munge the VCPKG_TRIPLET to correspond to the right one for our presets
# Just make sure not to override if the developer is trying to cross-compile
# or the developer set it manually, or if this is not the first run of CMake
if (NOT DEFINED CACHE{VCPKG_TARGET_TRIPLET} AND NOT DEFINED CACHE{VCPKG_HOST_TRIPLET} AND NOT DEFINED VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
# Just make sure not to override if the developer set it manually, or if this is not the first run of CMake
if (NOT DEFINED CACHE{VCPKG_TARGET_TRIPLET} AND NOT DEFINED CACHE{VCPKG_HOST_TRIPLET})
# Only tweak settings if there's custom triplets defined
if (NOT DEFINED CACHE{VCPKG_OVERLAY_TRIPLETS})
return()
@ -74,6 +79,8 @@ if (NOT DEFINED CACHE{VCPKG_TARGET_TRIPLET} AND NOT DEFINED CACHE{VCPKG_HOST_TRI
endif()
message(STATUS "Determined host VCPKG_TARGET_TRIPLET: ${full_triplet}")
set(VCPKG_TARGET_TRIPLET ${full_triplet} CACHE STRING "")
if (NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
set(VCPKG_TARGET_TRIPLET ${full_triplet} CACHE STRING "")
endif()
set(VCPKG_HOST_TRIPLET ${full_triplet} CACHE STRING "")
endif()

View file

@ -0,0 +1,57 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ecfbb83..420c578 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,13 +34,6 @@ endif()
# Find Brotli dependencies
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
-find_package(BrotliDec)
-if (NOT BROTLIDEC_FOUND)
- message(FATAL_ERROR "librotlidec is needed to build woff2.")
-endif ()
-find_package(BrotliEnc)
-if (NOT BROTLIENC_FOUND)
- message(FATAL_ERROR "librotlienc is needed to build woff2.")
-endif ()
+ find_package(unofficial-brotli REQUIRED)
# Set compiler flags
if (NOT CANONICAL_PREFIXES)
@@ -63,9 +73,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAG}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAG}")
set(CMAKE_CXX_STANDARD 11)
-# Set search path for our private/public headers as well as Brotli headers
-include_directories("src" "include"
- "${BROTLIDEC_INCLUDE_DIRS}" "${BROTLIENC_INCLUDE_DIRS}")
+# Set search path for our private/public headers
+include_directories("src" "include")
# Common part used by decoder and encoder
add_library(woff2common
@@ -77,7 +86,7 @@ add_library(woff2common
add_library(woff2dec
src/woff2_dec.cc
src/woff2_out.cc)
-target_link_libraries(woff2dec woff2common "${BROTLIDEC_LIBRARIES}")
+target_link_libraries(woff2dec woff2common unofficial::brotli::brotlidec)
add_executable(woff2_decompress src/woff2_decompress.cc)
target_link_libraries(woff2_decompress woff2dec)
@@ -88,7 +97,7 @@ add_library(woff2enc
src/normalize.cc
src/transform.cc
src/woff2_enc.cc)
-target_link_libraries(woff2enc woff2common "${BROTLIENC_LIBRARIES}")
+target_link_libraries(woff2enc woff2common unofficial::brotli::brotlienc)
add_executable(woff2_compress src/woff2_compress.cc)
target_link_libraries(woff2_compress woff2enc)
@@ -264,6 +273,7 @@ if (NOT BUILD_SHARED_LIBS)
install(
TARGETS woff2_decompress woff2_compress woff2_info
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()

View file

@ -0,0 +1,36 @@
vcpkg_check_linkage(
ONLY_STATIC_LIBRARY
)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO google/woff2
REF v1.0.2
SHA512 c788bba1530aec463e755e901f9342f4b599e3a07f54645fef1dc388ab5d5c30625535e5dd38e9e792e04a640574baa50eeefb6b7338ab403755f4a4e0c3044d
HEAD_REF master
PATCHES
0001-unofficial-brotli.patch
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DCANONICAL_PREFIXES=ON
-DCMAKE_POLICY_DEFAULT_CMP0057=NEW
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
file(COPY "${CURRENT_PACKAGES_DIR}/bin/" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/woff2")
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/bin"
"${CURRENT_PACKAGES_DIR}/debug/bin"
"${CURRENT_PACKAGES_DIR}/debug/include"
)
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/woff2")
vcpkg_fixup_pkgconfig()
# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/woff2" RENAME copyright)

View file

@ -0,0 +1,13 @@
{
"name": "woff2",
"version": "1.0.2",
"port-version": 4,
"description": "font compression reference code",
"dependencies": [
"brotli",
{
"name": "vcpkg-cmake",
"host": true
}
]
}

View file

@ -0,0 +1,2 @@
include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/arm64-android.cmake)
include (${CMAKE_CURRENT_LIST_DIR}/release.cmake)

View file

@ -0,0 +1,2 @@
include (${CMAKE_CURRENT_LIST_DIR}/../base-triplets/arm64-android.cmake)
include (${CMAKE_CURRENT_LIST_DIR}/sanitizer.cmake)

View file

@ -35,6 +35,7 @@ cmake -S "${LADYBIRD_SOURCE_DIR}/Meta/Lagom" -B "$BUILD_DIR/lagom-tools" \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DSERENITY_CACHE_DIR="$CACHE_DIR" \
-DBUILD_SHARED_LIBS=OFF \
-DLAGOM_TOOLS_ONLY=ON \
-DINSTALL_LAGOM_TOOLS=ON \
-DCMAKE_TOOLCHAIN_FILE="$LADYBIRD_SOURCE_DIR/Build/vcpkg/scripts/buildsystems/vcpkg.cmake" \

View file

@ -1,7 +1,7 @@
import com.android.build.gradle.internal.tasks.factory.dependsOn
plugins {
id("com.android.application") version "8.4.0"
id("com.android.application") version "8.7.3"
id("org.jetbrains.kotlin.android") version "1.9.0"
}
@ -22,12 +22,13 @@ tasks.named("prepareKotlinBuildScriptModel").dependsOn("buildLagomTools")
android {
namespace = "org.serenityos.ladybird"
compileSdk = 34
ndkVersion = "29.0.13113456"
compileSdk = 36
defaultConfig {
applicationId = "org.serenityos.ladybird"
minSdk = 30
targetSdk = 34
targetSdk = 36
versionCode = 1
versionName = "1.0"
@ -41,7 +42,10 @@ android {
"-DANDROID_STL=c++_shared",
"-DSERENITY_CACHE_DIR=$cacheDir",
"-DVCPKG_ROOT=$sourceDir/Build/vcpkg",
"-DVCPKG_TARGET_ANDROID=ON"
"-DVCPKG_TARGET_ANDROID=ON",
"-DVCPKG_INSTALL_OPTIONS=--no-print-usage",
"-DVCPKG_OVERLAY_TRIPLETS=$sourceDir/Meta/CMake/vcpkg/distribution-triplets",
"-DBUILD_SHARED_LIBS=OFF"
)
}
}

View file

@ -1,6 +1,6 @@
#Fri Sep 01 12:36:55 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -20,7 +20,7 @@
},
{
"name": "ffmpeg",
"platform": "!android",
"platform": "!xbox",
"features": [
"avcodec",
"avformat",
@ -63,7 +63,10 @@
"apng"
]
},
"libproxy",
{
"name": "libproxy",
"platform": "!(uwp | xbox | android)"
},
{
"name": "libavif",
"features": [