Skip to content

Commit aff29ee

Browse files
committed
add files for windows
1 parent bff8a0f commit aff29ee

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

.github/workflows/build-windows.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build Windows DLL (lib/windows/x64)
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- ".github/workflows/build-windows.yml"
8+
- "c/windows/**"
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
win-x64:
15+
runs-on: windows-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up MSVC env
24+
uses: ilammy/msvc-dev-cmd@v1
25+
with:
26+
arch: x64
27+
28+
- name: Configure (CMake, x64, Release)
29+
run: >
30+
cmake
31+
-S c/windows
32+
-B build
33+
-G "Visual Studio 17 2022"
34+
-A x64
35+
-D CMAKE_BUILD_TYPE=Release
36+
37+
- name: Build
38+
run: cmake --build build --config Release --parallel
39+
40+
- name: Prepare lib/windows/x64
41+
shell: pwsh
42+
run: |
43+
New-Item -ItemType Directory -Path lib/windows/x64 -Force | Out-Null
44+
Copy-Item build/bin/Release/webview.dll lib/windows/x64/
45+
if (Test-Path build/lib/Release/webview.lib) {
46+
Copy-Item build/lib/Release/webview.lib lib/windows/x64/
47+
} elseif (Test-Path build/bin/Release/webview.lib) {
48+
Copy-Item build/bin/Release/webview.lib lib/windows/x64/
49+
}
50+
if (Test-Path build/bin/Release/webview.pdb) {
51+
Copy-Item build/bin/Release/webview.pdb lib/windows/x64/
52+
}
53+
54+
- name: Upload artifact
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: webview-windows-x64
58+
path: lib/windows/x64/

c/windows/CMakeLists.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
project(cl-webview-win LANGUAGES C CXX)
3+
4+
# x64 前提
5+
if (NOT MSVC OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
6+
message(FATAL_ERROR "This build expects MSVC on 64-bit (x64) Windows.")
7+
endif()
8+
9+
set(CMAKE_C_STANDARD 11)
10+
set(CMAKE_CXX_STANDARD 17)
11+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
12+
13+
include(FetchContent)
14+
# 上流 webview を取得(必要に応じてタグ固定)
15+
FetchContent_Declare(
16+
webview
17+
GIT_REPOSITORY https://github.com/webview/webview
18+
GIT_TAG 0.12.0
19+
)
20+
FetchContent_MakeAvailable(webview)
21+
22+
# C API を DLL 化(CFFI からロードする想定)
23+
add_library(webview SHARED)
24+
25+
# 上流の C API 実装(パスは上流リポ構成に追従)
26+
target_sources(webview PRIVATE
27+
${webview_SOURCE_DIR}/webview/webview_capi.cpp
28+
)
29+
30+
# 上流のコアにリンク
31+
target_link_libraries(webview PRIVATE webview::core)
32+
33+
# 必要に応じて DLL 名を固定したい場合は有効化
34+
# set_target_properties(webview PROPERTIES OUTPUT_NAME "libwebview")
35+
36+
# 出力先
37+
set_target_properties(webview PROPERTIES
38+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
39+
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
40+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
41+
)
42+
43+
if (MSVC)
44+
target_compile_definitions(webview PRIVATE -DUNICODE -D_UNICODE)
45+
# 静的ランタイム (/MT) にしたい場合は以下を有効化
46+
# foreach(flag_var CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE)
47+
# string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
48+
# endforeach()
49+
endif()
50+
51+
target_compile_definitions(webview PRIVATE WEBVIEW_LISP_BINDING=1)

0 commit comments

Comments
 (0)