diff --git a/packages/l/libyuv/patches/1891/cmake.patch b/packages/l/libyuv/patches/1891/cmake.patch new file mode 100644 index 000000000..784e9ee69 --- /dev/null +++ b/packages/l/libyuv/patches/1891/cmake.patch @@ -0,0 +1,79 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3f521e3..4d742f3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -73,7 +73,6 @@ if(MSVC) + endif() + + # Need to set PIC to allow creating shared libraries from object file libraries. +-SET(CMAKE_POSITION_INDEPENDENT_CODE ON) + + # Build the set of objects that do not need to be compiled with flags to enable + # particular architecture features. +@@ -120,19 +119,15 @@ if(NOT MSVC) + endif() + + # this creates the static library (.a) +-ADD_LIBRARY( ${ly_lib_static} STATIC ${ly_lib_parts}) +- +-# this creates the shared library (.so) +-ADD_LIBRARY( ${ly_lib_shared} SHARED ${ly_lib_parts}) +-SET_TARGET_PROPERTIES( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" ) +-SET_TARGET_PROPERTIES( ${ly_lib_shared} PROPERTIES PREFIX "lib" ) +-if(WIN32) +- SET_TARGET_PROPERTIES( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" ) ++ADD_LIBRARY( ${ly_lib_static} ${ly_lib_parts}) ++if (BUILD_SHARED_LIBS) ++ add_definitions("-DLIBYUV_BUILDING_SHARED_LIBRARY") + endif() ++# this creates the shared library (.so) + ++option(BUILD_TOOLS "Build tools" OFF) ++if (BUILD_TOOLS) + # this creates the cpuid tool +-ADD_EXECUTABLE ( cpuid ${ly_base_dir}/util/cpuid.c ) +-TARGET_LINK_LIBRARIES ( cpuid ${ly_lib_static} ) + + # this creates the conversion tool + ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc ) +@@ -141,12 +136,22 @@ TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} ) + # this creates the yuvconstants tool + ADD_EXECUTABLE ( yuvconstants ${ly_base_dir}/util/yuvconstants.c ) + TARGET_LINK_LIBRARIES ( yuvconstants ${ly_lib_static} ) ++include(CheckFunctionExists) ++check_function_exists(round HAVE_MATH_SYSTEM) ++if(NOT HAVE_MATH_SYSTEM) ++ target_link_libraries(yuvconstants m) ++endif() ++INSTALL(TARGETS yuvconvert yuvconstants DESTINATION bin) ++endif() + +-find_package ( JPEG ) +-if (JPEG_FOUND) +- include_directories( ${JPEG_INCLUDE_DIR} ) +- target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} ) +- add_definitions( -DHAVE_JPEG ) ++option(LIBYUV_WITH_JPEG "Build libyuv with jpeg" OFF) ++if (LIBYUV_WITH_JPEG) ++ find_package(JPEG REQUIRED) ++ target_link_libraries(${ly_lib_static} JPEG::JPEG ) ++ target_compile_definitions(${ly_lib_static} PRIVATE HAVE_JPEG) ++ if (BUILD_TOOLS) ++ target_compile_definitions(yuvconvert PRIVATE HAVE_JPEG) ++ endif() + endif() + + if(UNIT_TEST) +@@ -192,11 +197,8 @@ endif() + + + # install the conversion tool, .so, .a, and all the header files +-INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin ) +-INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib ) +-INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) ++INSTALL ( TARGETS ${ly_lib_static} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) + INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include ) + + # create the .deb and .rpm packages using cpack +-INCLUDE ( CM_linux_packages.cmake ) + diff --git a/packages/l/libyuv/xmake.lua b/packages/l/libyuv/xmake.lua index 8a0d76cfe..4c8c6da11 100644 --- a/packages/l/libyuv/xmake.lua +++ b/packages/l/libyuv/xmake.lua @@ -1,28 +1,64 @@ package("libyuv") - set_homepage("https://chromium.googlesource.com/libyuv/libyuv/") set_description("libyuv is an open source project that includes YUV scaling and conversion functionality.") set_license("BSD-3-Clause") - set_urls("https://chromium.googlesource.com/libyuv/libyuv.git") - add_versions("2023.10.27", "31e1d6f896615342d5d5b6bde8f7b50b3fd698dc") + add_urls("https://chromium.googlesource.com/libyuv/libyuv.git", + "https://github.com/lemenkov/libyuv.git") + + add_urls("https://github.com/lemenkov/libyuv/archive/$(version).tar.gz", { + version = function (version) + -- Versions from LIBYUV_VERSION definition in include/libyuv/version.h + -- Pay attention to package commits incrementing this definition + local table = { + ["1891"] = "611806a1559b92c97961f51c78805d8d9d528c08", + } + return table[tostring(version)] + end}) + + add_versions("1891", "a8dddc6f45d6987cd3c08e00824792f3c72651fde29f475f572ee2292c03761f") + + add_patches("1891", "patches/1891/cmake.patch", "87086566b2180f65ff3d5ef9db7c59a6e51e2592aeeb787e45305beb4cf9d30d") + + add_configs("jpeg", {description = "Build with JPEG.", default = false, type = "boolean"}) + add_configs("tools", {description = "Build tools", default = false, type = "boolean"}) add_deps("cmake") - on_install("windows", "linux", "macosx", "android", "cross", "bsd", "mingw", function (package) - local configs = {"-DTEST=OFF"} - table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) - - io.replace("CMakeLists.txt", "INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin )", "", {plain = true}) - import("package.tools.cmake").install(package, configs) - - if package:is_plat("macosx", "linux", "android") then - if package:config("shared") then - os.tryrm(package:installdir("lib", "*.a")) - else - os.tryrm(package:installdir("lib", "*.so")) - end + if is_plat("linux", "bsd") then + add_syslinks("m") + end + + if on_check then + on_check("android", function (package) + local ndk = package:toolchain("ndk"):config("ndkver") + assert(ndk and tonumber(ndk) > 22, "package(libyuv/arm64): need ndk version > 22") + end) + end + + on_load(function (package) + if package:config("jpeg") then + package:add("deps", "libjpeg") end + + if package:config("shared") then + package:add("defines", "LIBYUV_USING_SHARED_LIBRARY") + end + end) + + on_install("!cross", function (package) + if package:is_plat("iphoneos") then + io.replace("CMakeLists.txt", + [[STRING(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" arch_lowercase)]], + [[set(arch_lowercase "]] .. package:arch() .. [[")]], {plain = true}) + end + + local configs = {"-DCMAKE_CXX_STANDARD=14"} + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + table.insert(configs, "-DLIBYUV_WITH_JPEG=" .. (package:config("jpeg") and "ON" or "OFF")) + table.insert(configs, "-DBUILD_TOOLS=" .. (package:config("tools") and "ON" or "OFF")) + import("package.tools.cmake").install(package, configs) end) on_test(function (package)