-
Notifications
You must be signed in to change notification settings - Fork 556
Expand file tree
/
Copy pathconfig.nims
More file actions
132 lines (120 loc) · 5.01 KB
/
config.nims
File metadata and controls
132 lines (120 loc) · 5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import std/[strformat, strutils]
var enableVpx = getEnv("DISABLE_VPX").len == 0
var enableSvtav1 = getEnv("DISABLE_SVTAV1").len == 0
var enableHevc = getEnv("DISABLE_HEVC").len == 0
var enableWhisper = getEnv("DISABLE_WHISPER").len == 0
var enableVpl = getEnv("DISABLE_VPL").len == 0 and not defined(macosx)
when defined(danger) or defined(release):
switch("define", "flto")
switch("passC", "-flto")
switch("passL", "-flto")
switch("panics", "on")
when defined(dynamic):
let ffmpegCflags = gorgeEx("pkg-config --cflags libavutil", "")
if ffmpegCflags.exitCode == 0:
switch("passC", ffmpegCflags.output.strip())
let ffmpegLibs = gorgeEx("pkg-config --libs libavfilter libavformat libavcodec libswresample libswscale libavutil", "")
if ffmpegLibs.exitCode == 0:
switch("passL", ffmpegLibs.output.strip())
else:
let buildPath = (
if hostCPU == "wasm32": "build_wasm"
elif defined(emscripten): "build_wasm64"
elif hostOS == "windows" and hostCPU == "arm64": "build_winarm"
elif hostOS == "windows" and hostCPU != "arm64": "build_win"
elif hostOS == "linux" and hostCPU == "arm": "build_armv7"
else: "build"
)
switch("passC", &"-I./{buildPath}/include")
switch("passL", &"-L./{buildPath}/lib")
when defined(emscripten):
switch("define", "noSignalHandler")
--cc:clang
--clang.exe:emcc
--clang.linkerexe:emcc
switch("passC", "-pthread")
switch("passC", "-msimd128")
switch("passC", "-g0")
switch("passL", "-pthread")
switch("passL", "-g0")
switch("passL", "-sINITIAL_MEMORY=67108864")
switch("passL", "-sALLOW_MEMORY_GROWTH=1")
switch("passL", "-Wno-pthreads-mem-growth")
switch("passL", "-sSTACK_SIZE=1048576")
switch("passL", "-sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency")
switch("passL", "-sPROXY_TO_PTHREAD=1")
switch("passL", "-sEXIT_RUNTIME=1")
switch("passL", "-sMODULARIZE=1")
switch("passL", "-sEXPORT_NAME=AutoEditor")
switch("passL", "-sEXPORTED_RUNTIME_METHODS=[FS,ENV]")
switch("passL", "-sENVIRONMENT=web,worker")
when hostCPU == "wasm32":
switch("passL", "-sMAXIMUM_MEMORY=4294967296")
else:
switch("passC", "-sMEMORY64=1")
switch("passL", "-sMEMORY64=1")
switch("passL", "-sMAXIMUM_MEMORY=17179869184") # 16 GiB
# See for details: https://simonbyrne.github.io/notes/fastmath/
switch("passC", "-fno-signaling-nans -fno-math-errno -fno-trapping-math -fno-signed-zeros")
when defined(gcc):
switch("passC", "-Wno-incompatible-pointer-types")
switch("passC", "-Wno-stringop-overflow")
if not defined(dynamic):
# Core FFmpeg libraries
switch("passL", "-lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil")
# Codec libraries
switch("passL", "-lmp3lame -lopus -lx264 -ldav1d -lz")
if enableVpx:
switch("passL", "-lvpx")
if enableSvtav1:
switch("passL", "-lSvtAv1Enc")
if enableHevc:
switch("passL", "-lx265")
when not defined(emscripten):
if enableVpl and not (hostCPU == "arm64" and hostOS == "windows") and
not (hostCPU == "arm" and hostOS == "linux"):
switch("passL", "-lvpl")
when hostOS == "macosx":
if defined(dynamic):
let (osVer, _) = gorgeEx("sw_vers -productVersion", "")
let majorVer = osVer.strip().split(".")[0]
switch("passC", "-mmacosx-version-min=" & majorVer & ".0")
switch("passL", "-mmacosx-version-min=" & majorVer & ".0")
switch("passL", "-framework VideoToolbox -framework AudioToolbox")
switch("passL", "-framework CoreFoundation -framework CoreMedia -framework CoreVideo")
elif hostOS == "windows":
switch("passL", "-lpthread -lbcrypt -lsetupapi -lole32 -luuid")
elif not defined(dynamic) and hostOS == "linux" and not defined(emscripten):
when hostCPU == "arm64":
switch("passL", "-L./build/lib/aarch64-linux-gnu")
switch("passL", "-L./build/lib64")
elif hostCPU == "arm":
switch("passL", "-L./build_armv7/lib/arm-linux-gnueabihf")
else:
switch("passL", "-L./build/lib/x86_64-linux-gnu")
switch("passL", "-L./build/lib64")
if not defined(dynamic) and enableWhisper:
switch("passL", "-lwhisper")
switch("passL", "-lggml-base")
switch("passL", "-lggml")
switch("passL", "-lggml-cpu")
when defined(macosx):
switch("passL", "-lggml-blas")
when defined(arm64):
switch("passL", "-lggml-metal")
switch("passL", "-framework Accelerate")
switch("passL", "-framework Metal -framework MetalKit -framework Foundation")
elif not (hostOS == "windows" and hostCPU == "arm64") and not defined(emscripten):
switch("passL", "-lgomp")
if not defined(dynamic):
if enableHevc or enableWhisper or defined(linux):
# Link the C++ standard library
switch("passL", when defined(macosx): "-lc++" else: "-lstdc++")
# Static linking is order-sensitive: re-add libm/libpthread at the end so
# codec libs (x264, vpx, FFmpeg) can resolve math/threading symbols.
when defined(linux) and hostCPU == "arm":
switch("passL", "-lm -lpthread")
# begin Nimble config (version 2)
when withDir(thisDir(), system.fileExists("nimble.paths")):
include "nimble.paths"
# end Nimble config