Skip to content

Commit 6471626

Browse files
authored
Merge pull request #686 from triuk/main
Fix: CMakeLists.txt wrong path and README inconsistencies
2 parents ad3fbc2 + ab6a15c commit 6471626

4 files changed

Lines changed: 63 additions & 17 deletions

File tree

CMakeLists.txt

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,64 @@ if (WEBUI_BUILD_EXAMPLES)
120120

121121
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
122122

123-
add_executable(minimal ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/minimal/main.cpp)
123+
# C++ examples
124+
add_executable(minimal_cpp ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/minimal/main.cpp)
124125
add_executable(call_js_from_cpp ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/call_js_from_cpp/main.cpp)
125-
add_executable(call_js_from_cpp_class ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/call_js_from_cpp_class/main.cpp)
126-
add_executable(serve_a_folder ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/serve_a_folder/main.cpp)
127-
add_executable(call_js_from_c ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/call_js_from_c/main.c)
126+
add_executable(call_cpp_from_js ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/call_cpp_from_js/main.cpp)
127+
add_executable(serve_a_folder_cpp ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/serve_a_folder/main.cpp)
128+
add_executable(virtual_file_system_cpp ${CMAKE_CURRENT_SOURCE_DIR}/examples/C++/virtual_file_system/main.cpp)
128129

129-
target_link_libraries(minimal webui)
130+
# C examples
131+
add_executable(minimal_c ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/minimal/main.c)
132+
add_executable(call_js_from_c ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/call_js_from_c/main.c)
133+
add_executable(call_c_from_js ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/call_c_from_js/main.c)
134+
add_executable(serve_a_folder_c ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/serve_a_folder/main.c)
135+
add_executable(virtual_file_system_c ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/virtual_file_system/main.c)
136+
add_executable(public_network_access ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/public_network_access/main.c)
137+
add_executable(web_app_multi_client ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/web_app_multi_client/main.c)
138+
add_executable(chatgpt_api ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/chatgpt_api/main.c)
139+
add_executable(custom_web_server ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/custom_web_server/main.c)
140+
add_executable(react ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/react/main.c)
141+
add_executable(frameless ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/frameless/main.c)
142+
add_executable(text_editor ${CMAKE_CURRENT_SOURCE_DIR}/examples/C/text-editor/main.c)
143+
144+
target_link_libraries(minimal_cpp webui)
130145
target_link_libraries(call_js_from_cpp webui)
131-
target_link_libraries(call_js_from_cpp_class webui)
132-
target_link_libraries(serve_a_folder webui)
146+
target_link_libraries(call_cpp_from_js webui)
147+
target_link_libraries(serve_a_folder_cpp webui)
148+
target_link_libraries(virtual_file_system_cpp webui)
149+
150+
target_link_libraries(minimal_c webui)
133151
target_link_libraries(call_js_from_c webui)
152+
target_link_libraries(call_c_from_js webui)
153+
target_link_libraries(serve_a_folder_c webui)
154+
target_link_libraries(virtual_file_system_c webui)
155+
target_link_libraries(public_network_access webui)
156+
target_link_libraries(web_app_multi_client webui)
157+
target_link_libraries(chatgpt_api webui)
158+
target_link_libraries(custom_web_server webui)
159+
target_link_libraries(react webui)
160+
target_link_libraries(frameless webui)
161+
target_link_libraries(text_editor webui)
134162

