-
Notifications
You must be signed in to change notification settings - Fork 50
/
build.gradle
198 lines (175 loc) · 6.86 KB
/
build.gradle
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
apply plugin: "java-library"
if (JavaVersion.current().isJava9Compatible()) {
compileJava {
options.release = 7
}
}
targetCompatibility = 1.7
sourceCompatibility = 1.7
java {
withSourcesJar()
withJavadocJar()
}
sourceSets {
main {
java {
srcDirs = ["src/"]
}
}
}
configurations {
custom
compile.extendsFrom custom
}
dependencies {
api project(":gdx-video-core")
}
apply plugin: "com.badlogicgames.gdx.gdx-jnigen"
tasks.register('cleanFFmpeg')
clean.configure {
dependsOn 'cleanFFmpeg'
}
String checkCrossPrefix(String crossToolchain) {
def tc = crossToolchain
if (tc == null || System.getProperty("os.name").startsWith("Win")) return ""
def result = project.exec {
ignoreExitValue = true
commandLine "bash", "-l", "-c",
"(command -v $tc-g++ && command -v $tc-ar && command -v $tc-ld)>/dev/null"
}
if(result.getExitValue() == 0) {
return "$tc-"
}
return ""
}
void registerBuild(String buildName, String crossToolchain, String... extraArgs) {
String buildDir = "FFmpeg/build-${buildName.toLowerCase()}"
tasks.register("cleanFFmpeg$buildName", Delete) {
delete buildDir
}
cleanFFmpeg.configure {
dependsOn "cleanFFmpeg$buildName"
}
tasks.register("buildFFmpeg$buildName") {
doFirst {
mkdir buildDir
String[] crossArgs = []
def crossPrefix = checkCrossPrefix(crossToolchain)
if(!crossPrefix.isEmpty()) {
crossArgs = ["--enable-cross-compile", "--cross-prefix=$crossPrefix"]
}
project.exec {
workingDir buildDir
executable '../configure'
args '--enable-pic', '--disable-symver', '--disable-doc', '--disable-shared', '--enable-static'
args crossArgs
args '--disable-everything'
args '--enable-protocol=file', '--enable-filter=aresample', '--enable-filter=deshake'
args '--enable-demuxer=ogg', '--enable-demuxer=matroska'
args '--enable-decoder=vorbis', '--enable-decoder=opus'
args '--enable-decoder=vp8', '--enable-decoder=vp9', '--enable-decoder=theora', '--enable-decoder=av1'
// Uncomment the following line for MP4 video support:
// args '--enable-demuxer=mov', '--enable-decoder=aac', '--enable-decoder=h264', '--enable-decoder=hevc'
args extraArgs
}
project.exec {
workingDir buildDir
commandLine 'make', '-j16'
}
}
outputs.upToDateWhen { file("$buildDir/libavformat/libavformat.a").exists() }
}
}
registerBuild 'Windows32', 'i686-w64-mingw32', '--arch=x86', '--target-os=mingw32'
registerBuild 'Windows64', 'x86_64-w64-mingw32', '--arch=x86_64', '--target-os=mingw32'
registerBuild 'Linux64', 'x86_64-linux-gnu', '--arch=x86_64', '--target-os=linux', '--disable-cuda', '--disable-cuvid'
registerBuild 'LinuxARM32', 'arm-linux-gnueabihf', '--arch=arm', '--target-os=linux'
registerBuild 'LinuxARM64', 'aarch64-linux-gnu', '--arch=aarch64', '--target-os=linux'
registerBuild 'Macos64', null, '--enable-cross-compile', '--arch=x86_64', '--target-os=darwin', '--cc=clang', '--cxx=clang++', '--dep-cc=clang',
'--extra-cflags=-mmacosx-version-min=10.11 -arch x86_64', '--extra-cxxflags=-mmacosx-version-min=10.11 -arch x86_64', '--extra-ldflags=-mmacosx-version-min=10.11 -arch x86_64'
registerBuild 'MacosARM64', null, '--enable-cross-compile', '--arch=arm64', '--target-os=darwin', '--cc=clang', '--cxx=clang++', '--dep-cc=clang',
'--extra-cflags=-mmacosx-version-min=10.11 -arch arm64', '--extra-cxxflags=-mmacosx-version-min=10.11 -arch arm64', '--extra-ldflags=-mmacosx-version-min=10.11 -arch arm64'
jnigen {
sharedLibName = "gdx-video-desktop"
all {
headerDirs = ["../FFmpeg"]
cFlags += " -fvisibility=hidden "
cppFlags += " -fvisibility=hidden "
//Using `-lavcodec -lavformat` order on linux drops filesize by half but mingw wont compile???
libraries += " -lavformat -lavcodec -lavutil -lswscale -lswresample -lpthread "
}
def genLibs = { String buildName ->
String libraries = ''
String absPath = file("FFmpeg/build-$buildName").absolutePath
libraries += " -L$absPath/libavcodec"
libraries += " -L$absPath/libavformat"
libraries += " -L$absPath/libavutil"
libraries += " -L$absPath/libswscale"
libraries += " -L$absPath/libswresample"
return libraries
}
add(Windows, x32) {
headerDirs += "../FFmpeg/build-windows32/"
cppFlags += " -DWIN32 "
libraries += genLibs("windows32") + " -lbcrypt -lws2_32"
}
add(Windows, x64) {
headerDirs += "../FFmpeg/build-windows64/"
cppFlags += " -DWIN32 "
libraries += genLibs("windows64") + " -lbcrypt -lws2_32"
}
add(Linux, x64) {
headerDirs += "../FFmpeg/build-linux64/"
libraries += genLibs("linux64")
compilerPrefix = checkCrossPrefix('x86_64-linux-gnu')
linkerFlags += " -Wl,-Bsymbolic "
}
add(Linux, x32, ARM) {
headerDirs += "../FFmpeg/build-linuxarm32/"
libraries += genLibs("linuxarm32")
linkerFlags += " -Wl,-Bsymbolic "
}
add(Linux, x64, ARM) {
headerDirs += "../FFmpeg/build-linuxarm64/"
libraries += genLibs("linuxarm64")
linkerFlags += " -Wl,-Bsymbolic "
}
add(MacOsX, x64) {
headerDirs += "../FFmpeg/build-macos64/"
libraries += genLibs("macos64") + " -liconv -lbz2 -lz -framework CoreFoundation -framework CoreVideo"
cFlags += " -mmacosx-version-min=10.11"
cppFlags += " -mmacosx-version-min=10.11"
linkerFlags += " -mmacosx-version-min=10.11"
}
add(MacOsX, x64, ARM) {
headerDirs += "../FFmpeg/build-macosarm64/"
libraries += genLibs("macosarm64") + " -liconv -lbz2 -lz -framework CoreFoundation -framework CoreVideo"
cFlags += " -mmacosx-version-min=10.11"
cppFlags += " -mmacosx-version-min=10.11"
linkerFlags += " -mmacosx-version-min=10.11"
}
}
tasks.register('buildFFmpegWindowsAll') {
dependsOn buildFFmpegWindows32, buildFFmpegWindows64
}
tasks.register('buildFFmpegLinuxAll') {
dependsOn buildFFmpegLinux64, buildFFmpegLinuxARM32, buildFFmpegLinuxARM64
}
tasks.register('buildFFmpegMacosAll') {
dependsOn buildFFmpegMacos64, buildFFmpegMacosARM64
}
tasks.register('jnigenBuildWindowsAll') {
dependsOn jnigenBuildWindows, jnigenBuildWindows64
}
tasks.register('jnigenBuildLinuxAll') {
dependsOn jnigenBuildLinux64, jnigenBuildLinuxARM, jnigenBuildLinuxARM64
}
tasks.register('jnigenBuildMacosAll') {
dependsOn jnigenBuildMacOsX64, jnigenBuildMacOsXARM64
}
jar {
from fileTree("libs").files
}
eclipse.project {
name = projectGroup + "-desktop"
}