Skip to content

Commit 8758904

Browse files
authored
cmake : fix LLAMA_BUILD_UI logic (#23190)
1 parent e0de4c2 commit 8758904

4 files changed

Lines changed: 8 additions & 24 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,15 @@ option(LLAMA_BUILD_TESTS "llama: build tests"
108108
option(LLAMA_BUILD_TOOLS "llama: build tools" ${LLAMA_STANDALONE})
109109
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
110110
option(LLAMA_BUILD_SERVER "llama: build server example" ${LLAMA_STANDALONE})
111-
# Deprecated: use LLAMA_BUILD_UI instead (kept for backward compat)
112-
option(LLAMA_BUILD_WEBUI "llama: build the embedded Web UI for server (deprecated: use LLAMA_BUILD_UI)" ON)
113-
option(LLAMA_USE_PREBUILT_WEBUI "llama: use prebuilt WebUI from HF Bucket when available (deprecated: use LLAMA_USE_PREBUILT_UI)" ON)
114-
115-
# New option names
116111
option(LLAMA_BUILD_UI "llama: build the embedded Web UI for server" ON)
117112
option(LLAMA_USE_PREBUILT_UI "llama: use prebuilt UI from HF Bucket when available (requires LLAMA_BUILD_UI=ON)" ON)
118113

119114
# Backward compat: when old var is set but new one isn't, forward the value
120-
if(DEFINED LLAMA_BUILD_WEBUI AND NOT DEFINED LLAMA_BUILD_UI)
115+
if(DEFINED LLAMA_BUILD_WEBUI)
121116
set(LLAMA_BUILD_UI ${LLAMA_BUILD_WEBUI})
122117
message(DEPRECATION "LLAMA_BUILD_WEBUI is deprecated, use LLAMA_BUILD_UI instead")
123118
endif()
124-
if(DEFINED LLAMA_USE_PREBUILT_WEBUI AND NOT DEFINED LLAMA_USE_PREBUILT_UI)
119+
if(DEFINED LLAMA_USE_PREBUILT_WEBUI)
125120
set(LLAMA_USE_PREBUILT_UI ${LLAMA_USE_PREBUILT_WEBUI})
126121
message(DEPRECATION "LLAMA_USE_PREBUILT_WEBUI is deprecated, use LLAMA_USE_PREBUILT_UI instead")
127122
endif()

common/common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,6 @@ struct common_params {
617617
// UI configs
618618
#ifdef LLAMA_UI_DEFAULT_ENABLED
619619
bool ui = LLAMA_UI_DEFAULT_ENABLED != 0;
620-
#elif defined(LLAMA_WEBUI_DEFAULT_ENABLED)
621-
bool ui = LLAMA_WEBUI_DEFAULT_ENABLED != 0;
622620
#else
623621
bool ui = true; // default to enabled when not set
624622
#endif

tools/server/server-http.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,10 @@ bool server_http_context::init(const common_params & params) {
231231
};
232232

233233
auto middleware_server_state = [this](const httplib::Request & req, httplib::Response & res) {
234-
(void)req; // suppress unused parameter warning when LLAMA_BUILD_UI / LLAMA_BUILD_WEBUI is not defined
234+
(void)req; // suppress unused parameter warning when LLAMA_BUILD_UI is not defined
235235
bool ready = is_ready.load();
236236
if (!ready) {
237-
// Support both old and new preprocessor defines
238-
#if defined(LLAMA_BUILD_UI) || defined(LLAMA_BUILD_WEBUI)
237+
#if defined(LLAMA_BUILD_UI)
239238
auto tmp = string_split<std::string>(req.path, '.');
240239
if (req.path == "/" || (tmp.size() > 0 && tmp.back() == "html")) {
241240
res.status = 503;
@@ -313,8 +312,7 @@ bool server_http_context::init(const common_params & params) {
313312
return 1;
314313
}
315314
} else {
316-
// Support both old and new preprocessor defines
317-
#if defined(LLAMA_BUILD_UI) || defined(LLAMA_BUILD_WEBUI)
315+
#if defined(LLAMA_BUILD_UI)
318316
// using embedded static index.html
319317
srv->Get(params.api_prefix + "/", [](const httplib::Request & /*req*/, httplib::Response & res) {
320318
// COEP and COOP headers, required by pyodide (python interpreter)

tools/ui/CMakeLists.txt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ endif()
1414
set(TARGET_SRCS "")
1515
set(UI_COMPILE_DEFS "")
1616

17-
# Support both old (LLAMA_BUILD_WEBUI) and new (LLAMA_BUILD_UI) option names
18-
if(LLAMA_BUILD_WEBUI OR LLAMA_BUILD_UI)
19-
if(LLAMA_BUILD_WEBUI AND NOT LLAMA_BUILD_UI)
20-
message(DEPRECATION "LLAMA_BUILD_WEBUI is deprecated, use LLAMA_BUILD_UI instead")
21-
endif()
22-
17+
if(LLAMA_BUILD_UI)
2318
set(PUBLIC_ASSETS
2419
index.html
2520
bundle.js
@@ -125,19 +120,17 @@ if(LLAMA_BUILD_WEBUI OR LLAMA_BUILD_UI)
125120
endforeach()
126121

127122
list(APPEND UI_COMPILE_DEFS
128-
LLAMA_BUILD_WEBUI # Deprecated: use LLAMA_BUILD_UI
129123
LLAMA_BUILD_UI
130-
LLAMA_WEBUI_DEFAULT_ENABLED=1 # Deprecated: use LLAMA_UI_DEFAULT_ENABLED
131124
LLAMA_UI_DEFAULT_ENABLED=1
132125
)
133126
message(STATUS "UI: embedded with source: ${UI_SOURCE}")
134127
else()
135128
message(WARNING "UI: no source available. Neither local build (build/tools/ui/dist/) nor HF Bucket download succeeded.")
136129
message(WARNING "UI: building server without embedded UI. Set LLAMA_BUILD_UI=OFF to suppress this warning.")
137-
list(APPEND UI_COMPILE_DEFS LLAMA_WEBUI_DEFAULT_ENABLED=0 LLAMA_UI_DEFAULT_ENABLED=0)
130+
list(APPEND UI_COMPILE_DEFS LLAMA_UI_DEFAULT_ENABLED=0)
138131
endif()
139132
else()
140-
list(APPEND UI_COMPILE_DEFS LLAMA_WEBUI_DEFAULT_ENABLED=0 LLAMA_UI_DEFAULT_ENABLED=0)
133+
list(APPEND UI_COMPILE_DEFS LLAMA_UI_DEFAULT_ENABLED=0)
141134
endif()
142135

143136
# Build the static library

0 commit comments

Comments
 (0)