135163
if (MSVC)
136-
set_target_properties(minimal PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
164+
set_target_properties(minimal_cpp PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
137165
set_target_properties(call_js_from_cpp PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
138-
set_target_properties(call_js_from_cpp_class PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
139-
set_target_properties(serve_a_folder PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
166+
set_target_properties(call_cpp_from_js PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
167+
set_target_properties(serve_a_folder_cpp PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
168+
set_target_properties(virtual_file_system_cpp PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
169+
set_target_properties(minimal_c PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
140170
set_target_properties(call_js_from_c PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
171+
set_target_properties(call_c_from_js PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
172+
set_target_properties(serve_a_folder_c PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
173+
set_target_properties(virtual_file_system_c PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
174+
set_target_properties(public_network_access PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
175+
set_target_properties(web_app_multi_client PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
176+
set_target_properties(chatgpt_api PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
177+
set_target_properties(custom_web_server PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
178+
set_target_properties(react PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
179+
set_target_properties(frameless PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
180+
set_target_properties(text_editor PROPERTIES LINK_FLAGS "/SubSystem:\"Windows\"" VS_DPI_AWARE "ON")
141181
endif()
142182

143183
if (MSVC)

bridge/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# WebUI Bridge
22

3-
The WebUI Bridge connects the UI (_Web Browser_) with the backend application through WebSocket. This bridge is written in TypeScript, and it needs to be transpiled to JavaScript using [ESBuild](https://esbuild.github.io/) to produce `webui.js`, then converted to C header using the Python script `js2c.py` to generate `webui_bridge.h`.
3+
The WebUI Bridge connects the UI (_Web Browser_) with the backend application through WebSocket. This bridge is written in TypeScript, and it needs to be transpiled to JavaScript using [ESBuild](https://esbuild.github.io/) to produce `webui.js`, then converted to C header using the Node script `js2c.js` to generate `webui_bridge.h`.
44

55
### Windows
66

@@ -9,7 +9,7 @@ The WebUI Bridge connects the UI (_Web Browser_) with the backend application th
99
- cd `webui\bridge`
1010
- `npm install esbuild`
1111
- `.\node_modules\.bin\esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --outdir=.\ .\webui.ts`
12-
- `python js2c.py`
12+
- `node js2c.js`
1313

1414
### Windows PowerShell
1515

@@ -25,7 +25,7 @@ The WebUI Bridge connects the UI (_Web Browser_) with the backend application th
2525
- cd `webui/bridge`
2626
- `npm install esbuild`
2727
- `./node_modules/.bin/esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --outdir=./ ./webui.ts`
28-
- `python js2c.py`
28+
- `node js2c.js`
2929

3030
### Linux Bash
3131

@@ -39,7 +39,7 @@ The WebUI Bridge connects the UI (_Web Browser_) with the backend application th
3939
- cd `webui/bridge`
4040
- `npm install esbuild`
4141
- `./node_modules/.bin/esbuild --bundle --target="chrome90,firefox90,safari15" --format=esm --tree-shaking=false --outdir=./ ./webui.ts`
42-
- `python js2c.py`
42+
- `node js2c.js`
4343

4444
### macOS Bash
4545

examples/C++/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Examples of how to create a WebUI application in C++.
55
The only requirement to build the examples is a a C++11 compiler.
66

77
- `minimal`: Creates a minimal WebUI application.
8-
- `call_c_from_js`: Calls C++ from JavaScript.
9-
- `call_js_from_c`: Calls JavaScript from C++.
10-
- `call_js_from_cpp_class`: Calls JavaScript from C++ using class methods and member-function bind.
8+
- `call_cpp_from_js`: Calls C++ from JavaScript.
9+
- `call_js_from_cpp`: Calls JavaScript from C++ using class methods and member-function bind.
1110
- `serve_a_folder`: Uses WebUI to serve a folder with multiple files (class-based example using member-function bind).
11+
- `virtual_file_system`: Embeds files using a virtual file system.
1212

1313
To build an example, cd into its directory and run the make command.
1414

examples/C/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ The only requirement to build the examples is a C compiler.
1111
- `call_js_from_c`: Calls JavaScript from C.
1212
- `serve_a_folder`: Use WebUI to serve a folder that contains `.html`, `.css`, `.js`, or `.ts` files.
1313
- `custom_web_server`: Use your preferred web server like NGINX/Apache... with WebUI to serve a folder.
14+
- `chatgpt_api`: Calls ChatGPT API from C.
15+
- `frameless`: Frameless window example.
16+
- `public_network_access`: Allows network access to external devices.
17+
- `react`: React + WebUI example.
18+
- `virtual_file_system`: Embeds files using a virtual file system.
19+
- `web_app_multi_client`: Multiple clients example.
1420

1521
To build an example, cd into its directory and run the make command.
1622

0 commit comments

Comments
 (0)