Bladeren bron

libyuv: add 1913 version (#7677)

* libyuv: add 1913 version

* Update xmake.lua

* fix linux arm64

* add 1913

* imporve patch

* fix ios
star9029 4 maanden geleden
bovenliggende
commit
c00e635025
2 gewijzigde bestanden met toevoegingen van 91 en 20 verwijderingen
  1. 77 0
      packages/l/libyuv/patches/1913/cmake.patch
  2. 14 20
      packages/l/libyuv/xmake.lua

+ 77 - 0
packages/l/libyuv/patches/1913/cmake.patch

@@ -0,0 +1,77 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c8d6d900..b8134168 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -75,7 +75,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.
+@@ -174,19 +173,14 @@ if(LOONGARCH64)
+ 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()
+ 
++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 )
+@@ -195,12 +189,21 @@ 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} )
+-
+-find_package ( JPEG )
+-if (JPEG_FOUND)
+-  include_directories( ${JPEG_INCLUDE_DIR} )
+-  target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} )
+-  add_definitions( -DHAVE_JPEG )
++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()
++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)
+@@ -246,9 +249,7 @@ endif()
+ 
+ 
+ # install the conversion tool, .so, .a, and all the header files
+-install ( TARGETS yuvconvert DESTINATION bin )
+-install ( TARGETS ${ly_lib_static}						DESTINATION lib )
+-install ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib )
++install ( TARGETS ${ly_lib_static} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib )
+ install ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/		DESTINATION include )
+ 
+ # create the .deb and .rpm packages using cpack
+ 

+ 14 - 20
packages/l/libyuv/xmake.lua

@@ -4,20 +4,14 @@ package("libyuv")
     set_license("BSD-3-Clause")
 
     add_urls("https://chromium.googlesource.com/libyuv/libyuv.git",
-             "https://github.com/lemenkov/libyuv.git")
+             "https://github.com/lemenkov/libyuv.git", {alias = "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")
+    -- Versions from LIBYUV_VERSION definition in include/libyuv/version.h
+    -- Pay attention to package commits incrementing this definition
+    add_versions("git:1913", "6f729fbe658a40dfd993fa8b22bd612bb17cde5c")
+    add_versions("git:1891", "611806a1559b92c97961f51c78805d8d9d528c08")
 
+    add_patches("1913", "patches/1913/cmake.patch", "9b61c6a5c26e727d164f06e83a3bf19863f840cd57fcee365429561e640930bf")
     add_patches("1891", "patches/1891/cmake.patch", "87086566b2180f65ff3d5ef9db7c59a6e51e2592aeeb787e45305beb4cf9d30d")
 
     add_configs("jpeg", {description = "Build with JPEG.", default = false, type = "boolean"})
@@ -34,11 +28,6 @@ package("libyuv")
             local ndk = package:toolchain("ndk"):config("ndkver")
             assert(ndk and tonumber(ndk) > 22, "package(libyuv): need ndk version > 22")
         end)
-        on_check("linux", function (package)
-            if package:is_arch("arm64") then
-                raise("package(libyuv) unsupport compile flags -march=armv9-a+sme")
-            end
-        end)
     end
 
     on_load(function (package)
@@ -53,10 +42,15 @@ package("libyuv")
 
     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})
+            local patch = [[set(arch_lowercase "]] .. package:arch() .. [[")]]
+            io.replace("CMakeLists.txt", [[STRING(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" arch_lowercase)]], patch, {plain = true})
+            io.replace("CMakeLists.txt", [[string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" arch_lowercase)]], patch, {plain = true})
         end
+        -- fix linux arm64 build error
+        -- -- commit 1724c4be72f32d2f04eead939f7b3f35ad4e39e3
+        -- io.replace("CMakeLists.txt", "-march=armv9-a+sme", "-march=armv9-a+i8mm+sme", {plain = true})
+        io.replace("CMakeLists.txt", "-march=armv9-a+sme", "", {plain = true})
+        io.replace("CMakeLists.txt", "-march=armv9-a+i8mm+sme", "", {plain = true})
 
         local configs = {"-DCMAKE_CXX_STANDARD=14"}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))