Skip to content

Commit

Permalink
libshardc framework 标识符
Browse files Browse the repository at this point in the history
  • Loading branch information
tinuv authored and tinuv committed Dec 2, 2024
1 parent be7c7cc commit 5c09d07
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 42 deletions.
19 changes: 17 additions & 2 deletions FFMPEGBuilder/Builder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Builder {

func postCompile() {}

func postBuild(platform: PlatformType, arch: ArchType) {}
func postBuild(platform _: PlatformType, arch _: ArchType) {}

func compile() {
for platform in platforms() {
Expand Down Expand Up @@ -173,6 +173,21 @@ class Builder {

func arguments(platform _: PlatformType, arch _: ArchType) -> [String] { [] }

func printCommd(arguments: [String], environment: [String: String], buildURL _: String) {
var cmd = ""
for (key, value) in environment {
cmd += "\(key)=\"\(value)\" "
}
cmd += "\n"
cmd += "cmake \\\n"
for arg in arguments {
cmd += "\(arg) \\\n"
}
print("-----------------")
print(cmd)
print("-----------------")
}

func configure(buildURL: URL, env: [String: String], platform: PlatformType, arch: ArchType) throws {
let makeLists = lib.libSourceDirectory + "CMakeLists.txt"
if FileManager.default.fileExists(atPath: makeLists.path) {
Expand Down Expand Up @@ -343,7 +358,7 @@ extension Builder {
if !FileManager.default.fileExists(atPath: prefix.path) {
return nil
}
let libname = framework.hasPrefix("lib") || framework.hasPrefix("Lib") ? framework : "lib" + framework
let libname = framework=="libshaderccombined" ? "libshaderc_combined": framework.hasPrefix("lib") || framework.hasPrefix("Lib") ? framework : "lib" + framework
var libPath = prefix + ["lib", "\(libname).a"]
if !FileManager.default.fileExists(atPath: libPath.path) {
libPath = prefix + ["lib", "\(libname).dylib"]
Expand Down
43 changes: 22 additions & 21 deletions FFMPEGBuilder/FFMPEGBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import Foundation

// 交叉编译参数
class FFMPEGBuilder {
static let workDirectory = "file:///Users/tinuv/Downloads/build"
static let workDirectory = "file:///Users/tinuv/Downloads/build1"
static let buildDirectory = workDirectory + "/build"
static let distDirectory = workDirectory + "/dist"

static let patchDirector = URL(string: "/Users/tinuv/Developer/Apple/Other/FFMPEGBuilder/FFMPEGBuilder/Patch")!
static let libsmbclientDepDirector = URL(string: "/Users/tinuv/Developer/Apple/Other/FFMPEGBuilder/FFMPEGBuilder/libsmbclient")!
static let platforms = PlatformType.allCases.filter { ![.watchos, .watchsimulator, .android].contains($0) }
Expand All @@ -22,26 +23,26 @@ extension FFMPEGBuilder {
func initLibrayList() -> [Library] {
var libraryList: [Library] = []
libraryList.append(.libshaderc)
libraryList.append(.vulkan)
libraryList.append(.lcms2)
libraryList.append(.libplacebo)
libraryList.append(.libdav1d)
libraryList.append(.gmp)
libraryList.append(.nettle)
libraryList.append(.gnutls)
libraryList.append(.readline)
libraryList.append(.libsmbclient)
libraryList.append(.libsrt)
libraryList.append(.libzvbi)
libraryList.append(.libfreetype)
libraryList.append(.libfribidi)
libraryList.append(.libharfbuzz)
libraryList.append(.libass)
libraryList.append(.libfontconfig)
libraryList.append(.libbluray)
libraryList.append(.libunibreak)
libraryList.append(.ffmpeg)
libraryList.append(.libmpv)
//libraryList.append(.vulkan)
//libraryList.append(.lcms2)
//libraryList.append(.libplacebo)
//libraryList.append(.libdav1d)
//libraryList.append(.gmp)
//libraryList.append(.nettle)
//libraryList.append(.gnutls)
//libraryList.append(.readline)
//libraryList.append(.libsmbclient)
//libraryList.append(.libsrt)
//libraryList.append(.libzvbi)
//libraryList.append(.libfreetype)
//libraryList.append(.libfribidi)
//libraryList.append(.libharfbuzz)
//libraryList.append(.libass)
//libraryList.append(.libfontconfig)
//libraryList.append(.libbluray)
//libraryList.append(.libunibreak)
//libraryList.append(.ffmpeg)
//libraryList.append(.libmpv)
return libraryList
}
}
17 changes: 15 additions & 2 deletions FFMPEGBuilder/LibBuilders/LibFFMPEGBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
import Foundation

class LibFFMPEGBuilder: Builder {

override func platforms() -> [PlatformType] {
// Placebo编译maccatalyst的时候,vulkan会报找不到UIKit的问题,所以要先屏蔽。
super.platforms().filter {
![].contains($0)
}
}


override func preCompile() {
super.preCompile()
if Utility.shell("which nasm") == nil {
Expand All @@ -28,7 +37,7 @@ class LibFFMPEGBuilder: Builder {
}

override func flagsDependencelibrarys() -> [Library] {
[.gmp, .nettle, .gnutls, .libsmbclient]
[.gmp, .nettle, .gnutls, .libsmbclient,/*.libsleef*/.lcms2,.libbluray,.libfontconfig,.libfreetype,.libdav1d,.libplacebo,.libshaderc,.libsrt,.libzvbi]
}

override func frameworks() -> [String] {
Expand Down Expand Up @@ -216,11 +225,14 @@ class LibFFMPEGBuilder: Builder {
arguments.append("--target-os=darwin")
arguments.append("--enable-libxml2")
}
//arguments.append("-DCMAKE_C_VISIBILITY_PRESET=hidden")
//arguments.append("-DCMAKE_CXX_VISIBILITY_PRESET=hidden")
// arguments.append(arch.cpu())
/**
aacpsdsp.o), building for Mac Catalyst, but linking in object file built for
x86_64 binaries are built without ASM support, since ASM for x86_64 is actually x86 and that confuses `xcodebuild -create-xcframework` https://stackoverflow.com/questions/58796267/building-for-macos-but-linking-in-object-file-built-for-free-standing/59103419#59103419
*/
//arguments.append("--disable-libsmbclient")
if platform == .maccatalyst || arch == .x86_64 {
arguments.append("--disable-neon")
arguments.append("--disable-asm")
Expand Down Expand Up @@ -292,6 +304,7 @@ class LibFFMPEGBuilder: Builder {
private let ffmpegConfiguers = [
// Configuration options:
"--enable-gpl",
//"--enable-libtorch",
"--disable-armv5te", "--disable-armv6", "--disable-armv6t2",
"--disable-bzlib", "--disable-gray", "--disable-iconv", "--disable-linux-perf",
"--disable-shared", "--disable-small", "--disable-swscale-alpha", "--disable-symver", "--disable-xlib",
Expand Down Expand Up @@ -362,6 +375,6 @@ class LibFFMPEGBuilder: Builder {
"--enable-filter=avgblur_vulkan", "--enable-filter=blend_vulkan", "--enable-filter=bwdif_vulkan",
"--enable-filter=chromaber_vulkan", "--enable-filter=flip_vulkan", "--enable-filter=gblur_vulkan",
"--enable-filter=hflip_vulkan", "--enable-filter=nlmeans_vulkan", "--enable-filter=overlay_vulkan",
"--enable-filter=vflip_vulkan", "--enable-filter=xfade_vulkan","--enable-filter=subtitles","--enable-filter=drawbox"
"--enable-filter=vflip_vulkan", "--enable-filter=xfade_vulkan","--enable-filter=subtitles","--enable-filter=drawbox","--enable-filter=myfilter"
]
}
6 changes: 3 additions & 3 deletions FFMPEGBuilder/LibBuilders/LibShadercBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ class LibShadercBuilder: Builder {
}

override func frameworks() -> [String] {
["libshaderc_combined"]
["libshaderccombined"]
}

override func postBuild(platform: PlatformType, arch: ArchType) {
super.postBuild(platform: platform, arch: arch)
let thinDir = lib.thin(platform: platform, arch: arch)
let pkgconfig = thinDir + "lib/pkgconfig"
do {
try FileManager.default.moveItem(at: pkgconfig + "shaderc.pc", to: pkgconfig + "shaderc_shared.pc")
try FileManager.default.moveItem(at: pkgconfig + "shaderc_combined.pc", to: pkgconfig + "shaderc.pc")
try FileManager.default.moveItem(at: pkgconfig + "shaderc.pc", to: pkgconfig + "shadercshared.pc")
try FileManager.default.moveItem(at: pkgconfig + "shaderccombined.pc", to: pkgconfig + "shaderc.pc")
} catch {
print("LibShadercBuilder moveItem error \(error)")
}
Expand Down
1 change: 1 addition & 0 deletions FFMPEGBuilder/LibBuilders/LibassBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class LibassBuilder: Builder {
"--disable-shared",
"--disable-fast-install",
"--disable-dependency-tracking",
"--disable-libunibreak",
"--host=\(platform.host(arch: arch))",
"--prefix=\(lib.thin(platform: platform, arch: arch).path)",
]
Expand Down
8 changes: 8 additions & 0 deletions FFMPEGBuilder/LibBuilders/LibmpvBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ class LibmpvBuilder: Builder {
override func flagsDependencelibrarys() -> [Library] {
[.gmp, .libsmbclient]
}

override func cFlags(platform: PlatformType, arch: ArchType) -> [String] {
var cFlags = super.cFlags(platform: platform, arch: arch)
cFlags.append("-Wno-incompatible-function-pointer-types")
return cFlags
}

override func arguments(platform: PlatformType, arch: ArchType) -> [String] {
var array = [
Expand All @@ -56,6 +62,8 @@ class LibmpvBuilder: Builder {
array.append("-Dvideotoolbox-gl=disabled")
array.append("-Dswift-build=disabled")
array.append("-Daudiounit=enabled")
array.append("-Dcoreaudio=disabled")
array.append("-Davfoundation=disabled")
if platform == .maccatalyst {
array.append("-Dcocoa=disabled")
array.append("-Dcoreaudio=disabled")
Expand Down
5 changes: 5 additions & 0 deletions FFMPEGBuilder/LibBuilders/LibsmbclientBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class LibsmbclientBuilder: Builder {
override func cFlags(platform: PlatformType, arch: ArchType) -> [String] {
var cFlags = super.cFlags(platform: platform, arch: arch)
cFlags.append("-Wno-error=implicit-function-declaration")
cFlags.append("-D_DARWIN_USE_64_BIT_INODE")
cFlags.append("-D_FILE_OFFSET_BITS=64")
// 新添加了选项
cFlags.append("-Wno-int-conversion")
return cFlags
}

Expand All @@ -25,6 +29,7 @@ class LibsmbclientBuilder: Builder {
+ (lib.libSourceDirectory + "buildtools/bin").path)
env["PYTHONHASHSEED"] = "1"
env["WAF_MAKE"] = "1"
env["ac_cv_sizeof_off_t"] = "8"
return env
}

Expand Down
19 changes: 5 additions & 14 deletions FFMPEGBuilder/Library.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ enum Library: String, CaseIterable {
case libunibreak
case ffmpeg
case libmpv
case openssh
}

extension Library {
Expand Down Expand Up @@ -77,8 +76,6 @@ extension Library {
"https://github.com/FFmpeg/FFmpeg"
case .libmpv:
"https://github.com/mpv-player/mpv"
case .openssh:
"https://github.com/openssh/openssh-portable"
}
}

Expand Down Expand Up @@ -113,7 +110,7 @@ extension Library {
case .libfribidi:
"v1.0.12"
case .libharfbuzz:
"5.3.1"
"8.5.0"
case .libass:
"0.17.1-branch"
case .libfontconfig:
Expand All @@ -123,11 +120,9 @@ extension Library {
case .libunibreak:
"libunibreak_6_1"
case .ffmpeg:
"n6.1"
"n7.0.2"
case .libmpv:
"v0.37.0"
case .openssh:
"V_7_2_P2"
"v0.39.0"
}
}

Expand Down Expand Up @@ -175,8 +170,6 @@ extension Library {
LibFFMPEGBuilder(lib: self)
case .libmpv:
LibmpvBuilder(lib: self)
case .openssh:
LibOpenSSHBuilder(lib: self)
}
}

Expand Down Expand Up @@ -213,10 +206,8 @@ extension Library {
.libsrt,
.libzvbi,
.vulkan: return true
// case .openssl:
// return false
case .libsmbclient:
return true
//case .libsmbclient:
// return true
default:
return false
}
Expand Down

0 comments on commit 5c09d07

Please sign in to comment.