forked from xonotic/xonotic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.cmake
217 lines (198 loc) · 8.04 KB
/
release.cmake
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# release requirements:
# a graphical environment
# vorbis-tools: vorbiscomment, oggdec, oggenc
# imagemagick: convert
# https://github.com/divVerent/s2tc.git: s2tc_compress
add_custom_target(release)
string(TIMESTAMP stamp "%Y%m%d")
string(TIMESTAMP filestamp "%Y-%m-%d")
file(STRINGS data/xonotic-data.pk3dir/xonotic-common.cfg _contents REGEX "^gameversion ")
if (NOT _contents)
message(FATAL_ERROR "xonotic-common.cfg does not contain gameversion")
else ()
string(REGEX REPLACE ".*gameversion ([0-9]+).*" "\\1" versionstr "${_contents}")
math(EXPR versionstr_major "${versionstr} / 10000")
math(EXPR versionstr_minor "${versionstr} / 100 - ${versionstr_major} * 100")
math(EXPR versionstr_patch "${versionstr} - ${versionstr_major} * 10000 - ${versionstr_minor} * 100")
set(versionstr "${versionstr_major}.${versionstr_minor}.${versionstr_patch}")
message("game version: ${versionstr}")
endif ()
# foreach repo: git tag "xonotic-v${versionstr}"
function(getbinary artifact)
find_package(Git REQUIRED)
get_filename_component(dpname ${artifact} NAME)
string(REGEX REPLACE "^xonotic" "darkplaces" dpname ${dpname})
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/darkplaces
OUTPUT_VARIABLE rev
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Downloading http://beta.xonotic.org/autobuild-bin/${rev}/${dpname}")
file(DOWNLOAD "http://beta.xonotic.org/autobuild-bin/${rev}/${dpname}"
"${PROJECT_BINARY_DIR}/${artifact}"
SHOW_PROGRESS)
endfunction()
if (0)
# TODO: build from source
message(STATUS "Downloading NetRadiant")
file(DOWNLOAD http://www.icculus.org/netradiant/files/netradiant-1.5.0-20120301.tar.bz2
"${PROJECT_BINARY_DIR}/netradiant-1.5.0-20120301.tar.bz2"
SHOW_PROGRESS
EXPECTED_HASH SHA256=5e720cd8ebd2379ee5d388dfb8f2613bfd5798fb33d16bc7415d44a11fb4eadb)
file(DOWNLOAD http://www.icculus.org/netradiant/files/netradiant-1.5.0-20120301-win32-7z.exe
"${PROJECT_BINARY_DIR}/netradiant-1.5.0-20120301-win32-7z.exe"
SHOW_PROGRESS
EXPECTED_HASH SHA256=c4bb30b6f14c3f71f1ed29fa38cddac209a7bc2ab5b38e5bf5b442106279b5c4)
endif ()
if (0)
# TODO: build from source
message(STATUS "Downloading Darkplaces")
getbinary(Xonotic/xonotic-x86.exe)
getbinary(Xonotic/xonotic-x86-dedicated.exe)
getbinary(Xonotic/xonotic.exe)
getbinary(Xonotic/xonotic-dedicated.exe)
getbinary(Xonotic/Xonotic.app/Contents/MacOS/xonotic-osx-sdl-bin) # +x
getbinary(Xonotic/xonotic-osx-dedicated) # +x
getbinary(Xonotic/xonotic-linux64-sdl) # +x
getbinary(Xonotic/xonotic-linux64-glx) # +x
getbinary(Xonotic/xonotic-linux64-dedicated) # +x
endif ()
function(buildpk3s src)
set(dir data/${src})
string(REGEX REPLACE "\\.pk3dir$" "" name ${src})
if (name MATCHES "^xonotic-")
string(REGEX REPLACE "^xonotic-" "xonotic-${stamp}-" name ${name})
else ()
set(name "${name}-${stamp}")
endif ()
file(GLOB_RECURSE files RELATIVE "${PROJECT_SOURCE_DIR}/${dir}" "${dir}/*")
string(REGEX REPLACE "\\.git/[^;]+;?" "" files "${files}")
# string(REGEX REPLACE "[^;]+(qh|inc|txt|cfg|sh|po|pl|yml|cmake);?" "" files "${files}")
foreach (pair ${ARGN})
list(GET pair 0 filter)
list(GET pair 1 flavor)
buildpk3(${name}${flavor}.pk3)
endforeach ()
endfunction()
function(buildpk3 pk3)
message("registered pk3 ${pk3}")
set(deps)
foreach (file IN LISTS files)
set(marker "done.data/${pk3}dir/${file}")
string(REPLACE "#" "_" marker ${marker}) # OUTPUT cannot contain '#'
list(APPEND deps "${marker}")
get_filename_component(rel ${file} DIRECTORY)
add_custom_command(OUTPUT ${marker}
DEPENDS "${dir}/${file}"
COMMAND ${CMAKE_COMMAND}
"-Dsrc=${PROJECT_SOURCE_DIR}/${dir}/${file}"
"-Ddst=data/${pk3}dir/${rel}"
"-Dconv=data/${pk3}dir/${file}"
-P "transform-${filter}.cmake"
VERBATIM)
endforeach ()
add_custom_target(${pk3}dir DEPENDS ${deps})
add_custom_target(${pk3}dir-zip DEPENDS ${pk3})
add_dependencies(release ${pk3}dir-zip)
add_custom_command(OUTPUT ${pk3}
DEPENDS ${pk3}dir
COMMAND ${CMAKE_COMMAND} -E tar cvf "../../${pk3}" --mtime=${filestamp} --format=zip -- * # TODO: no wildcard
WORKING_DIRECTORY "data/${pk3}dir")
endfunction()
function(deftransform name)
file(WRITE ${PROJECT_BINARY_DIR}/transform-${name}.cmake "")
set(pairs "${ARGN}")
list(APPEND pairs "del_src\;true")
foreach (pair IN LISTS pairs)
list(GET pair 0 k)
list(GET pair 1 v)
file(APPEND ${PROJECT_BINARY_DIR}/transform-${name}.cmake "set(ENV{${k}} \"${v}\")\n")
endforeach ()
file(APPEND ${PROJECT_BINARY_DIR}/transform-${name}.cmake
"execute_process(\n"
" COMMAND ${CMAKE_COMMAND} -E copy \${src} \${conv}\n"
" COMMAND ${PROJECT_SOURCE_DIR}/misc/tools/cached-converter.sh \${conv}\n"
" COMMAND ${CMAKE_COMMAND} -E make_directory done.\${conv}\n"
" COMMAND ${CMAKE_COMMAND} -E touch done.\${conv}\n"
" RESULT_VARIABLE res_var\n"
")")
endfunction()
file(WRITE ${PROJECT_BINARY_DIR}/transform-raw.cmake
"execute_process(\n"
" COMMAND ${CMAKE_COMMAND} -E copy \${src} \${conv}\n"
" COMMAND ${CMAKE_COMMAND} -E make_directory done.\${conv}\n"
" COMMAND ${CMAKE_COMMAND} -E touch done.\${conv}\n"
")")
# default to "del_src\;true"
deftransform(normal
# texture: convert to jpeg and dds
"do_jpeg\;true"
"jpeg_qual_rgb\;97"
"jpeg_qual_a\;99"
"do_dds\;false"
"do_ogg\;true"
"ogg_ogg\;false")
deftransform(normaldds
# texture: convert to jpeg and dds
# music: reduce bitrate
"do_jpeg\;false"
"do_jpeg_if_not_dds\;true"
"jpeg_qual_rgb\;95"
"jpeg_qual_a\;99"
"do_dds\;true"
"dds_flags\;"
"do_ogg\;true"
"ogg_ogg\;false")
deftransform(low
# texture: convert to jpeg and dds
# music: reduce bitrate
"do_jpeg\;true"
"jpeg_qual_rgb\;80"
"jpeg_qual_a\;97"
"do_dds\;false"
"do_ogg\;true"
"ogg_qual\;1")
deftransform(webp
# texture: convert to jpeg and dds
"do_jpeg\;false"
"do_webp\;true"
"do_dds\;false"
"do_ogg\;false"
"ogg_ogg\;false")
deftransform(lowdds
# texture: convert to jpeg and dds
# music: reduce bitrate
"do_jpeg\;false"
"do_jpeg_if_not_dds\;true"
"jpeg_qual_rgb\;80"
"jpeg_qual_a\;99"
"do_dds\;true"
"dds_flags\;"
"do_ogg\;true"
"ogg_qual\;1")
deftransform(mapping
# texture: convert to jpeg and dds
# music: reduce bitrate
"do_jpeg\;true"
"jpeg_qual_rgb\;80"
"jpeg_qual_a\;97"
"do_dds\;false"
"do_ogg\;true"
"ogg_qual\;1"
)
## remove stuff radiant has no use for
#verbose find . -name \*_norm.\* -exec rm -f {} \;
#verbose find . -name \*_bump.\* -exec rm -f {} \;
#verbose find . -name \*_glow.\* -exec rm -f {} \;
#verbose find . -name \*_gloss.\* -exec rm -f {} \;
#verbose find . -name \*_pants.\* -exec rm -f {} \;
#verbose find . -name \*_shirt.\* -exec rm -f {} \;
#verbose find . -name \*_reflect.\* -exec rm -f {} \;
#verbose find . -not \( -name \*.tga -o -name \*.png -o -name \*.jpg \) -exec rm -f {} \;
buildpk3s(font-unifont.pk3dir "raw\;")
buildpk3s(font-xolonium.pk3dir "raw\;")
buildpk3s(xonotic-data.pk3dir "low\;-low" "normaldds\;" "normal\;-high")
buildpk3s(xonotic-maps.pk3dir "low\;-low" "normaldds\;" "normal\;-high" "mapping\;-mapping")
buildpk3s(xonotic-music.pk3dir "raw\;" "low\;-low")
buildpk3s(xonotic-nexcompat.pk3dir "normaldds\;")
message("CMake may appear to halt at '-- Configuring done', this is not the case")