Doc: Add support for Sphinx documentation build.
Technical documentation of TF-M is captured in GitHub flavored
markdown files. This change add support for building HTML and
PDF output of these files using the Sphinx tool.
Change-Id: I8be11256f2c654c248b1974974a5de6190ca0fc3
Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com>
diff --git a/cmake/Common/Utils.cmake b/cmake/Common/Utils.cmake
index 0c3b0d0..452d0bf 100644
--- a/cmake/Common/Utils.cmake
+++ b/cmake/Common/Utils.cmake
@@ -1,31 +1,41 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2017, Arm Limited. All rights reserved.
+# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------
-# Append a value to a string if not already present
+
+#Print a message and exit with failure
#
-# Append an item to a string if no item with matching key is already on the string.
-# This function's intended purpose is to append unique flags to command line switches.
+#Examples:
+# failure("Something is wrong!")
+
+function(failure)
+ message(FATAL_ERROR "${ARGN}")
+endfunction()
+
+#Append a value to a string if not already present
#
-# Examples:
-# string_append_unique_item(STRING C_FLAGS KEY "--target" VAL "--target=armv8m-arm-none-eabi")
+#Append an item to a string if no item with matching key is already on the string.
+#This function's intended purpose is to append unique flags to command line switches.
#
-# INPUTS:
-# STRING - (mandatory) - name of the string to operate on
-# KEY - (mandatory) - string to look for
-# VAL - (mandatory) - value to put be added to the string
+#Examples:
+# string_append_unique_item(STRING C_FLAGS KEY "--target" VAL "--target=armv8m-arm-none-eabi")
#
-# OUTPUTS
-# STRING is modified as needed.
+#INPUTS:
+# STRING - (mandatory) - name of the string to operate on
+# KEY - (mandatory) - string to look for
+# VAL - (mandatory) - value to put be added to the string
+#
+#OUTPUTS
+# STRING is modified as needed.
#
function(string_append_unique_item)
#Parse our arguments
- set( _OPTIONS_ARGS ) #No option (on/off) arguments (e.g. IGNORE_CASE)
- set( _ONE_VALUE_ARGS STRING KEY VAL) #Single option arguments (e.g. PATH "./foo/bar")
- set( _MULTI_VALUE_ARGS ) #List arguments (e.g. LANGUAGES C ASM CXX)
+ set( _OPTIONS_ARGS ) #No option (on/off) arguments (e.g. IGNORE_CASE)
+ set( _ONE_VALUE_ARGS STRING KEY VAL) #Single option arguments (e.g. PATH "./foo/bar")
+ set( _MULTI_VALUE_ARGS ) #List arguments (e.g. LANGUAGES C ASM CXX)
cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
#Check mandatory parameters
@@ -42,11 +52,54 @@
if(NOT _MY_PARAMS_VAL)
failure("string_append_unique_item(): Missing VAL parameter!")
endif()
- set(_VAL ${_MY_PARAMS_VAL})
+ set(_VAL ${_MY_PARAMS_VAL})
- #Scan the string.
- STRING(REGEX MATCH "( |^) *${_KEY}" _FOUND "${${_STRING}}")
- if("${_FOUND}" STREQUAL "")
+ #Scan the string.
+ STRING(REGEX MATCH "( |^) *${_KEY}" _FOUND "${${_STRING}}")
+ if("${_FOUND}" STREQUAL "")
set(${_STRING} "${${_STRING}} ${_VAL}" PARENT_SCOPE)
- endif()
+ endif()
+endfunction()
+
+
+#Convert \ directory separators to / on windows systems
+#
+#Convert the directory separators to forward slash on windows. Avoid
+#conversion if path contains any forward slashes to avoid mixing up cygwin or
+#mingw paths where an extra caharacter is escaped (i.e. "/c/Program\ Files/")
+#
+#Examples:
+# set(MY_PATH "C:\foo\bar")
+# win_fix_dir_sep(PATH MY_PATH)
+#
+#INPUTS:
+# PATH - (mandatory) - name of the string variable to operate on
+#
+#OUTPUTS
+# PATH is modified as needed.
+#
+function(win_fix_dir_sep)
+ #Parse our arguments
+ set( _OPTIONS_ARGS ) #No option (on/off) arguments (e.g. IGNORE_CASE)
+ set( _ONE_VALUE_ARGS PATH ) #Single option arguments (e.g. PATH "./foo/bar")
+ set( _MULTI_VALUE_ARGS ) #List arguments (e.g. LANGUAGES C ASM CXX)
+ cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
+
+ #Check mandatory parameters
+ if(NOT _MY_PARAMS_PATH)
+ failure("win_fix_dir_sep(): Missing mandatory parameter PATH!")
+ endif()
+ set(_PATH ${_MY_PARAMS_PATH})
+
+ #To avoid trouble on windows change directory separator.
+ if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ #Do not convert directory separator if there are forward slashes
+ #present. This is to avoid mixing up escaped characters in cygwin
+ #or mingw paths (i.e. c:/Program\ Files/something)
+ string(FIND "${${_PATH}}" "/" _is_found)
+ if (_is_found LESS 0)
+ string(REPLACE "\\" "/" ${_PATH} "${${_PATH}}")
+ set(${_PATH} "${${_PATH}}" PARENT_SCOPE)
+ endif()
+ endif()
endfunction()