mirror of https://github.com/ceph/ceph
cmake: dashboard: support locale-dependent frontend builds
Fixes: https://tracker.ceph.com/issues/41988 Signed-off-by: Ricardo Dias <rdias@suse.com>
This commit is contained in:
parent
5adc755201
commit
3fe39d4899
|
@ -584,6 +584,9 @@ if(WITH_SYSTEM_NPM)
|
|||
message(FATAL_ERROR "Can't find npm.")
|
||||
endif()
|
||||
endif()
|
||||
set(DASHBOARD_FRONTEND_LANGS "" CACHE STRING
|
||||
"List of comma separated ceph-dashboard frontend languages to build. \
|
||||
Use value `ALL` to build all languages")
|
||||
|
||||
include_directories(SYSTEM ${PROJECT_BINARY_DIR}/include)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ function(add_npm_command)
|
|||
cmake_parse_arguments(NC "${options}" "${single_kw}" "${multi_kw}" ${ARGN})
|
||||
string(REPLACE ";" " " command "${NC_COMMAND}")
|
||||
if(NC_NODEENV)
|
||||
string(REGEX REPLACE "^(.*npm .*)$" ". ${mgr-dashboard-nodeenv-dir}/bin/activate && \\1 && deactivate" command ${command})
|
||||
string(REGEX REPLACE "^(.*(npm|npx) .*)$" ". ${mgr-dashboard-nodeenv-dir}/bin/activate && \\1 && deactivate" command ${command})
|
||||
endif()
|
||||
string(REPLACE " " ";" command "${command}")
|
||||
add_custom_command(
|
||||
|
@ -75,15 +75,41 @@ file(
|
|||
frontend/src/*/*/*/*/*/*.ts
|
||||
frontend/src/*/*/*/*/*/*.html)
|
||||
|
||||
# these files are generated during build
|
||||
list(REMOVE_ITEM frontend_src
|
||||
${CMAKE_SOURCE_DIR}/src/pybind/mgr/dashboard/frontend/src/environments/environment.prod.ts
|
||||
${CMAKE_SOURCE_DIR}/src/pybind/mgr/dashboard/frontend/src/environments/environment.ts)
|
||||
|
||||
execute_process(
|
||||
COMMAND bash -c "jq -r .config.locale ${CMAKE_SOURCE_DIR}/src/pybind/mgr/dashboard/frontend/package.json"
|
||||
OUTPUT_VARIABLE default_lang
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(DASHBOARD_FRONTEND_LANGS)
|
||||
string(STRIP "${DASHBOARD_FRONTEND_LANGS}" DASHBOARD_FRONTEND_LANGS)
|
||||
if(DASHBOARD_FRONTEND_LANGS STREQUAL "ALL")
|
||||
set(build_target ":*")
|
||||
else()
|
||||
string(FIND "${DASHBOARD_FRONTEND_LANGS}" "${default_lang}" default_idx)
|
||||
if (default_idx EQUAL -1)
|
||||
# default language must be always built
|
||||
string(CONCAT DASHBOARD_FRONTEND_LANGS "${DASHBOARD_FRONTEND_LANGS}" ",${default_lang}")
|
||||
endif()
|
||||
set(build_target ":\{${DASHBOARD_FRONTEND_LANGS}\}")
|
||||
endif()
|
||||
else(DASHBOARD_FRONTEND_LANGS)
|
||||
set(build_target ":${default_lang}")
|
||||
endif(DASHBOARD_FRONTEND_LANGS)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
set(npm_command npm run build -- --prod --progress=false)
|
||||
set(npm_args "-- --prod --progress=false")
|
||||
else()
|
||||
set(npm_command npm run build -- --progress=false)
|
||||
set(npm_args "-- --progress=false")
|
||||
endif()
|
||||
|
||||
add_npm_command(
|
||||
OUTPUT "${CMAKE_SOURCE_DIR}/src/pybind/mgr/dashboard/frontend/dist"
|
||||
COMMAND ${npm_command}
|
||||
COMMAND npx npm-run-all --print-label --parallel --max-parallel 2 "\"build${build_target} -- ${npm_args}\""
|
||||
DEPENDS ${frontend_src} frontend/node_modules
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/mgr/dashboard/frontend
|
||||
COMMENT "dashboard frontend is being created"
|
||||
|
@ -93,6 +119,7 @@ add_custom_target(mgr-dashboard-frontend-build
|
|||
ALL
|
||||
DEPENDS frontend/dist mgr-dashboard-frontend-deps
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/mgr/dashboard/frontend)
|
||||
|
||||
add_dependencies(tests mgr-dashboard-frontend-build)
|
||||
endif(WITH_MGR_DASHBOARD_FRONTEND AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64|arm|ARM")
|
||||
|
||||
|
|
Loading…
Reference in New Issue