Skip to content

Commit 3191d5e

Browse files
committed
feat:Add MSVC toolchain support, timezone shims, and update roadmap docs
1 parent bcd8849 commit 3191d5e

File tree

7 files changed

+1186
-55
lines changed

7 files changed

+1186
-55
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ jobs:
2323
run: |
2424
make
2525
26+
- name: Configure on Windows
27+
if: runner.os == 'Windows'
28+
run: |
29+
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DSTRAP_BUILD_TESTS=ON -DSTRAP_BUILD_BENCHMARKS=OFF -DCMAKE_BUILD_TYPE=Release
30+
2631
- name: Build on Windows
2732
if: runner.os == 'Windows'
2833
run: |
29-
gcc -Wall -Wextra -O2 -c strap.c -o strap.o
30-
ar rcs libstrap.a strap.o
34+
cmake --build build --config Release
3135
3236
- name: Run tests on Linux/macOS
3337
if: runner.os != 'Windows'
@@ -39,9 +43,7 @@ jobs:
3943
- name: Run tests on Windows
4044
if: runner.os == 'Windows'
4145
run: |
42-
cd tests
43-
gcc -I.. -L.. -o test_strap.exe test_strap.c -lstrap
44-
./test_strap.exe
46+
ctest --test-dir build --config Release --output-on-failure
4547
4648
release:
4749
needs: build

CMakeLists.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
3+
project(strap LANGUAGES C)
4+
5+
option(STRAP_BUILD_TESTS "Build STRAP tests" ON)
6+
option(STRAP_BUILD_BENCHMARKS "Build STRAP benchmarks" OFF)
7+
8+
add_library(strap STATIC strap.c)
9+
target_include_directories(
10+
strap
11+
PUBLIC
12+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
13+
$<INSTALL_INTERFACE:include>)
14+
target_compile_features(strap PRIVATE c_std_99)
15+
16+
if(MSVC)
17+
target_compile_options(strap PRIVATE /W4 /permissive-)
18+
target_compile_definitions(
19+
strap
20+
PRIVATE
21+
_CRT_SECURE_NO_WARNINGS
22+
_CRT_NONSTDC_NO_DEPRECATE)
23+
else()
24+
target_compile_options(strap PRIVATE -Wall -Wextra)
25+
endif()
26+
27+
if(STRAP_BUILD_TESTS)
28+
enable_testing()
29+
add_executable(strap_tests tests/test_strap.c)
30+
target_link_libraries(strap_tests PRIVATE strap)
31+
if(MSVC)
32+
target_compile_definitions(
33+
strap_tests
34+
PRIVATE
35+
_CRT_SECURE_NO_WARNINGS
36+
_CRT_NONSTDC_NO_DEPRECATE)
37+
endif()
38+
add_test(NAME strap_tests COMMAND strap_tests)
39+
endif()
40+
41+
if(STRAP_BUILD_BENCHMARKS)
42+
add_executable(strap_bench benchmarks/strap_bench.c)
43+
target_link_libraries(strap_bench PRIVATE strap)
44+
if(MSVC)
45+
target_compile_definitions(
46+
strap_bench
47+
PRIVATE
48+
_CRT_SECURE_NO_WARNINGS
49+
_CRT_NONSTDC_NO_DEPRECATE)
50+
endif()
51+
endif()
52+
53+
include(GNUInstallDirs)
54+
install(TARGETS strap
55+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
56+
install(FILES strap.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ A small, efficient C library providing missing utilities for safe and comfortabl
1212
- **[🚀 Quick Start Guide](../../wiki/Quick-Start)** - Get up and running in minutes
1313
- **[📋 API Reference](../../wiki/API-Reference)** - Detailed function documentation
1414
- **[💡 Examples](../../wiki/Examples)** - Code examples and use cases
15+
- **[🧰 Cookbook](../../wiki/Cookbook)** - Practical recipes for common tasks
1516

1617
## 🚀 Quick Start
1718

@@ -29,6 +30,17 @@ make bench
2930
./benchmarks/strap_bench
3031
```
3132

33+
### Windows (MSVC + CMake)
34+
35+
```powershell
36+
# From a Visual Studio Developer Command Prompt
37+
git clone https://github.com/murapadev/strap.git
38+
cd strap
39+
scripts\build_windows_msvc.bat Release
40+
```
41+
42+
The helper script configures the Visual Studio generator via CMake, builds the static library, and runs the unit tests. Adjust the generator string or build type inside the script to match your environment.
43+
3244
## 🔔 What's New in v0.2
3345

3446
- Faster joins and file reads through tighter allocation strategies
@@ -97,6 +109,21 @@ Call `strap_clear_error()` when you want to reset the status manually.
97109
- [x] Optional arena allocator for transient strings
98110
- [x] Timezone-aware time helpers
99111

112+
### v0.4 (Upcoming)
113+
114+
- [x] Additional performance optimizations
115+
- [x] SIMD-accelerated paths for common hot functions (`strtrim`, `strjoin`)
116+
- [x] Streaming-friendly buffering for `afgets` and file helpers (`strap_line_buffer_read`)
117+
- [x] Extended string manipulation utilities
118+
- [x] High-level split helpers with delimiter limits and predicates (`strsplit_limit`, `strsplit_predicate`)
119+
- [x] Case-insensitive comparison helpers (`strap_strcasecmp`, `strcaseeq`)
120+
- [x] Cross-platform improvements
121+
- [x] Official Windows/MSVC build scripts and CI coverage
122+
- [x] Locale/timezone shims for BSD and musl-targeted systems
123+
- [x] Enhanced documentation
124+
- [x] Cookbook-style guides for common patterns (log parsing, CSV wrangling)
125+
- [x] API reference refresh with usage notes and complexity details
126+
100127
## 📄 License
101128

102129
MIT Licensed - see [LICENSE](LICENSE) for details.

scripts/build_windows_msvc.bat

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
4+
set "BUILD_TYPE=%~1"
5+
if "%BUILD_TYPE%"=="" set BUILD_TYPE=Release
6+
7+
set "ROOT=%~dp0.."
8+
set "BUILD_DIR=%ROOT%\build\msvc"
9+
10+
echo Configuring STRAP (%BUILD_TYPE%)...
11+
cmake -S "%ROOT%" -B "%BUILD_DIR%" -G "Visual Studio 17 2022" -A x64 -DSTRAP_BUILD_TESTS=ON -DSTRAP_BUILD_BENCHMARKS=OFF -DCMAKE_BUILD_TYPE=%BUILD_TYPE%
12+
if errorlevel 1 (
13+
echo Failed to configure STRAP project.
14+
exit /b 1
15+
)
16+
17+
echo Building STRAP...
18+
cmake --build "%BUILD_DIR%" --config %BUILD_TYPE%
19+
if errorlevel 1 (
20+
echo Build failed.
21+
exit /b 1
22+
)
23+
24+
echo Running tests...
25+
ctest --test-dir "%BUILD_DIR%" --config %BUILD_TYPE% --output-on-failure
26+
exit /b %errorlevel%

0 commit comments

Comments
 (0)