Gyorgy Szing | 74dae3c | 2018-09-27 17:00:46 +0200 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2019, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | #Sphinx needs all document files to be under a single directory. This script |
| 9 | #copies all document files to a temporary directory while keeping the original |
| 10 | #directory tree (relative location of files) except "docs/index.rst" which is |
| 11 | #moved to the top level of the new tree. |
| 12 | # |
| 13 | # i.e.: |
| 14 | # <DST_DIR> |
| 15 | # | All documents from <TFM_ROOT_DIR> plus <TFM_ROOT_DIR>/docs/index.rst |
| 16 | # | |
| 17 | # +---docs |
| 18 | # | | |
| 19 | # \- all documents from <TFM_ROOT_DIR>/docs except index.rst |
| 20 | # | |
| 21 | # +---lib |
| 22 | # | | |
| 23 | # | \- All document from <TFM_ROOT_DIR>/lib keeping reativle location |
| 24 | # ... |
| 25 | # | |
| 26 | # |
| 27 | #Usage: |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 28 | # cmake -DDST_DIR=<path to destination> -DTFM_ROOT_DIR=<path to tf-m root> \ |
Gyorgy Szing | 74dae3c | 2018-09-27 17:00:46 +0200 | [diff] [blame] | 29 | # -P SphinxCopyDoc.cmake |
| 30 | |
| 31 | #Check input parameters |
| 32 | foreach(_PARAM IN ITEMS TFM_ROOT_DIR DST_DIR) |
| 33 | if (NOT DEFINED ${_PARAM}) |
| 34 | message(FATAL_ERROR "Variable ${_PARAM} is undefined. Please add -D${_PARAM}=<...> when calling this script.") |
| 35 | endif() |
| 36 | endforeach() |
| 37 | |
| 38 | message(STATUS "Creating document tree for Sphinx under ${DST_DIR}") |
| 39 | |
| 40 | #List all document files. |
| 41 | file(GLOB_RECURSE _COPY_FILES |
| 42 | LIST_DIRECTORIES false |
| 43 | RELATIVE "${TFM_ROOT_DIR}" |
| 44 | "${TFM_ROOT_DIR}/*.md" |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 45 | "${TFM_ROOT_DIR}/*.rst" |
Antonio de Angelis | b9bba1a | 2019-05-08 10:28:22 +0100 | [diff] [blame^] | 46 | "${TFM_ROOT_DIR}/*.png" |
| 47 | "${TFM_ROOT_DIR}/*.jpg" |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 48 | "${TFM_ROOT_DIR}/dco.txt") |
Gyorgy Szing | 74dae3c | 2018-09-27 17:00:46 +0200 | [diff] [blame] | 49 | |
| 50 | #Subtract exluded files from copy files |
| 51 | list(REMOVE_ITEM _COPY_FILES "docs/index.rst") |
| 52 | |
| 53 | #Copy files with directory tree. |
| 54 | foreach(_FILE ${_COPY_FILES}) |
| 55 | get_filename_component(_DIR ${_FILE} DIRECTORY) |
| 56 | file(COPY ${_FILE} DESTINATION "${DST_DIR}/${_DIR}") |
| 57 | endforeach() |
| 58 | |
| 59 | #Copy index.rst to the top level |
| 60 | file(COPY "${TFM_ROOT_DIR}/docs/index.rst" DESTINATION "${DST_DIR}") |