Commit a381d31b authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Properly workaround xsltproc not handling spaces in filepaths on Windows

All CMake code that executes xsltproc is wrapped to functions that
ensure that arguments passed to xsltproc are all relative paths,
thus avoiding issues with spaces in the source/build dir parent
path containing spaces, which xsltproc on Windows just does not
like.

It also simplifies some of the CMake code and moves the
kcfg_generate_dbus_interface macro into KF5AkonadiMacros
so that we don't have to have a dedicated copies (that would all
need fixing) all over KDE PIM.

(Cherry-picked from couple of commits on master)
parent 5552cffc
......@@ -95,3 +95,34 @@ function(add_akonadi_isolated_test_advanced source additional_sources link_libra
LINK_LIBRARIES "${link_libraries}"
)
endfunction()
function(kcfg_generate_dbus_interface _kcfg _name)
if (NOT XSLTPROC_EXECUTABLE)
message(FATAL_ERROR "xsltproc executable not found but needed by KCFG_GENERATE_DBUS_INTERFACE()")
endif()
# When using this macro inside Akonadi, we need to refer to the file in the
# repo
if (Akonadi_SOURCE_DIR)
set(xsl_path ${Akonadi_SOURCE_DIR}/src/core/kcfg2dbus.xsl)
else()
set(xsl_path ${KF5Akonadi_DATA_DIR}/kcfg2dbus.xsl)
endif()
file(RELATIVE_PATH xsl_relpath ${CMAKE_CURRENT_BINARY_DIR} ${xsl_path})
if (IS_ABSOLUTE ${_kcfg})
file(RELATIVE_PATH kcfg_relpath ${CMAKE_CURRENT_BINARY_DIR} ${_kcfg})
else()
file(RELATIVE_PATH kcfg_relpath ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfg})
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
COMMAND ${XSLTPROC_EXECUTABLE}
--output ${_name}.xml
--stringparam interfaceName ${_name}
${xsl_relpath}
${kcfg_relpath}
DEPENDS
${xsl_path}
${_kcfg}
)
endfunction()
......@@ -2,29 +2,13 @@ include_directories(
${Boost_INCLUDE_DIR}
)
include(${CMAKE_SOURCE_DIR}/KF5AkonadiMacros.cmake)
kde_enable_exceptions()
remove_definitions(-DTRANSLATION_DOMAIN=\"libakonadi5\")
add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_knut_resource\")
find_package(LibXslt)
set_package_properties(LibXslt PROPERTIES DESCRIPTION "xsltproc" URL "http://xmlsoft.org/XSLT/" TYPE REQUIRED PURPOSE "Needed to generate D-Bus interface specifications")
find_program(XSLTPROC_EXECUTABLE xsltproc DOC "Path to the xsltproc executable")
# generates a D-Bus interface description from a KConfigXT file
macro(kcfg_generate_dbus_interface _kcfg _name)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
COMMAND ${XSLTPROC_EXECUTABLE} --stringparam interfaceName ${_name}
${Akonadi_SOURCE_DIR}/src/core/kcfg2dbus.xsl
${_kcfg}
> ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
DEPENDS ${Akonadi_SOURCE_DIR}/src/core/kcfg2dbus.xsl
${_kcfg}
)
endmacro()
# Disabled for now, resourcetester remained in kdepim-runtime
#add_subdirectory( tests )
......
......@@ -9,18 +9,16 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_BINARY_DIR}/src/server
${Akonadi_SOURCE_DIR}/src/server)
akonadi_generate_schema(${CMAKE_CURRENT_SOURCE_DIR}/dbtest_data/unittest_schema.xml UnitTestSchema unittestschema)
set(AKONADI_DB_DATA ${CMAKE_CURRENT_SOURCE_DIR}/dbtest_data/dbdata.xml)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dbpopulator.cpp
COMMAND ${XSLTPROC_EXECUTABLE}
--output ${CMAKE_CURRENT_BINARY_DIR}/dbpopulator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dbpopulator.xsl
${AKONADI_DB_DATA}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dbpopulator.xsl
${AKONADI_DB_DATA}
akonadi_run_xsltproc(
XSL ${Akonadi_SOURCE_DIR}/src/server/storage/schema.xsl
XML ${CMAKE_CURRENT_SOURCE_DIR}/dbtest_data/unittest_schema.xml
BASENAME unittestschema
CLASSNAME UnitTestSchema
)
akonadi_run_xsltproc(
XSL ${CMAKE_CURRENT_SOURCE_DIR}/dbpopulator.xsl
XML ${CMAKE_CURRENT_SOURCE_DIR}/dbtest_data/dbdata.xml
BASENAME dbpopulator
)
set(common_SRCS
......
/*
* Copyright (C) 2014 Daniel Vrátil <dvratil@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef AKONADI_SERVER_DBPOPULATOR_H
#define AKONADI_SERVER_DBPOPULATOR_H
namespace Akonadi {
namespace Server {
class DbPopulator
{
public:
DbPopulator();
~DbPopulator();
bool run();
};
}
}
#endif // AKONADI_SERVER_DBPOPULATOR_H
......@@ -315,8 +315,36 @@
<xsl:template match="/">
<!-- Header generation //-->
<xsl:if test="$code='header'">
/*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef AKONADI_SERVER_DBPOPULATOR_H
#define AKONADI_SERVER_DBPOPULATOR_H
namespace Akonadi {
namespace Server {
class DbPopulator
{
public:
DbPopulator();
~DbPopulator();
bool run();
};
}
}
#endif
</xsl:if>
<!-- Source generation //-->
<xsl:if test="$code='source'">
/*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
......@@ -394,6 +422,7 @@ bool DbPopulator::run()
qDebug() &lt;&lt; "Database successfully populated";
return true;
}
</xsl:if>
</xsl:template>
......
......@@ -21,27 +21,87 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Internal server macros
function(akonadi_run_xsltproc)
if (NOT XSLTPROC_EXECUTABLE)
message(FATAL_ERROR "xsltproc executable not found but needed by AKONADI_RUN_XSLTPROC()")
endif()
set(options )
set(oneValueArgs XSL XML CLASSNAME BASENAME)
set(multiValueArgs )
cmake_parse_arguments(XSLT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT XSLT_XSL)
message(FATAL_ERROR "Required argument XSL missing in AKONADI_RUN_XSLTPROC() call")
endif()
if (NOT XSLT_XML)
message(FATAL_ERROR "Required argument XML missing in AKONADI_RUN_XSLTPROC() call")
endif()
if (NOT XSLT_BASENAME)
message(FATAL_ERROR "Required argument BASENAME missing in AKONADI_RUN_XSLTPROC() call")
endif()
# Workaround xsltproc struggling with spaces in filepaths on Windows
file(RELATIVE_PATH xsl_relpath ${CMAKE_CURRENT_BINARY_DIR} ${XSLT_XSL})
file(RELATIVE_PATH xml_relpath ${CMAKE_CURRENT_BINARY_DIR} ${XSLT_XML})
set(extra_params )
if (XSLT_CLASSNAME)
set(extra_params --stringparam className ${XSLT_CLASSNAME})
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${XSLT_BASENAME}.h
${CMAKE_CURRENT_BINARY_DIR}/${XSLT_BASENAME}.cpp
COMMAND ${XSLTPROC_EXECUTABLE}
--output ${XSLT_BASENAME}.h
--stringparam code header
--stringparam fileName ${XSLT_BASENAME}
${extra_params}
${xsl_relpath}
${xml_relpath}
COMMAND ${XSLTPROC_EXECUTABLE}
--output ${XSLT_BASENAME}.cpp
--stringparam code source
--stringparam fileName ${XSLT_BASENAME}
${extra_params}
${xsl_relpath}
${xml_relpath}
DEPENDS ${XSLT_XSL}
${XSLT_XML}
)
set_property(SOURCE
${CMAKE_CURRENT_BINARY_DIR}/${XSLT_BASENAME}.cpp
${CMAKE_CURRENT_BINARY_DIR}/${XSLT_BASENAME}.h
PROPERTY SKIP_AUTOMOC TRUE
)
endfunction()
macro(akonadi_generate_schema _schemaXml _className _fileBaseName)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_fileBaseName}.h
${CMAKE_CURRENT_BINARY_DIR}/${_fileBaseName}.cpp
COMMAND ${XSLTPROC_EXECUTABLE}
--output ${CMAKE_CURRENT_BINARY_DIR}/${_fileBaseName}.h
--stringparam code header
--stringparam className ${_className}
--stringparam fileName ${_fileBaseName}
${Akonadi_SOURCE_DIR}/src/server/storage/schema.xsl
${_schemaXml}
COMMAND ${XSLTPROC_EXECUTABLE}
--output ${CMAKE_CURRENT_BINARY_DIR}/${_fileBaseName}.cpp
--stringparam code source
--stringparam className ${_className}
--stringparam fileName ${_fileBaseName}
${Akonadi_SOURCE_DIR}/src/server/storage/schema.xsl
${_schemaXml}
DEPENDS ${Akonadi_SOURCE_DIR}/src/server/storage/schema.xsl
${Akonadi_SOURCE_DIR}/src/server/storage/schema-header.xsl
${Akonadi_SOURCE_DIR}/src/server/storage/schema-source.xsl
${_schemaXml}
)
if (NOT XSLTPROC_EXECUTABLE)
message(FATAL_ERROR "xsltproc executable not found but needed by AKONADI_GENERATE_SCHEMA()")
endif()
akonadi_run_xsltproc(
XSL ${Akonadi_SOURCE_DIR}/src/server/storage/schema.xsl
XML ${_schemaXml}
CLASSNAME ${_className}
BASENAME ${_fileBaseName}
)
endmacro()
function(akonadi_add_xmllint_test)
if (NOT XMLLINT_EXECUTABLE)
message(FATAL_ERROR "xmllint executable not found but needed by AKONADI_ADD_XMLLINT_SCHEMA()")
endif()
set(options )
set(oneValueArgs XML XSD)
set(multiValueArgs )
cmake_parse_arguments(TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
file(RELATIVE_PATH xsd_relpath ${CMAKE_CURRENT_BINARY_DIR} ${TEST_XSD})
file(RELATIVE_PATH xml_relpath ${CMAKE_CURRENT_BINARY_DIR} ${TEST_XML})
add_test(${TEST_UNPARSED_ARGUMENTS} ${XMLLINT_EXECUTABLE} --noout --schema ${xsd_relpath} ${xml_relpath})
endfunction()
# 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 copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
#
# Find xsltproc executable and provide a macro to generate D-Bus interfaces.
#
# The following variables are defined :
# XSLTPROC_EXECUTABLE - path to the xsltproc executable
# Xsltproc_FOUND - true if the program was found
#
find_program(XSLTPROC_EXECUTABLE xsltproc DOC "Path to the xsltproc executable")
mark_as_advanced(XSLTPROC_EXECUTABLE)
if(XSLTPROC_EXECUTABLE)
set(Xsltproc_FOUND TRUE)
# Macro to generate a D-Bus interface description from a KConfigXT file
macro(kcfg_generate_dbus_interface _kcfg _name)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
COMMAND ${XSLTPROC_EXECUTABLE} --stringparam interfaceName ${_name}
${CMAKE_SOURCE_DIR}/akonadi/kcfg2dbus.xsl
${_kcfg}
> ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
DEPENDS ${CMAKE_SOURCE_DIR}/akonadi/kcfg2dbus.xsl
${_kcfg}
)
endmacro()
endif()
......@@ -10,32 +10,31 @@ if(POSTGRES_PATH)
endif()
########### next target ###############
set(AKONADI_DB_SCHEMA "${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xml")
set(AKONADI_DB_SCHEME ${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xml)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/entities.h
${CMAKE_CURRENT_BINARY_DIR}/entities.cpp
COMMAND ${XSLTPROC_EXECUTABLE}
--output ${CMAKE_CURRENT_BINARY_DIR}/entities.h
--stringparam code header
${CMAKE_CURRENT_SOURCE_DIR}/storage/entities.xsl
${AKONADI_DB_SCHEME}
COMMAND ${XSLTPROC_EXECUTABLE}
--output ${CMAKE_CURRENT_BINARY_DIR}/entities.cpp
--stringparam code source
${CMAKE_CURRENT_SOURCE_DIR}/storage/entities.xsl
${AKONADI_DB_SCHEME}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/storage/entities.xsl
${CMAKE_CURRENT_SOURCE_DIR}/storage/entities-header.xsl
${CMAKE_CURRENT_SOURCE_DIR}/storage/entities-source.xsl
${AKONADI_DB_SCHEME}
akonadi_run_xsltproc(
XSL ${CMAKE_CURRENT_SOURCE_DIR}/storage/entities.xsl
XML ${AKONADI_DB_SCHEMA}
BASENAME entities
)
add_test(akonadidb-xmllint ${XMLLINT_EXECUTABLE} --noout --schema ${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xsd ${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xml)
add_test(akonadidbupdate-xmllint ${XMLLINT_EXECUTABLE} --noout --schema ${CMAKE_CURRENT_SOURCE_DIR}/storage/dbupdate.xsd ${CMAKE_CURRENT_SOURCE_DIR}/storage/dbupdate.xml)
akonadi_run_xsltproc(
XSL ${Akonadi_SOURCE_DIR}/src/server/storage/schema.xsl
XML ${AKONADI_DB_SCHEMA}
CLASSNAME AkonadiSchema
BASENAME akonadischema
)
akonadi_generate_schema(${AKONADI_DB_SCHEME} AkonadiSchema akonadischema)
akonadi_add_xmllint_test(
akonadidb-xmllint
XSD ${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xsd
XML ${AKONADI_DB_SCHEMA}
)
akonadi_add_xmllint_test(
akonadidbupdate-xmllint
XSD ${CMAKE_CURRENT_SOURCE_DIR}/storage/akonadidb.xsd
XML ${AKONADI_DB_SCHEMA}
)
set(libakonadiserver_SRCS
akonadi.cpp
......
......@@ -22,12 +22,10 @@ find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED)
set(AKONADI_MIN_VERSION "5.2")
find_package(KF5Akonadi ${AKONADI_MIN_VERSION} CONFIG REQUIRED)
find_package(Xsltproc REQUIRED)
set_package_properties(Xsltproc PROPERTIES
DESCRIPTION "XSLT processor from libxslt"
TYPE REQUIRED
PURPOSE "Required to generate a D-Bus interface for the resource."
)
find_program(XSLTPROC_EXECUTABLE xsltproc DOC "Path to the xsltproc executable")
if (NOT XSLTPROC_EXECUTABLE)
message(FATAL_ERROR "\nThe command line XSLT processor program 'xsltproc' could not be found.\nPlease install xsltproc.\n")
endif()
add_subdirectory(src)
......
# Find xsltproc executable and provide a macro to generate D-Bus interfaces.
#
# The following variables are defined :
# XSLTPROC_EXECUTABLE - path to the xsltproc executable
# Xsltproc_FOUND - true if the program was found
find_program(XSLTPROC_EXECUTABLE xsltproc DOC "Path to the xsltproc executable")
mark_as_advanced(XSLTPROC_EXECUTABLE)
if(XSLTPROC_EXECUTABLE)
set(Xsltproc_FOUND TRUE)
# We depend on Akonadi, make sure it's found
if(NOT DEFINED KF5Akonadi_DATA_DIR)
find_package(KF5Akonadi REQUIRED)
endif()
# Macro to generate a D-Bus interface description from a KConfigXT file
macro(kcfg_generate_dbus_interface _kcfg _name)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
COMMAND ${XSLTPROC_EXECUTABLE}
--stringparam interfaceName ${_name}
${KF5Akonadi_DATA_DIR}/kcfg2dbus.xsl
${_kcfg}
> ${CMAKE_CURRENT_BINARY_DIR}/${_name}.xml
DEPENDS
${KF5Akonadi_DATA_DIR}/kcfg2dbus.xsl
${_kcfg}
)
endmacro()
endif()
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