1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
set(TANGENT_MODULES_DIR ${CMAKE_CURRENT_LIST_DIR}/tangent)
# =================================================
# Detect whether this is local or installed tooling
# =================================================
get_filename_component(_local_tooling_dir
${CMAKE_CURRENT_LIST_DIR}/../../tangent/tooling ABSOLUTE)
if(EXISTS ${_local_tooling_dir})
set(TANGENT_TOOLING ${_local_tooling_dir})
else()
set(TANGENT_TOOLING ${TANGENT_MODULES_DIR})
endif()
# =================
# Submodules
# =================
# NOTE(josh): order matters
set(_tangent_modules
environment.cmake
wrappers.cmake
codestyle.cmake
ctest_helpers.cmake
debian.cmake
doctools.cmake
pkgconfig.cmake
re2-config.cmake)
foreach(module ${_tangent_modules})
include(${TANGENT_MODULES_DIR}/${module})
endforeach()
if(TANGENT_SPARSE_EXPORT)
message(STATUS "Detected sparse export: ${TANGENT_SPARSE_EXPORT}")
endif()
if(NOT TANGENT_BUILD_CONTEXT)
set(TANGENT_BUILD_CONTEXT
WORKSTATION
CACHE STRING "what is the context for the current build")
endif()
# =================
# Global properties
# =================
# Will be populated by subdirectory listfiles with the dependencies of the
# master sphinx build
set_property(GLOBAL PROPERTY global_doc_files "")
# ======================
# Top-level (UI) targets
# ======================
add_custom_command(
OUTPUT __always_rebuild
COMMAND cmake -E echo "" > /dev/null
COMMENT "Running every-build")
add_custom_target(chkfmt DEPENDS __always_rebuild)
add_custom_target(doc DEPENDS __always_rebuild)
add_custom_target(format DEPENDS __always_rebuild)
add_custom_target(gen DEPENDS __always_rebuild)
add_custom_target(lint DEPENDS __always_rebuild)
add_custom_target(precommit DEPENDS __always_rebuild)
add_custom_target(test-deps DEPENDS __always_rebuild)
add_custom_target(wheels DEPENDS __always_rebuild)
# ==================
# Codestyle Manifest
# ==================
if(CMAKE_GENERATOR STREQUAL "Ninja")
add_custom_target(
check-codestyle-manifest
BYPRODUCTS ${CMAKE_BINARY_DIR}/codestyle_manifest.cmake
DEPENDS __always_rebuild
COMMAND
python -B ${TANGENT_TOOLING}/generate_style_manifest.py #
--outfile ${CMAKE_BINARY_DIR}/codestyle_manifest.cmake #
--excludes-from ${CMAKE_SOURCE_DIR}/build_tooling/lint-excludes.txt #
-- ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Checking for changes in codestyle manifest")
else()
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/codestyle_manifest.cmake
DEPENDS __always_rebuild
COMMAND
python -B ${TANGENT_TOOLING}/generate_style_manifest.py #
--outfile ${CMAKE_BINARY_DIR}/codestyle_manifest.cmake #
--excludes-from ${CMAKE_SOURCE_DIR}/build_tooling/lint-excludes.txt #
-- ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Checking for changes in codestyle manifest")
add_custom_target(check-codestyle-manifest
DEPENDS ${CMAKE_BINARY_DIR}/codestyle_manifest.cmake)
endif()
check_call(
COMMAND
python -B ${TANGENT_TOOLING}/generate_style_manifest.py #
--outfile ${CMAKE_BINARY_DIR}/codestyle_manifest.cmake #
--excludes-from ${CMAKE_SOURCE_DIR}/build_tooling/lint-excludes.txt #
-- ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
check_call(
COMMAND python -B ${TANGENT_TOOLING}/cmake_post.py --binary-dir
${CMAKE_BINARY_DIR} --generator "${CMAKE_GENERATOR}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
# If the manifest changes, then we need to rerun cmake to import link/fmt rules
# for the new manifest
# configure_file(${CMAKE_BINARY_DIR}/codestyle_manifest.cmake
# ${CMAKE_BINARY_DIR}/codestyle_manifest.stamp COPYONLY)
include(${CMAKE_BINARY_DIR}/codestyle_manifest.cmake)
# ========================
# Local python environment
# ========================
# Create python environment with packages needed to do the build
set(PYENV_WITNESS ${CMAKE_BINARY_DIR}/pyenv.witness)
set(PYENV
${CMAKE_COMMAND} -E env #
VIRTUAL_ENV=${CMAKE_BINARY_DIR}/pyenv #
"PATH=${CMAKE_BINARY_DIR}/pyenv:\$\${PATH}")
if(CMAKE_GENERATOR STREQUAL "Ninja")
set(_depfile DEPFILE ${CMAKE_BINARY_DIR}/pyenv.d)
endif()
add_custom_command(
OUTPUT ${PYENV_WITNESS}
COMMAND rm -rf ${CMAKE_BINARY_DIR}/pyenv
COMMAND virtualenv -p python3 ${CMAKE_BINARY_DIR}/pyenv
COMMAND ${PYENV} pip install -r requirements.txt
COMMAND echo "pyenv.witness : \\\\" > ${CMAKE_BINARY_DIR}/pyenv.d
COMMAND
env LC_ALL=C #
find ${CMAKE_BINARY_DIR}/pyenv -type l,f #
| sed 's: :\\\\ :g' #
| sort #
| sed 's:$$:\\\\:' >> ${CMAKE_BINARY_DIR}/pyenv.d
COMMAND touch ${PYENV_WITNESS}
DEPENDS requirements.txt
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Creating python environment" ${_depfile})
# NOTE(josh): bug in cmake 3.10. If we don't create this custom target, then
# cmake wont emit the rule... even though we have a rule later on that depends
# on the outputs of the custom command.
add_custom_target(pyenv DEPENDS ${PYENV_WITNESS})
# ==============
# doxygen target
# ==============
# NOTE(josh): some sparse checkouts don't include doxygen
if(EXISTS ${CMAKE_SOURCE_DIR}/doxy.config.in)
# configure the doxygen configuration
# NOTE(josh): maybe want to expose this for editor integration
# ~~~
# set(DOXY_WARN_FORMAT "\"$file($line) : $text \"")
# set(DOXY_WARN_FORMAT "\"$file:$line: $text \"")
# ~~~
configure_file("${PROJECT_SOURCE_DIR}/doxy.config.in"
"${PROJECT_BINARY_DIR}/doxy.config")
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/doxy.stamp
COMMAND doxygen ${PROJECT_BINARY_DIR}/doxy.config
COMMAND touch ${PROJECT_BINARY_DIR}/doxy.stamp
DEPENDS ${PROJECT_BINARY_DIR}/doxy.config
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_custom_target(doxygen DEPENDS ${PROJECT_BINARY_DIR}/doxy.stamp)
add_dependencies(doc doxygen)
endif()
# ==================
# better-test target
# ==================
add_custom_target(
better-test
DEPENDS test-deps
COMMAND ctest --force-new-ctest-process --output-on-failure
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Execute ctest")
add_custom_target(
best-test
COMMENT "Execute all tests")
# ====================
# buildbot-test target
# ====================
add_custom_target(
buildbot-test
DEPENDS test-deps
COMMAND
# cmake-format: off
ctest
--label-exclude CI_DISABLED
--force-new-ctest-process
--output-on-failure
--output-log ${CMAKE_BINARY_DIR}/ctestlog.txt
# cmake-format: on
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# =========
# git hooks
# =========
add_custom_target(pre-push)
add_dependencies(pre-push lint chkfmt)
add_custom_target(pre-release)
add_dependencies(pre-release better-test doc lint chkfmt)
# ========================
# bake vscode config files
# ========================
# Inform vscode where compile commands is
find_program(_python_path python)
file(GLOB _vscode_files ${CMAKE_SOURCE_DIR}/.vscode/*)
execute_process(
COMMAND
python -B ${TANGENT_TOOLING}/vscode_varsub.py #
--var cmakeBinaryDir=${CMAKE_BINARY_DIR} #
--var "pythonPath=${_python_path}" #
sub ${_vscode_files}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_custom_target(
unsub-vscode
COMMAND
python -B ${TANGENT_TOOLING}/vscode_varsub.py #
--var cmakeBinaryDir=${CMAKE_BINARY_DIR} #
--var "pythonPath=${_python_path}" #
--touch ${CMAKE_SOURCE_DIR}/CMakeLists.txt #
unsub ${_vscode_files}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Restoring variables in vscode")
add_dependencies(precommit unsub-vscode)
|