From 7e4acc7c3505ed5cedcf1dbc7a71d3adcd39f8a4 Mon Sep 17 00:00:00 2001 From: TimePath Date: Mon, 21 Mar 2016 23:08:11 +1100 Subject: [PATCH] CMake: port most of the release script --- .gitignore | 1 + CMakeLists.txt | 7 ++ release.cmake | 219 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 227 insertions(+) create mode 100644 release.cmake diff --git a/.gitignore b/.gitignore index 100ef0b1..f590f872 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/build/ /darkplaces /fteqcc /gmqcc diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dbabfbe..c1e0adb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,3 +5,10 @@ add_subdirectory(darkplaces) add_subdirectory(data/xonotic-data.pk3dir) add_subdirectory(gmqcc) add_subdirectory(netradiant) + +add_custom_target(update-maps ALL + COMMAND ${PROJECT_SOURCE_DIR}/misc/tools/xonotic-map-compiler-autobuild download + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) + +include(release.cmake) diff --git a/release.cmake b/release.cmake new file mode 100644 index 00000000..94128251 --- /dev/null +++ b/release.cmake @@ -0,0 +1,219 @@ +# 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") + +file(STRINGS data/xonotic-data.pk3dir/defaultXonotic.cfg _contents REGEX "^gameversion ") +if (NOT _contents) + message(FATAL_ERROR "defaultXonotic.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-wgl.exe) + getbinary(Xonotic/xonotic-x86-dedicated.exe) + getbinary(Xonotic/xonotic.exe) + getbinary(Xonotic/xonotic-wgl.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-linux32-sdl) # +x + getbinary(Xonotic/xonotic-linux32-glx) # +x + getbinary(Xonotic/xonotic-linux32-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) + get_filename_component(rel ${file} DIRECTORY) + set(marker "done.data/${pk3}/${file}") + string(REPLACE "#" "_" marker ${marker}) # OUTPUT cannot contain '#' + add_custom_command(OUTPUT ${marker} + COMMAND ${CMAKE_COMMAND} + "-Dsrc=${PROJECT_SOURCE_DIR}/${dir}/${file}" + "-Ddst=data/${pk3}/${rel}" + "-Dconv=data/${pk3}/${file}" + -P "transform-${filter}.cmake" + VERBATIM) + list(APPEND deps ${marker}) + endforeach () + add_custom_target(${pk3} DEPENDS ${deps}) + add_custom_target(${pk3}-zip DEPENDS ${pk3}.zip) + add_dependencies(release ${pk3}-zip) + add_custom_command(OUTPUT ${pk3}.zip + DEPENDS ${pk3} + COMMAND ${CMAKE_COMMAND} -E tar "cfv" "../../${pk3}.zip" --format=zip * + WORKING_DIRECTORY "data/${pk3}") +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" + " 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" + ")") + +# 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") -- 2.39.2