cmake : fix LLAMA_BUILD_UI logic (#23190)
This commit is contained in:
+2
-7
@@ -108,20 +108,15 @@ option(LLAMA_BUILD_TESTS "llama: build tests"
|
|||||||
option(LLAMA_BUILD_TOOLS "llama: build tools" ${LLAMA_STANDALONE})
|
option(LLAMA_BUILD_TOOLS "llama: build tools" ${LLAMA_STANDALONE})
|
||||||
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
|
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
|
||||||
option(LLAMA_BUILD_SERVER "llama: build server example" ${LLAMA_STANDALONE})
|
option(LLAMA_BUILD_SERVER "llama: build server example" ${LLAMA_STANDALONE})
|
||||||
# Deprecated: use LLAMA_BUILD_UI instead (kept for backward compat)
|
|
||||||
option(LLAMA_BUILD_WEBUI "llama: build the embedded Web UI for server (deprecated: use LLAMA_BUILD_UI)" ON)
|
|
||||||
option(LLAMA_USE_PREBUILT_WEBUI "llama: use prebuilt WebUI from HF Bucket when available (deprecated: use LLAMA_USE_PREBUILT_UI)" ON)
|
|
||||||
|
|
||||||
# New option names
|
|
||||||
option(LLAMA_BUILD_UI "llama: build the embedded Web UI for server" ON)
|
option(LLAMA_BUILD_UI "llama: build the embedded Web UI for server" ON)
|
||||||
option(LLAMA_USE_PREBUILT_UI "llama: use prebuilt UI from HF Bucket when available (requires LLAMA_BUILD_UI=ON)" ON)
|
option(LLAMA_USE_PREBUILT_UI "llama: use prebuilt UI from HF Bucket when available (requires LLAMA_BUILD_UI=ON)" ON)
|
||||||
|
|
||||||
# Backward compat: when old var is set but new one isn't, forward the value
|
# Backward compat: when old var is set but new one isn't, forward the value
|
||||||
if(DEFINED LLAMA_BUILD_WEBUI AND NOT DEFINED LLAMA_BUILD_UI)
|
if(DEFINED LLAMA_BUILD_WEBUI)
|
||||||
set(LLAMA_BUILD_UI ${LLAMA_BUILD_WEBUI})
|
set(LLAMA_BUILD_UI ${LLAMA_BUILD_WEBUI})
|
||||||
message(DEPRECATION "LLAMA_BUILD_WEBUI is deprecated, use LLAMA_BUILD_UI instead")
|
message(DEPRECATION "LLAMA_BUILD_WEBUI is deprecated, use LLAMA_BUILD_UI instead")
|
||||||
endif()
|
endif()
|
||||||
if(DEFINED LLAMA_USE_PREBUILT_WEBUI AND NOT DEFINED LLAMA_USE_PREBUILT_UI)
|
if(DEFINED LLAMA_USE_PREBUILT_WEBUI)
|
||||||
set(LLAMA_USE_PREBUILT_UI ${LLAMA_USE_PREBUILT_WEBUI})
|
set(LLAMA_USE_PREBUILT_UI ${LLAMA_USE_PREBUILT_WEBUI})
|
||||||
message(DEPRECATION "LLAMA_USE_PREBUILT_WEBUI is deprecated, use LLAMA_USE_PREBUILT_UI instead")
|
message(DEPRECATION "LLAMA_USE_PREBUILT_WEBUI is deprecated, use LLAMA_USE_PREBUILT_UI instead")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -617,8 +617,6 @@ struct common_params {
|
|||||||
// UI configs
|
// UI configs
|
||||||
#ifdef LLAMA_UI_DEFAULT_ENABLED
|
#ifdef LLAMA_UI_DEFAULT_ENABLED
|
||||||
bool ui = LLAMA_UI_DEFAULT_ENABLED != 0;
|
bool ui = LLAMA_UI_DEFAULT_ENABLED != 0;
|
||||||
#elif defined(LLAMA_WEBUI_DEFAULT_ENABLED)
|
|
||||||
bool ui = LLAMA_WEBUI_DEFAULT_ENABLED != 0;
|
|
||||||
#else
|
#else
|
||||||
bool ui = true; // default to enabled when not set
|
bool ui = true; // default to enabled when not set
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -231,11 +231,10 @@ bool server_http_context::init(const common_params & params) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto middleware_server_state = [this](const httplib::Request & req, httplib::Response & res) {
|
auto middleware_server_state = [this](const httplib::Request & req, httplib::Response & res) {
|
||||||
(void)req; // suppress unused parameter warning when LLAMA_BUILD_UI / LLAMA_BUILD_WEBUI is not defined
|
(void)req; // suppress unused parameter warning when LLAMA_BUILD_UI is not defined
|
||||||
bool ready = is_ready.load();
|
bool ready = is_ready.load();
|
||||||
if (!ready) {
|
if (!ready) {
|
||||||
// Support both old and new preprocessor defines
|
#if defined(LLAMA_BUILD_UI)
|
||||||
#if defined(LLAMA_BUILD_UI) || defined(LLAMA_BUILD_WEBUI)
|
|
||||||
auto tmp = string_split<std::string>(req.path, '.');
|
auto tmp = string_split<std::string>(req.path, '.');
|
||||||
if (req.path == "/" || (tmp.size() > 0 && tmp.back() == "html")) {
|
if (req.path == "/" || (tmp.size() > 0 && tmp.back() == "html")) {
|
||||||
res.status = 503;
|
res.status = 503;
|
||||||
@@ -313,8 +312,7 @@ bool server_http_context::init(const common_params & params) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Support both old and new preprocessor defines
|
#if defined(LLAMA_BUILD_UI)
|
||||||
#if defined(LLAMA_BUILD_UI) || defined(LLAMA_BUILD_WEBUI)
|
|
||||||
// using embedded static index.html
|
// using embedded static index.html
|
||||||
srv->Get(params.api_prefix + "/", [](const httplib::Request & /*req*/, httplib::Response & res) {
|
srv->Get(params.api_prefix + "/", [](const httplib::Request & /*req*/, httplib::Response & res) {
|
||||||
// COEP and COOP headers, required by pyodide (python interpreter)
|
// COEP and COOP headers, required by pyodide (python interpreter)
|
||||||
|
|||||||
+3
-10
@@ -14,12 +14,7 @@ endif()
|
|||||||
set(TARGET_SRCS "")
|
set(TARGET_SRCS "")
|
||||||
set(UI_COMPILE_DEFS "")
|
set(UI_COMPILE_DEFS "")
|
||||||
|
|
||||||
# Support both old (LLAMA_BUILD_WEBUI) and new (LLAMA_BUILD_UI) option names
|
if(LLAMA_BUILD_UI)
|
||||||
if(LLAMA_BUILD_WEBUI OR LLAMA_BUILD_UI)
|
|
||||||
if(LLAMA_BUILD_WEBUI AND NOT LLAMA_BUILD_UI)
|
|
||||||
message(DEPRECATION "LLAMA_BUILD_WEBUI is deprecated, use LLAMA_BUILD_UI instead")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(PUBLIC_ASSETS
|
set(PUBLIC_ASSETS
|
||||||
index.html
|
index.html
|
||||||
bundle.js
|
bundle.js
|
||||||
@@ -125,19 +120,17 @@ if(LLAMA_BUILD_WEBUI OR LLAMA_BUILD_UI)
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
list(APPEND UI_COMPILE_DEFS
|
list(APPEND UI_COMPILE_DEFS
|
||||||
LLAMA_BUILD_WEBUI # Deprecated: use LLAMA_BUILD_UI
|
|
||||||
LLAMA_BUILD_UI
|
LLAMA_BUILD_UI
|
||||||
LLAMA_WEBUI_DEFAULT_ENABLED=1 # Deprecated: use LLAMA_UI_DEFAULT_ENABLED
|
|
||||||
LLAMA_UI_DEFAULT_ENABLED=1
|
LLAMA_UI_DEFAULT_ENABLED=1
|
||||||
)
|
)
|
||||||
message(STATUS "UI: embedded with source: ${UI_SOURCE}")
|
message(STATUS "UI: embedded with source: ${UI_SOURCE}")
|
||||||
else()
|
else()
|
||||||
message(WARNING "UI: no source available. Neither local build (build/tools/ui/dist/) nor HF Bucket download succeeded.")
|
message(WARNING "UI: no source available. Neither local build (build/tools/ui/dist/) nor HF Bucket download succeeded.")
|
||||||
message(WARNING "UI: building server without embedded UI. Set LLAMA_BUILD_UI=OFF to suppress this warning.")
|
message(WARNING "UI: building server without embedded UI. Set LLAMA_BUILD_UI=OFF to suppress this warning.")
|
||||||
list(APPEND UI_COMPILE_DEFS LLAMA_WEBUI_DEFAULT_ENABLED=0 LLAMA_UI_DEFAULT_ENABLED=0)
|
list(APPEND UI_COMPILE_DEFS LLAMA_UI_DEFAULT_ENABLED=0)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
list(APPEND UI_COMPILE_DEFS LLAMA_WEBUI_DEFAULT_ENABLED=0 LLAMA_UI_DEFAULT_ENABLED=0)
|
list(APPEND UI_COMPILE_DEFS LLAMA_UI_DEFAULT_ENABLED=0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Build the static library
|
# Build the static library
|
||||||
|
|||||||
Reference in New Issue
Block a user