forked from esmuellert/codediff.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
156 lines (115 loc) · 4.2 KB
/
CMakeLists.txt
File metadata and controls
156 lines (115 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
cmake_minimum_required(VERSION 3.15)
# Export compile commands for clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Read version from VERSION file (single source of truth)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" FULL_VERSION)
string(STRIP "${FULL_VERSION}" FULL_VERSION)
# Extract base version for CMake (handles prerelease like 2.0.0-next.1)
string(REGEX REPLACE "^([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" BASE_VERSION "${FULL_VERSION}")
project(vscode-diff-nvim VERSION ${BASE_VERSION})
# Store full version for display/packaging
set(PROJECT_FULL_VERSION "${FULL_VERSION}")
# This is the root CMakeLists.txt for the Neovim plugin
# It delegates C building to libvscode-diff/
# Enable testing at root level so CTest can find tests from subdirectories
enable_testing()
# Add C core subdirectory
add_subdirectory(libvscode-diff)
message(STATUS "===========================================")
message(STATUS " vscode-diff.nvim Plugin")
message(STATUS "===========================================")
message(STATUS " Build the plugin:")
message(STATUS " cmake -B build")
message(STATUS " cmake --build build")
message(STATUS "")
message(STATUS " Run C tests:")
message(STATUS " cmake --build build --target test")
message(STATUS " ctest --test-dir build")
message(STATUS "")
message(STATUS " Run Lua tests:")
message(STATUS " ./tests/run_tests.sh")
message(STATUS " make test-lua")
message(STATUS "===========================================")
# Generate Makefile wrappers that delegate to CMake
# This allows developers to use 'make' (Linux/macOS) or 'nmake' (Windows)
# Users without CMake can still use build.sh / build.cmd
# Generate Makefile for Unix/Linux/macOS
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/Makefile"
"# Auto-generated by CMake - DO NOT EDIT
# Makefile wrapper for developers (uses CMake underneath)
# Users: Use build.sh instead (no CMake required)
.PHONY: all build test test-c test-lua lint format clean help bump-patch bump-minor bump-major bump-prerelease
all: build
build:
\t@cmake -B build -S .
\t@cmake --build build
\t@echo \"✓ Build successful\"
test: test-c test-lua
test-c: build
\t@cd build && ctest --output-on-failure
test-lua:
\t@./tests/run_plenary_tests.sh
lint:
\t@stylua --check lua
format:
\t@stylua lua
\t@echo \"✓ Formatted lua/\"
clean:
\t@rm -rf build
\t@rm -f libvscode_diff.so libvscode_diff.dylib
bump-patch:
\t@node scripts/bump_version.mjs patch
bump-minor:
\t@node scripts/bump_version.mjs minor
bump-major:
\t@node scripts/bump_version.mjs major
bump-prerelease:
\t@node scripts/bump_version.mjs prerelease
help:
\t@echo \"Targets: build, test, test-c, test-lua, lint, clean, help\"
\t@echo \"Version: bump-patch, bump-minor, bump-major, bump-prerelease\"
")
# Generate Makefile.win for Windows nmake
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.win"
"# Auto-generated by CMake - DO NOT EDIT
# Makefile wrapper for Windows developers (uses CMake underneath)
# Usage: nmake /f Makefile.win
# Users: Use build.cmd instead (no CMake required)
all: do-build
# Force build to always run (nmake doesn't have .PHONY)
do-build:
\t@cmake -B build -S .
\t@cmake --build build --config Release
\t@echo Build successful
\t@echo NOTE: If DLL copy failed, close nvim and rebuild
build: do-build
test: test-c test-lua
test-c: build
\tctest --test-dir build --output-on-failure -C Release
test-lua:
\tnvim --headless --noplugin -u tests/init.lua -c \"lua require('plenary.test_harness').test_directory('tests', { minimal_init = vim.fn.getcwd() .. '/tests/init.lua' })\"
lint:
\tstylua --check lua
format:
\tstylua lua
\t@echo Formatted lua/
clean:
\tif exist build rmdir /s /q build
\tif exist libvscode_diff.dll del /q libvscode_diff.dll
bump-patch:
\tnode scripts/bump_version.mjs patch
bump-minor:
\tnode scripts/bump_version.mjs minor
bump-major:
\tnode scripts/bump_version.mjs major
bump-prerelease:
\tnode scripts/bump_version.mjs prerelease
help:
\t@echo Targets: build, test, test-c, test-lua, lint, clean, help
\t@echo Version: bump-patch, bump-minor, bump-major, bump-prerelease
")
message(STATUS "")
message(STATUS "Generated Makefiles:")
message(STATUS " Makefile - for make (Linux/macOS)")
message(STATUS " Makefile.win - for nmake /f Makefile.win (Windows)")
message(STATUS "")