Commit 55934507 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Compress background & tileset SVGs to SVGZ on installation

parent f9311151
......@@ -7,7 +7,7 @@ set(KF_MIN_VERSION "5.85.0")
find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH})
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${ECM_MODULE_PATH})
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
......@@ -27,13 +27,16 @@ include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(FeatureSummary)
include(GenerateExportHeader)
include(CMakePackageConfigHelpers)
include(ECMSetupVersion)
include(ECMGenerateHeaders)
include(ECMQtDeclareLoggingCategory)
include(GenerateExportHeader)
include(CMakePackageConfigHelpers)
include(FeatureSummary)
include(InternalMacros)
add_definitions(
-DQT_DISABLE_DEPRECATED_BEFORE=0x050F00
-DQT_DEPRECATED_WARNINGS_SINCE=0x060000
......
Copyright (c) <year> <owner>. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
function(install_svg_background id)
set(svgz "${CMAKE_CURRENT_BINARY_DIR}/${id}.svgz")
generate_svgz(${id}.svg ${svgz} "background-")
install(
FILES
${id}.desktop
${id}.svg
${svgz}
${id}.copyright
DESTINATION ${KDE_INSTALL_DATADIR}/kmahjongglib/backgrounds
)
......
......@@ -109,5 +109,5 @@ VersionFormat=1
Author=Eugene Trounev
AuthorEmail=eugene.trounev@gmail.com
Type=SVG
FileName=chinese_landscape.svg
FileName=chinese_landscape.svgz
Tiled=0
......@@ -112,7 +112,7 @@ VersionFormat=1
Author=Raquel Ravanini
AuthorEmail=raquel@tabuleiro.com
Type=SVG
FileName=default.svg
FileName=default.svgz
Tiled=1
Width=50
Height=70
......@@ -96,4 +96,4 @@ VersionFormat=1
Author=Sean Wilson
AuthorEmail=suseux@gmail.com
Type=SVG
FileName=egyptian.svg
FileName=egyptian.svgz
......@@ -100,5 +100,5 @@ VersionFormat=1
Author=Eugene Trounev
AuthorEmail=eugene.trounev@gmail.com
Type=SVG
FileName=summerfield.svg
FileName=summerfield.svgz
Tiled=0
......@@ -105,7 +105,7 @@ VersionFormat=1
Author=Raquel Ravanini
AuthorEmail=raquel@tabuleiro.com
Type=SVG
FileName=wood_light.svg
FileName=wood_light.svgz
Tiled=1
Width=205
Height=180
# SPDX-FileCopyrightText: 2021 Friedrich W. H. Kossebau <kossebau@kde.org>
#
# SPDX-License-Identifier: BSD-3-Clause
if(WIN32)
find_package(7z)
set_package_properties(7z PROPERTIES
TYPE REQUIRED
PURPOSE "For installing SVG files as SVGZ"
)
else()
find_package(gzip)
set_package_properties(gzip PROPERTIES
TYPE REQUIRED
PURPOSE "For installing SVG files as SVGZ"
)
endif()
function(generate_svgz svg_file svgz_file target_prefix)
if (NOT IS_ABSOLUTE ${svg_file})
set(svg_file "${CMAKE_CURRENT_SOURCE_DIR}/${svg_file}")
endif()
if (NOT EXISTS ${svg_file})
message(FATAL_ERROR "No such file found: ${svg_file}")
endif()
get_filename_component(_fileName "${svg_file}" NAME)
if(WIN32)
add_custom_command(
OUTPUT ${svgz_file}
COMMAND 7z::7z
ARGS
a
-tgzip
${svgz_file} ${svg_file}
DEPENDS ${svg_file}
COMMENT "Gzipping ${_fileName}"
)
else()
add_custom_command(
OUTPUT ${svgz_file}
COMMAND ${gzip_EXECUTABLE}
ARGS
-9
-c
${svg_file} > ${svgz_file}
DEPENDS ${svg_file}
COMMENT "Gzipping ${_fileName}"
)
endif()
add_custom_target("${target_prefix}${_fileName}z" ALL DEPENDS ${svgz_file})
endfunction()
function(install_tileset id)
set(svgz "${CMAKE_CURRENT_BINARY_DIR}/${id}.svgz")
generate_svgz(${id}.svg ${svgz} "tileset-")
install(
FILES
${id}.desktop
${id}.svg
${svgz}
${id}.copyright
DESTINATION ${KDE_INSTALL_DATADIR}/kmahjongglib/tilesets
)
......
......@@ -105,7 +105,7 @@ Description[zh_TW]=彩色的外觀,為各年齡層的小朋友設計的。
VersionFormat=1
Author=Raquel Ravanini
AuthorEmail=raquel@tabuleiro.com
FileName=alphabet.svg
FileName=alphabet.svgz
LevelOffsetX=28
LevelOffsetY=32
TileFaceWidth=173
......
......@@ -89,7 +89,7 @@ Description[zh_TW]=日式的外觀,淡顏色的漢字與竹林
VersionFormat=1
Author=Matthew Woehlke
AuthorEmail=mw_triad@users.sourceforge.net
FileName=bamboo.svg
FileName=bamboo.svgz
LevelOffsetX=10
LevelOffsetY=10
TileFaceHeight=100
......
......@@ -109,7 +109,7 @@ Description[zh_TW]=中國式麻將牌,從傳統的 KDE3 版本而來
VersionFormat=1
Author=Robert Buchholz
AuthorEmail=robertbuchholz@gmx.de
FileName=classic.svg
FileName=classic.svgz
LevelOffsetX=10
LevelOffsetY=10
TileFaceHeight=95
......
......@@ -109,7 +109,7 @@ Description[zh_TW]=由實際的日本麻將牌得來的靈感
VersionFormat=1
Author=Raquel Ravanini
AuthorEmail=raquel@tabuleiro.com
FileName=default.svg
FileName=default.svgz
LevelOffsetX=12
LevelOffsetY=12
TileFaceHeight=89
......
......@@ -49,7 +49,7 @@ Name[zh_TW]=古埃及
VersionFormat=1
Author=Eugene Trounev [it-s] & Sean Wilson [Half-Left]
AuthorEmail=eugene.trounev@gmail.com; suseux@googlemail.com
FileName=egypt.svg
FileName=egypt.svgz
LevelOffsetX=12
LevelOffsetY=12
TileFaceHeight=89
......
......@@ -52,7 +52,7 @@ Name[zh_TW]=Imperial Jade
VersionFormat=1
Author=it-s
AuthorEmail=irs_me@hotmail.com
FileName=jade.svg
FileName=jade.svgz
LevelOffset=12
TileFaceHeight=86
TileFaceWidth=71
......
......@@ -104,7 +104,7 @@ Description[zh_TW]=由實際的日本麻將牌得來的靈感
VersionFormat=1
Author=James L. Hammons
AuthorEmail=jlhamm@acm.org
FileName=traditional.svg
FileName=traditional.svgz
LevelOffsetX=12
LevelOffsetY=12
TileFaceHeight=89
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment