Feature/drogon ctl add namespce to view (#1245)

drogon_ctl --namespace and --path-to-namespace is allowed. If both parameters are used the value of namespace will be set in front of path-to-namespace
added an example into the template cmake.csp how to use the new optional parameter of drogon_create_views
This commit is contained in:
JuergenGleiss 2022-06-03 09:40:24 +02:00 committed by GitHub
parent 346e2e6033
commit 664d97c185
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 4 deletions

View File

@ -1,6 +1,6 @@
# ##############################################################################
# function drogon_create_views(target source_path output_path
# [use_path_as_namespace])
# [TRUE to use_path_as_namespace] [prefixed namespace])
# ##############################################################################
function(drogon_create_views arg)
if(ARGC LESS 3)
@ -27,15 +27,27 @@ function(drogon_create_views arg)
""
outputFile
${f2})
set(p2ns "")
if("${ARGV3}" STREQUAL "TRUE")
set(p2ns "--path-to-namespace")
endif()
if ( (ARGC EQUAL 5) AND ( NOT "${ARGV4}" STREQUAL "") )
string(REPLACE "::" "_" nSpace ${ARGV4})
set(outputFile "${nSpace}_${outputFile}")
set(ns -n ${ARGV4})
else()
set(ns "")
endif()
add_custom_command(OUTPUT ${ARGV2}/${outputFile}.h ${ARGV2}/${outputFile}.cc
COMMAND drogon_ctl
ARGS
create
view
${inFile}
--path-to-namespace
${p2ns}
-o
${ARGV2}
${ns}
DEPENDS ${cspFile}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM)

View File

@ -24,8 +24,8 @@ std::string create::detail()
"Usage:drogon_ctl create <view|controller|filter|project|model> "
"[-options] <object name>\n\n"
"drogon_ctl create view <csp file name> [-o <output path>] [-n "
"<namespace>]|[--path-to-namespace]//create HttpView source files "
"from csp files\n\n"
"<namespace>] [--path-to-namespace] //create HttpView source files "
"from csp files, namespace is prefixed of path-to-namespace\n\n"
"drogon_ctl create controller [-s] <[namespace::]class_name> //"
"create HttpSimpleController source files\n\n"
"drogon_ctl create controller -h <[namespace::]class_name> //"

View File

@ -54,6 +54,10 @@ drogon_create_views(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/views
# use the following line to create views with namespaces.
# drogon_create_views(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/views
# ${CMAKE_CURRENT_BINARY_DIR} TRUE)
# use the following line to create views with namespace CHANGE_ME prefixed
# and path namespaces.
# drogon_create_views(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/views
# ${CMAKE_CURRENT_BINARY_DIR} TRUE CHANGE_ME)
target_include_directories(${PROJECT_NAME}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}