Be able to choose openAPI definition file name.
authorRomain Forlot <romain.forlot@iot.bzh>
Fri, 11 Aug 2017 08:16:05 +0000 (10:16 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Fri, 11 Aug 2017 08:16:05 +0000 (10:16 +0200)
Use a variable OPENAPI_DEF to define the file name else use the default
convention ${OUTPUT_NAME}-apidef.
Update the docs in consequence.

Change-Id: Ibc29d6079d185e47a80dbfe4df5dedd28f7f63c4
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
README.md
cmake/cmake.d/02-macros.cmake
docs/dev_guide/3_advanced_usage.md

index dd6555f..1c648ac 100644 (file)
--- a/README.md
+++ b/README.md
@@ -75,9 +75,13 @@ Choose between:
 
 - **BINDING**: Shared library that be loaded by the AGL Application Framework
 - **BINDINGV2**: Shared library that be loaded by the AGL Application Framework.
- This has to be accompagnied with a JSON file named like the *OUTPUT_NAME*  of
- the target that describe the API with OpenAPI syntax. JSON file will be used
- to generate header file using `afb-genskel` tool.
+ This has to be accompagnied with a JSON file named like the *${OUTPUT_NAME}-apidef* of
+ the target that describe the API with OpenAPI syntax (e.g: *mybinding-apidef*).
+ Or you can choose the name by setting the *CACHE* cmake variable *OPENAPI_DEF*
+ (***CAUTION***: setting a CACHE variable is needed, or set a normal variable
+ with the *PARENT_SCOPE* option to make it visible for the parent scope
+ where the target is defined) JSON file will be used to generate header file
+ using `afb-genskel` tool.
 - **HTDOCS**: Root directory of a web app
 - **DATA**: Resources used by your application
 - **EXECUTABLE**: Entry point of your application executed by the AGL
index 6ebff21..e116d2e 100644 (file)
@@ -98,12 +98,23 @@ macro(project_targets_populate)
                                )
                                add_custom_target(${POPULE_PACKAGE_TARGET} DEPENDS ${PACKAGE_LIBDIR}/${P}${OUT}.so)
 
-                               add_custom_command(OUTPUT ${SD}/${P}${OUT}.h
-                                       DEPENDS ${SD}/${P}${OUT}.json
-                                       COMMAND afb-genskel ${SD}/${P}${OUT}.json > ${SD}/${P}${OUT}.h
-                               )
-                               add_custom_target("${TARGET}_GENSKEL" DEPENDS ${SD}/${P}${OUT}.h)
-                               add_dependencies(${TARGET} "${TARGET}_GENSKEL")
+                               if (OPENAPI_DEF)
+                                       add_custom_command(OUTPUT ${SD}/${OPENAPI_DEF}.h
+                                               DEPENDS ${SD}/${OPENAPI_DEF}.json
+                                               COMMAND afb-genskel ${SD}/${OPENAPI_DEF}.json > ${SD}/${OPENAPI_DEF}.h
+                                       )
+                                       add_custom_target("${TARGET}_GENSKEL" DEPENDS ${SD}/${OPENAPI_DEF}.h
+                                               COMMENT "Generating OpenAPI header file ${OPENAPI_DEF}.h")
+                                       add_dependencies(${TARGET} "${TARGET}_GENSKEL")
+                               else()
+                                       add_custom_command(OUTPUT ${SD}/${OUT}-apidef.h
+                                               DEPENDS ${SD}/${OUT}-apidef.json
+                                               COMMAND afb-genskel ${SD}/${OUT}-apidef.json > ${SD}/${OUT}-apidef.h
+                                       )
+                                       add_custom_target("${TARGET}_GENSKEL" DEPENDS ${SD}/${OUT}-apidef.h
+                                               COMMENT "Generating OpenAPI header file ${OUT}-apidef.h")
+                                       add_dependencies(${TARGET} "${TARGET}_GENSKEL")
+                               endif()
                        elseif(${T} STREQUAL "EXECUTABLE")
                                add_custom_command(OUTPUT ${PACKAGE_BINDIR}/${P}${OUT}
                                        DEPENDS ${BD}/${P}${OUT}
index 87310b3..cc58bb0 100644 (file)
@@ -31,9 +31,13 @@ Choose between:
 
 - **BINDING**: Shared library that be loaded by the AGL Application Framework
 - **BINDINGV2**: Shared library that be loaded by the AGL Application Framework.
- This has to be accompagnied with a JSON file named like the *OUTPUT_NAME*  of
- the target that describe the API with OpenAPI syntax. JSON file will be used
- to generate header file using `afb-genskel` tool.
+ This has to be accompagnied with a JSON file named like the *${OUTPUT_NAME}-apidef* of
+ the target that describe the API with OpenAPI syntax (e.g: *mybinding-apidef*).
+ Or you can choose the name by setting the *CACHE* cmake variable *OPENAPI_DEF*
+ (***CAUTION***: setting a CACHE variable is needed, or set a normal variable
+ with the *PARENT_SCOPE* option to make it visible for the parent scope
+ where the target is defined) JSON file will be used to generate header file
+ using `afb-genskel` tool.
 - **HTDOCS**: Root directory of a web app
 - **DATA**: Resources used by your application
 - **EXECUTABLE**: Entry point of your application executed by the AGL