mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Cmake - rework gnc_add_scheme_deprecated_module to use keyword parameters
Update all invocations accordingly
This commit is contained in:
@@ -304,29 +304,45 @@ function(gnc_add_scheme_test_targets _TARGET)
|
||||
gnc_add_scheme_targets(${_TARGET} ${ARGN} TEST)
|
||||
endfunction()
|
||||
|
||||
# gnc_add_scheme_deprecated_module (OLD_MODULE old_module_name
|
||||
# [NEW_MODULE new_module_name
|
||||
# DEPENDS new_module_target]
|
||||
# [MESSAGE msg_string])
|
||||
#
|
||||
# Function to write boilerplate code for deprecated guile modules
|
||||
# All but the _OLDMOD parameter are optional
|
||||
# It will emit a deprecation warning and if _NEWMOD is also given
|
||||
# that module will be loaded instead.
|
||||
# If _NEWMOD is given, _DEPENDS should be set to the target for which
|
||||
# such that invocation of the old module will emit a deprecation warning
|
||||
# message.
|
||||
#
|
||||
# All but the OLD_MODULE keyword are optional
|
||||
#
|
||||
# OLD_MODULE and NEW_MODULE should be passed in the form
|
||||
# "gnucash mod parts"
|
||||
#
|
||||
# If NEW_MODULE is set that module will be loaded instead of the
|
||||
# deprecated module.
|
||||
# If NEW_MODULE is set, DEPENDS should be set to the target for which
|
||||
# that module is a source file.
|
||||
# For example module (gnucash reports standard transaction)
|
||||
# is defined in transaction.scm, which is a source file for
|
||||
# cmake target scm-reports-standard so that should be set as _DEPENDS.
|
||||
# cmake target scm-reports-standard so that should be set as DEPENDS.
|
||||
#
|
||||
# If MESSAGE is left blank, the module will emit a generic message.
|
||||
# Otherwise MESSAGE will be emitted.
|
||||
function(gnc_add_scheme_deprecated_module)
|
||||
|
||||
# The function expects module names in the form "gnucash mod parts"
|
||||
# If _DEPMSG is left blank, the module will emit a generic message,
|
||||
# otherswise _DEPMSG will be emitted.
|
||||
function(gnc_add_scheme_deprecated_module _OLDMOD _NEWMOD _DEPENDS _DEPMSG)
|
||||
string(STRIP _OLDMOD "${_OLDMOD}")
|
||||
string(REPLACE " " "-" _TARGET ${_OLDMOD})
|
||||
set(singleValues OLD_MODULE NEW_MODULE MESSAGE)
|
||||
set(multiValues DEPENDS)
|
||||
cmake_parse_arguments(DM "" "${singleValues}" "${multiValues}" ${ARGN})
|
||||
|
||||
string(STRIP DM_OLD_MODULE "${DM_OLD_MODULE}")
|
||||
string(REPLACE " " "-" _TARGET ${DM_OLD_MODULE})
|
||||
set(_TARGET "scm-deprecated-${_TARGET}")
|
||||
|
||||
string(REPLACE " " ";" MODPARTS "${_OLDMOD}")
|
||||
string(REPLACE " " ";" MODPARTS "${DM_OLD_MODULE}")
|
||||
list(GET MODPARTS -1 DEPFILENAME)
|
||||
set(SOURCEFILE "${CMAKE_CURRENT_BINARY_DIR}/deprecated/${DEPFILENAME}.scm")
|
||||
|
||||
string(FIND "${_OLDMOD}" ${DEPFILENAME} POS REVERSE)
|
||||
string(FIND "${DM_OLD_MODULE}" ${DEPFILENAME} POS REVERSE)
|
||||
if (${POS} LESS 2)
|
||||
set(MODPATH "gnucash/deprecated")
|
||||
else()
|
||||
@@ -336,38 +352,38 @@ function(gnc_add_scheme_deprecated_module _OLDMOD _NEWMOD _DEPENDS _DEPMSG)
|
||||
endif()
|
||||
|
||||
set(DEPPREFIX "* WARN <gnc-guile-deprecation> *: ")
|
||||
if (_DEPMSG)
|
||||
set(DEPWARNING "(issue-deprecation-warning \"${DEPPREFIX}${_DEPMSG}\")")
|
||||
if (DM_MESSAGE)
|
||||
set(DEPWARNING "(issue-deprecation-warning \"${DEPPREFIX}${DM_MESSAGE}\")")
|
||||
else()
|
||||
set(DEPWARNING
|
||||
"(issue-deprecation-warning \"${DEPPREFIX}Module '(${_OLDMOD})' has been deprecated and will be removed in the future.\")")
|
||||
if (_NEWMOD)
|
||||
"(issue-deprecation-warning \"${DEPPREFIX}Module '(${DM_OLD_MODULE})' has been deprecated and will be removed in the future.\")")
|
||||
if (DM_NEW_MODULE)
|
||||
set(DEPWARNING "${DEPWARNING}
|
||||
(issue-deprecation-warning \"${DEPPREFIX}Use module '(${_NEWMOD})' instead.\")")
|
||||
(issue-deprecation-warning \"${DEPPREFIX}Use module '(${DM_NEW_MODULE})' instead.\")")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Write the stub file
|
||||
file(WRITE ${SOURCEFILE} "
|
||||
;; ${DEPFILENAME}.scm
|
||||
;; Compatibility module for deprecated (${_OLDMOD}).
|
||||
;; Compatibility module for deprecated (${DM_OLD_MODULE}).
|
||||
;; This file is autogenerated, do not modify by hand.
|
||||
|
||||
(define-module (${_OLDMOD}))
|
||||
(define-module (${DM_OLD_MODULE}))
|
||||
|
||||
${DEPWARNING}
|
||||
")
|
||||
|
||||
if (_NEWMOD)
|
||||
if (DM_NEW_MODULE)
|
||||
file(APPEND ${SOURCEFILE} "
|
||||
(use-modules (${_NEWMOD}))
|
||||
(use-modules (${DM_NEW_MODULE}))
|
||||
|
||||
(let ((i (module-public-interface (current-module))))
|
||||
(module-use! i (resolve-interface '(${_NEWMOD}))))")
|
||||
(module-use! i (resolve-interface '(${DM_NEW_MODULE}))))")
|
||||
endif()
|
||||
|
||||
gnc_add_scheme_targets("${_TARGET}"
|
||||
SOURCES "${SOURCEFILE}"
|
||||
OUTPUT_DIR "${MODPATH}"
|
||||
DEPENDS "${_DEPENDS}")
|
||||
DEPENDS "${DM_DEPENDS}")
|
||||
endfunction()
|
||||
|
||||
@@ -67,7 +67,10 @@ gnc_add_scheme_test_targets(scm-test-core
|
||||
add_dependencies(check scm-test-core)
|
||||
|
||||
# Module interfaces deprecated in 4.x, will be removed for 5.x
|
||||
gnc_add_scheme_deprecated_module ("gnucash unittest-support" "tests unittest-support" "scm-test-core" "")
|
||||
gnc_add_scheme_deprecated_module (
|
||||
OLD_MODULE "gnucash unittest-support"
|
||||
NEW_MODULE "tests unittest-support"
|
||||
DEPENDS "scm-test-core")
|
||||
|
||||
|
||||
if (GTEST_SRC_DIR)
|
||||
|
||||
Reference in New Issue
Block a user