[evolution-data-server/tintou/camel-error-domains] M!61 - Camel: Add several headers to provide GType for error domains




commit 8603bc01db87a257f604f4c0bdb19194a56c164b
Author: Corentin Noël <corentin noel collabora com>
Date:   Wed Dec 30 00:00:14 2020 +0100

    M!61 - Camel: Add several headers to provide GType for error domains
    
    It allows bindings to provide syntax sugar for GErrors
    glib-mkenums allows to get multiple headers to extract all the enums.
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/-/merge_requests/61

 cmake/modules/GLibTools.cmake | 30 ++++++++++++++++++++++--------
 src/camel/CMakeLists.txt      |  9 ++++++++-
 2 files changed, 30 insertions(+), 9 deletions(-)
---
diff --git a/cmake/modules/GLibTools.cmake b/cmake/modules/GLibTools.cmake
index 300e6f4c3..f46ff6c02 100644
--- a/cmake/modules/GLibTools.cmake
+++ b/cmake/modules/GLibTools.cmake
@@ -4,6 +4,11 @@
 #
 # Functions:
 #
+# glib_mkenums_multiple(_output_filename_noext _define_name _enums_header ...)
+#    runs glib-mkenums to generate enumtypes .h and .c files from multiple
+#    _enums_header. It searches for files in the current source directory and
+#    exports to the current binary directory.
+#
 # glib_mkenums(_output_filename_noext _enums_header _define_name)
 #    runs glib-mkenums to generate enumtypes .h and .c files from _enums_header.
 #    It searches for files in the current source directory and exports to the current
@@ -52,18 +57,18 @@ if(NOT GLIB_MKENUMS)
        message(FATAL_ERROR "Cannot find glib-mkenums, which is required to build ${PROJECT_NAME}")
 endif(NOT GLIB_MKENUMS)
 
-function(glib_mkenums _output_filename_noext _enums_header _define_name)
+function(glib_mkenums_multiple _output_filename_noext _define_name _enums_header0)
        set(HEADER_TMPL "
 /*** BEGIN file-header ***/
 #ifndef ${_define_name}
 #define ${_define_name}
-/*** END file-header ***/
-
-/*** BEGIN file-production ***/
 
 #include <glib-object.h>
 
 G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
 
 /* Enumerations from \"@basename@\" */
 
@@ -76,6 +81,7 @@ GType @enum_name@_get_type    (void) G_GNUC_CONST;
 /*** END enumeration-production ***/
 
 /*** BEGIN file-tail ***/
+
 G_END_DECLS
 
 #endif /* ${_define_name} */
@@ -83,10 +89,14 @@ G_END_DECLS
 
        file(WRITE 
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/enumtypes-${_output_filename_noext}.h.tmpl" 
"${HEADER_TMPL}\n")
 
+       foreach(_enums_header ${_enums_header0} ${ARGN})
+               list(APPEND _enums_headers "${CMAKE_CURRENT_SOURCE_DIR}/${_enums_header}")
+       endforeach(_enums_header)
+
        add_custom_command(
                OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.h
-               COMMAND ${GLIB_MKENUMS} --template 
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/enumtypes-${_output_filename_noext}.h.tmpl" 
"${CMAKE_CURRENT_SOURCE_DIR}/${_enums_header}" >${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.h
-               DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_enums_header}
+               COMMAND ${GLIB_MKENUMS} --template 
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/enumtypes-${_output_filename_noext}.h.tmpl" 
${_enums_headers} >${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.h
+               DEPENDS ${_enums_headers}
        )
 
 set(SOURCE_TMPL "
@@ -133,9 +143,13 @@ GType
 
        add_custom_command(
                OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.c
-               COMMAND ${GLIB_MKENUMS} --template 
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/enumtypes-${_output_filename_noext}.c.tmpl" 
"${CMAKE_CURRENT_SOURCE_DIR}/${_enums_header}" >${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.c
-               DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_enums_header}
+               COMMAND ${GLIB_MKENUMS} --template 
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/enumtypes-${_output_filename_noext}.c.tmpl" 
${_enums_headers} >${CMAKE_CURRENT_BINARY_DIR}/${_output_filename_noext}.c
+               DEPENDS ${_enums_headers}
        )
+endfunction(glib_mkenums_multiple)
+
+function(glib_mkenums _output_filename_noext _enums_header _define_name)
+       glib_mkenums_multiple (${_output_filename_noext} ${_define_name} ${_enums_header})
 endfunction(glib_mkenums)
 
 find_program(GLIB_GENMARSHAL glib-genmarshal)
diff --git a/src/camel/CMakeLists.txt b/src/camel/CMakeLists.txt
index be626a890..6f3e970b7 100644
--- a/src/camel/CMakeLists.txt
+++ b/src/camel/CMakeLists.txt
@@ -1,4 +1,11 @@
-glib_mkenums(camel-enumtypes camel-enums.h CAMEL_ENUMTYPES_H)
+glib_mkenums_multiple(camel-enumtypes CAMEL_ENUMTYPES_H
+       camel-enums.h
+       camel-folder.h
+       camel-service.h
+       camel-sexp.h
+       camel-store.h
+       camel-url.h
+)
 
 add_executable(camel-gen-tables
        camel-gen-tables.c


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]