mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-17 11:37:10 +03:00
chore: support not using npm for some packagers
This commit is contained in:
parent
54eec739dc
commit
cc27485d18
@ -14,6 +14,15 @@ option(
|
||||
ON
|
||||
)
|
||||
|
||||
option(
|
||||
USE_NPM
|
||||
"Use npm installed packages during the build. You might \
|
||||
want to disable this option, if you want to use natively \
|
||||
installed tools. In particular build systems won't use \
|
||||
\"npx\" prefix before commands."
|
||||
ON
|
||||
)
|
||||
|
||||
set(QT_MIN_VERSION "5.15.0")
|
||||
set(KF5_MIN_VERSION "5.80.0")
|
||||
|
||||
|
@ -24,18 +24,47 @@ add_custom_target(
|
||||
file(GLOB_RECURSE TYPESCRIPT_SOURCES CONFIGURE_DEPENDS "*.ts")
|
||||
|
||||
if(USE_TSC)
|
||||
set(TSC_COMMAND "npx" "tsc" "--noEmit" "--incremental")
|
||||
set(TSC_COMMAND "tsc" "--noEmit" "--incremental")
|
||||
if(USE_NPM)
|
||||
list(PREPEND TSC_COMMAND "npx")
|
||||
else()
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"You are trying to use USE_TSC=ON with USE_NPM=OFF options. "
|
||||
"This is currently unsupported, because in this case TypeScript Compiler "
|
||||
"is going to throw a bunch of errors at you, because it cannot "
|
||||
"find a lot of stuff, like Jest or \"console\" JS global variable. "
|
||||
"\n"
|
||||
"This is happening, because normally TSC thinks, that he looks at "
|
||||
"code, that will be used with NPM packages and Node.js runtime. "
|
||||
"This is of course is not OK, but we ought to live with this "
|
||||
"behavior, because we need to use Jest Unit Testing Framework. "
|
||||
"\n"
|
||||
"You are supposed to use USE_NPM=OFF only with USE_TSC=OFF, "
|
||||
"because, if you are using these options at all, it means, that "
|
||||
"you are most probably a packager and packagers do not need "
|
||||
"to check TypeScript code for correctness."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(
|
||||
ESBUILD_COMMAND
|
||||
"esbuild"
|
||||
"--bundle" "${CMAKE_CURRENT_SOURCE_DIR}/index.ts"
|
||||
"--outfile=${CMAKE_CURRENT_BINARY_DIR}/bismuth/contents/code/index.mjs"
|
||||
"--format=esm"
|
||||
"--platform=neutral"
|
||||
)
|
||||
if(USE_NPM)
|
||||
list(PREPEND ESBUILD_COMMAND "npx")
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "bismuth/contents/code/index.mjs"
|
||||
COMMAND ${TSC_COMMAND}
|
||||
COMMAND "npx" "esbuild"
|
||||
"--bundle" "${CMAKE_CURRENT_SOURCE_DIR}/index.ts"
|
||||
"--outfile=${CMAKE_CURRENT_BINARY_DIR}/bismuth/contents/code/index.mjs"
|
||||
"--format=esm"
|
||||
"--platform=neutral"
|
||||
DEPENDS ${TYPESCRIPT_SOURCES}
|
||||
COMMAND ${ESBUILD_COMMAND}
|
||||
COMMAND DEPENDS ${TYPESCRIPT_SOURCES}
|
||||
COMMENT "🏗️ Compiling and bundling TypeScirpt sources..."
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user