Quellcode durchsuchen

HPCC-8616 Enable generating xml from xsd with configurator

Xiaoming Wang vor 10 Jahren
Ursprung
Commit
34c7345e75

+ 10 - 0
cmake_modules/commonSetup.cmake

@@ -76,6 +76,7 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
   option(DOCS_DRUPAL "Create Drupal HTML Docs" OFF)
   option(DOCS_EPUB "Create EPUB Docs" OFF)
   option(DOCS_MOBI "Create Mobi Docs" OFF)
+  option(DOCS_AUTO "DOCS automation" OFF)
   option(USE_RESOURCE "Use resource download in ECLWatch" OFF)
   option(GENERATE_COVERAGE_INFO "Generate coverage info for gcov" OFF)
   option(USE_SIGNED_CHAR "Build system with default char type is signed" OFF)
@@ -113,6 +114,9 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
 
   if ( MAKE_DOCS_ONLY AND NOT CLIENTTOOLS_ONLY )
       set( MAKE_DOCS ON )
+      if ( USE_DOCS_AUTO )
+        set ( DOCS_AUTO  ON)
+      endif()
   endif()
 
   if ( CLIENTTOOLS_ONLY )
@@ -494,6 +498,12 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
     ELSE()
       message(FATAL_ERROR "FOP requested but package not found")
     ENDIF()
+
+    if (DOCS_AUTO)
+       if ("${CONFIGURATOR_DIRECTORY}" STREQUAL "")
+         set(CONFIGURATOR_DIRECTORY ${HPCC_SOURCE_DIR}/../configurator)
+       endif()
+    endif()
   ENDIF(MAKE_DOCS)
 
   IF ( NOT MAKE_DOCS_ONLY )

+ 20 - 0
cmake_modules/docMacros.cmake

@@ -139,3 +139,23 @@ MACRO(FILE_LIST_GENERATOR outxml filename linkname description)
 	message("---- FILE_LIST_GENERATOR: Adding ${filename}")
 	set(${outxml} "${${outxml}}${xmlout}")
 ENDMACRO(FILE_LIST_GENERATOR)
+
+MACRO(XSD_TO_XML _xsd_files _in_dir _out_dir)
+
+        set(_xml_files)
+	ADD_CUSTOM_COMMAND(
+		COMMAND mkdir -p ${_out_dir}
+		OUTPUT ${_out_dir}
+                )
+        foreach(_xsd_file ${_xsd_files})
+            STRING(REGEX REPLACE "(.*).xsd" "\\1.xml" _xml_file "${_xsd_file}")
+	    ADD_CUSTOM_COMMAND(
+		COMMAND ./configurator -doc -use ${_xsd_file} -b ${_in_dir} -t ${_out_dir}
+		OUTPUT ${_out_dir}/${_xml_file}
+                WORKING_DIRECTORY ${CONFIGURATOR_DIRECTORY}
+		DEPENDS ${_out_dir} ${_in_dir}/${_xsd_file} ${_in_dir}/environment.xsd
+		)
+            list(APPEND _xml_files ${_out_dir}/${_xml_file})
+        endforeach()
+	ADD_CUSTOM_TARGET("xsd_to_xml" ALL  DEPENDS ${_out_dir} ${_xml_files} )
+ENDMACRO(XSD_TO_XML)

+ 47 - 0
docs/Automation/CMakeLists.txt

@@ -0,0 +1,47 @@
+################################################################################
+#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+################################################################################
+SET(XSD_SOURCE_DIR ${HPCC_SOURCE_DIR}/initfiles/componentfiles/configxml)
+SET(XSD_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR}/xsd )
+SET(XML_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR}/xml )
+
+FILE(MAKE_DIRECTORY ${XSD_TARGET_DIR})
+
+# get all *.xsd.in and *.xsd files
+FILE(GLOB XSD_TEMPLATE_FILES RELATIVE "${XSD_SOURCE_DIR}" "${XSD_SOURCE_DIR}/*.xsd.in")
+FILE(GLOB XSD_FILES RELATIVE "${XSD_SOURCE_DIR}" "${XSD_SOURCE_DIR}/*.xsd")
+
+# Skip some files which cause problem
+LIST(REMOVE_ITEM XSD_FILES "esp_service_wsecl2.xsd")
+
+# process and copy *.xsd.in files
+FOREACH( XSD_TEMPLATE_FILE  ${XSD_TEMPLATE_FILES} )
+   STRING(REGEX REPLACE "(.*).in" "\\1" XSD_FILE "${XSD_TEMPLATE_FILE}")
+   CONFIGURE_FILE(${XSD_SOURCE_DIR}/${XSD_TEMPLATE_FILE} ${XSD_TARGET_DIR}/${XSD_FILE})
+ENDFOREACH()
+
+# copy *.xsd.in files
+FOREACH( XSD_FILE  ${XSD_FILES} )
+   CONFIGURE_FILE(${XSD_SOURCE_DIR}/${XSD_FILE} ${XSD_TARGET_DIR}/${XSD_FILE} COPYONLY)
+ENDFOREACH()
+
+# create complete *.xsd file list
+FOREACH( XSD_TEMPLATE_FILE  ${XSD_TEMPLATE_FILES} )
+   STRING(REGEX REPLACE "(.*).in" "\\1" XSD_FILE "${XSD_TEMPLATE_FILE}")
+   SET(XSD_FILES ${XSD_FILES} ${XSD_FILE})
+ENDFOREACH()
+
+# create MakeFiles to generate xsd file to xml file
+XSD_TO_XML("${XSD_FILES}" ${XSD_TARGET_DIR} ${XML_TARGET_DIR})

+ 5 - 0
docs/CMakeLists.txt

@@ -71,6 +71,11 @@ add_subdirectory(ECLPluginForEclipse)
 add_subdirectory(ECLScheduler)
 add_subdirectory(ECLWatch)
 
+# Docs automation
+if (DOCS_AUTO)
+   add_subdirectory(Automation)
+endif()
+
 
 #WIP -  Docs
 #add_subdirectory(RuningHPCCinAmazonWebServicesEC2)