From 5cc71bb9ea2e440890627e17e4f7020bf706d66c Mon Sep 17 00:00:00 2001 From: cxfksword <718792+cxfksword@users.noreply.github.com> Date: Sun, 3 Nov 2024 09:38:00 +0800 Subject: [PATCH 1/2] feat: separate libbluray to independent repository --- README.md | 1 + .../BuildScripts/XCFrameworkBuild/base.swift | 4 +- .../BuildScripts/XCFrameworkBuild/main.swift | 80 ++----------------- 3 files changed, 10 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index af89d10..9004e9a 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ make help * [libshaderc-build](https://github.com/mpvkit/libshaderc-build) * [libluajit-build](https://github.com/mpvkit/libluajit-build) * [libass-build](https://github.com/mpvkit/libass-build) +* [libbluray-build](https://github.com/mpvkit/libbluray-build) * [libsmbclient-build](https://github.com/mpvkit/libsmbclient-build) * [gnutls-build](https://github.com/mpvkit/gnutls-build) * [openssl-build](https://github.com/mpvkit/openssl-build) diff --git a/Sources/BuildScripts/XCFrameworkBuild/base.swift b/Sources/BuildScripts/XCFrameworkBuild/base.swift index 69cff33..804c999 100644 --- a/Sources/BuildScripts/XCFrameworkBuild/base.swift +++ b/Sources/BuildScripts/XCFrameworkBuild/base.swift @@ -117,9 +117,9 @@ class BaseBuild { // pull code from git if pullLatestVersion { - try! Utility.launch(path: "/usr/bin/git", arguments: ["-c", "advice.detachedHead=false", "clone", "--depth", "1", library.url, directoryURL.path]) + try! Utility.launch(path: "/usr/bin/git", arguments: ["-c", "advice.detachedHead=false", "clone", "--recursive", "--depth", "1", library.url, directoryURL.path]) } else { - try! Utility.launch(path: "/usr/bin/git", arguments: ["-c", "advice.detachedHead=false", "clone", "--depth", "1", "--branch", library.version, library.url, directoryURL.path]) + try! Utility.launch(path: "/usr/bin/git", arguments: ["-c", "advice.detachedHead=false", "clone", "--recursive", "--depth", "1", "--branch", library.version, library.url, directoryURL.path]) } // apply patch diff --git a/Sources/BuildScripts/XCFrameworkBuild/main.swift b/Sources/BuildScripts/XCFrameworkBuild/main.swift index 4b121cc..61c1a90 100644 --- a/Sources/BuildScripts/XCFrameworkBuild/main.swift +++ b/Sources/BuildScripts/XCFrameworkBuild/main.swift @@ -19,6 +19,9 @@ do { // libsmbclient try BuildSmbclient().buildALL() + + // libbluray + try BuildBluray().buildALL() // ffmpeg try BuildUavs3d().buildALL() @@ -33,7 +36,6 @@ do { // mpv try BuildUchardet().buildALL() try BuildLuaJIT().buildALL() - try BuildBluray().buildALL() try BuildMPV().buildALL() } catch { print(error.localizedDescription) @@ -133,7 +135,7 @@ enum Library: String, CaseIterable { case .libuchardet: return "https://github.com/mpvkit/libuchardet-build/releases/download/\(self.version)/libuchardet-all.zip" case .libbluray: - return "https://code.videolan.org/videolan/libbluray.git" + return "https://github.com/mpvkit/libbluray-build/releases/download/\(self.version)/libbluray-all.zip" case .libluajit: return "https://github.com/mpvkit/libluajit-build/releases/download/\(self.version)/libluajit-all.zip" case .libuavs3d: @@ -340,8 +342,8 @@ enum Library: String, CaseIterable { return [ .target( name: "Libbluray", - url: "https://github.com/mpvkit/MPVKit/releases/download/\(BaseBuild.options.releaseVersion)/Libbluray.xcframework.zip", - checksum: "" + url: "https://github.com/mpvkit/libbluray-build/releases/download/\(self.version)/Libbluray.xcframework.zip", + checksum: "https://github.com/mpvkit/libbluray-build/releases/download/\(self.version)/Libbluray.xcframework.checksum.txt" ), ] case .libluajit: @@ -753,80 +755,12 @@ private class BuildFFMPEG: BaseBuild { -// depend openssl, ffmpeg, freetype -private class BuildBluray: BaseBuild { +private class BuildBluray: ZipBaseBuild { init() { super.init(library: .libbluray) } - - override func beforeBuild() throws { - if FileManager.default.fileExists(atPath: directoryURL.path) { - return - } - - // pull code from git - let noPatchURL = directoryURL + "nopatch" - try! Utility.launch(path: "/usr/bin/git", arguments: ["-c", "advice.detachedHead=false", "clone", "--recursive", "--depth", "1", "--branch", library.version, library.url, noPatchURL.path]) - - let patchURL = directoryURL + "patch" - try! Utility.launch(path: "/usr/bin/git", arguments: ["-c", "advice.detachedHead=false", "clone", "--recursive", "--depth", "1", "--branch", library.version, library.url, patchURL.path]) - // apply patch - let patch = URL.currentDirectory + "../Sources/BuildScripts/patch/\(library.rawValue)" - if FileManager.default.fileExists(atPath: patch.path) { - _ = try? Utility.launch(path: "/usr/bin/git", arguments: ["checkout", "."], currentDirectoryURL: patchURL) - let fileNames = try! FileManager.default.contentsOfDirectory(atPath: patch.path).sorted() - for fileName in fileNames { - try! Utility.launch(path: "/usr/bin/git", arguments: ["apply", "\((patch + fileName).path)"], currentDirectoryURL: patchURL) - } - } - } - - override func configure(buildURL: URL, environ: [String: String], platform: PlatformType, arch: ArchType) throws { - // 只能 macos 支持 DiskArbitration 框架,其他平台使用 patch 版本去掉 DiskArbitration 依赖 - var workURL = directoryURL + "nopatch" - if platform != .macos && platform != .maccatalyst { - workURL = directoryURL + "patch" - } - - let configure = workURL + "configure" - if !FileManager.default.fileExists(atPath: configure.path) { - var bootstrap = workURL + "bootstrap" - if !FileManager.default.fileExists(atPath: bootstrap.path) { - bootstrap = workURL + ".bootstrap" - } - if FileManager.default.fileExists(atPath: bootstrap.path) { - try Utility.launch(executableURL: bootstrap, arguments: [], currentDirectoryURL: workURL, environment: environ) - } - } - var arguments = [ - "--prefix=\(thinDir(platform: platform, arch: arch).path)", - ] - arguments.append(contentsOf: self.arguments(platform: platform, arch: arch)) - try Utility.launch(executableURL: configure, arguments: arguments, currentDirectoryURL: buildURL, environment: environ) - } - - override func arguments(platform: PlatformType, arch: ArchType) -> [String] { - [ - "--disable-doxygen-doc", - "--disable-doxygen-dot", - "--disable-doxygen-html", - "--disable-doxygen-ps", - "--disable-doxygen-pdf", - "--disable-examples", - "--disable-bdjava-jar", - "--without-fontconfig", - "--with-pic", - "--enable-static", - "--disable-shared", - "--disable-fast-install", - "--disable-dependency-tracking", - "--host=\(platform.host(arch: arch))", - ] - } } - - private class BuildUchardet: ZipBaseBuild { init() { super.init(library: .libuchardet) From 2f1d7cae7a609f212d13546c0ecfd92219feff9e Mon Sep 17 00:00:00 2001 From: cxfksword <718792+cxfksword@users.noreply.github.com> Date: Tue, 5 Nov 2024 09:06:25 +0800 Subject: [PATCH 2/2] chore: remove libbluray patch --- .../patch/libbluray/fix-no-dadisk.patch | 29 ------------------- .../patch/libbluray/no_fork_and_exec.patch | 22 -------------- 2 files changed, 51 deletions(-) delete mode 100644 Sources/BuildScripts/patch/libbluray/fix-no-dadisk.patch delete mode 100644 Sources/BuildScripts/patch/libbluray/no_fork_and_exec.patch diff --git a/Sources/BuildScripts/patch/libbluray/fix-no-dadisk.patch b/Sources/BuildScripts/patch/libbluray/fix-no-dadisk.patch deleted file mode 100644 index e0935ed..0000000 --- a/Sources/BuildScripts/patch/libbluray/fix-no-dadisk.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/src/file/mount_darwin.c b/src/file/mount_darwin.c -index 5b13450..930df04 100644 ---- a/src/file/mount_darwin.c -+++ b/src/file/mount_darwin.c -@@ -30,13 +30,12 @@ - #define _DARWIN_C_SOURCE - #include - --#include -+//#include - - static char *bsdname_get_mountpoint(const char *device_path) - { - char *result = NULL; -- -- DASessionRef session = DASessionCreate(kCFAllocatorDefault); -+ /*DASessionRef session = DASessionCreate(kCFAllocatorDefault); - if (session) { - DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, session, device_path); - if (disk) { -@@ -56,7 +55,7 @@ static char *bsdname_get_mountpoint(const char *device_path) - CFRelease(disk); - } - CFRelease(session); -- } -+ }*/ - - return result; - } diff --git a/Sources/BuildScripts/patch/libbluray/no_fork_and_exec.patch b/Sources/BuildScripts/patch/libbluray/no_fork_and_exec.patch deleted file mode 100644 index e7c079f..0000000 --- a/Sources/BuildScripts/patch/libbluray/no_fork_and_exec.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c -index 359bc8f..32b080c 100644 ---- a/src/libbluray/bdj/bdj.c -+++ b/src/libbluray/bdj/bdj.c -@@ -256,7 +256,7 @@ static char *_java_home_macos() - return NULL; - } - -- switch (java_home_pid = vfork()) -+ switch (java_home_pid = -1) - { - case -1: - BD_DEBUG(DBG_BDJ | DBG_CRIT, "vfork failed\n"); -@@ -270,7 +270,7 @@ static char *_java_home_macos() - close(fd[1]); - close(fd[0]); - -- execl(MACOS_JAVA_HOME, MACOS_JAVA_HOME); -+ //execl(MACOS_JAVA_HOME, MACOS_JAVA_HOME); - - _exit(-1); -