@@ -18,6 +18,7 @@ class GenerateLibs extends DefaultTask {
18
18
private final boolean forMac64 = buildEnvs?. contains(' mac64' )
19
19
20
20
private final boolean isLocal = System . properties. containsKey(" local" )
21
+ private final boolean withFreeType = System . properties. containsKey(" withFreeType" )
21
22
22
23
private final String sourceDir = project. file(' src/main/java' )
23
24
private final String classpath = project. file(' build/classes/java/main' )
@@ -27,13 +28,23 @@ class GenerateLibs extends DefaultTask {
27
28
28
29
@TaskAction
29
30
void generate () {
31
+ println ' Generating Native Libraries...'
32
+ println " Build environments: $buildEnvs "
33
+ println " Local mode: $isLocal "
34
+ println " With FreeType: $withFreeType "
35
+ println ' ====================================='
36
+
30
37
// Generate h/cpp files for JNI
31
38
new NativeCodeGenerator (). generate(sourceDir, classpath, jniDir)
32
39
33
40
// Copy ImGui h/cpp files
34
41
project. copy { CopySpec spec ->
35
42
spec. from(project. rootProject. file(' imgui' )) { CopySpec it -> it. include(' *.h' , ' *.cpp' ) }
36
- spec. from(project. rootProject. file(' imgui/misc/freetype' )) { CopySpec it -> it. include(' *.h' , ' *.cpp' ) }
43
+
44
+ if (withFreeType) {
45
+ spec. from(project. rootProject. file(' imgui/misc/freetype' )) { CopySpec it -> it. include(' *.h' , ' *.cpp' ) }
46
+ }
47
+
37
48
spec. from(project. rootProject. file(' imgui-binding/src/main/native' ))
38
49
spec. into(jniDir)
39
50
}
@@ -44,27 +55,43 @@ class GenerateLibs extends DefaultTask {
44
55
45
56
if (forWin32) {
46
57
def win32 = BuildTarget . newDefaultTarget(BuildTarget.TargetOs.Windows , false )
47
- win32. cppFlags + = ' -fstack-protector -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
48
- win32. libraries + = ' -lfreetype -lbz2 -lssp'
58
+
59
+ if (withFreeType) {
60
+ win32. cppFlags + = ' -fstack-protector -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
61
+ win32. libraries + = ' -lfreetype -lbz2 -lssp'
62
+ }
63
+
49
64
buildTargets + = win32
50
65
}
51
66
if (forWin64) {
52
67
def win64 = BuildTarget . newDefaultTarget(BuildTarget.TargetOs.Windows , true )
53
- win64. cppFlags + = ' -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
54
- win64. libraries + = ' -lfreetype -lbz2 -lssp'
68
+
69
+ if (withFreeType) {
70
+ win64. cppFlags + = ' -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
71
+ win64. libraries + = ' -lfreetype -lbz2 -lssp'
72
+ }
73
+
55
74
buildTargets + = win64
56
75
}
57
76
58
77
if (forLinux32) {
59
78
def linux32 = BuildTarget . newDefaultTarget(BuildTarget.TargetOs.Linux , false )
60
- linux32. cppFlags + = ' -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
61
- linux32. linkerFlags + = ' -lfreetype'
79
+
80
+ if (withFreeType) {
81
+ linux32. cppFlags + = ' -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
82
+ linux32. linkerFlags + = ' -lfreetype'
83
+ }
84
+
62
85
buildTargets + = linux32
63
86
}
64
87
if (forLinux64) {
65
88
def linux64 = BuildTarget . newDefaultTarget(BuildTarget.TargetOs.Linux , true )
66
- linux64. cppFlags + = ' -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
67
- linux64. linkerFlags + = ' -lfreetype'
89
+
90
+ if (withFreeType) {
91
+ linux64. cppFlags + = ' -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include'
92
+ linux64. linkerFlags + = ' -lfreetype'
93
+ }
94
+
68
95
buildTargets + = linux64
69
96
}
70
97
@@ -73,13 +100,23 @@ class GenerateLibs extends DefaultTask {
73
100
mac64. cppFlags + = ' -stdlib=libc++'
74
101
mac64. cppFlags = mac64. cppFlags. replaceAll(' 10.5' , ' 10.9' )
75
102
mac64. linkerFlags = mac64. linkerFlags. replaceAll(' 10.5' , ' 10.9' )
76
- mac64. cppFlags + = ' -I/usr/local/include/freetype2 -I/usr/local/include/libpng16 -I/usr/local/include/harfbuzz -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include'
77
- mac64. linkerFlags + = ' -lfreetype'
103
+
104
+ if (withFreeType) {
105
+ mac64. cppFlags + = ' -I/usr/local/include/freetype2 -I/usr/local/include/libpng16 -I/usr/local/include/harfbuzz -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include'
106
+ mac64. linkerFlags + = ' -lfreetype'
107
+ }
108
+
78
109
buildTargets + = mac64
79
110
}
80
111
81
112
new AntScriptGenerator (). generate(buildConfig, buildTargets)
82
113
114
+ if (! withFreeType) {
115
+ project. delete {
116
+ it. delete(" $jniDir /imgui.ImGuiFreeType.cpp" , " $jniDir /imgui.ImGuiFreeType.h" )
117
+ }
118
+ }
119
+
83
120
// Generate native libraries
84
121
// Comment/uncomment lines with OS you need.
85
122
0 commit comments