Skip to content

Commit 18ba4c7

Browse files
committed
removed/added dependence, updates for decoupling
- files removed know part of a separate repo dependency https://github.com/zelang-dev/c-raii
1 parent 5bdd08b commit 18ba4c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+11025
-100
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dkms.conf
5454
build/
5555
.frontmatter/
5656
frontmatter.json
57-
coroutine-built/
57+
built/
5858
*.crt
5959
*.pem
6060
*.key

CMakeLists.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@ set(C_STANDARD 89)
66

77
include(CMakeDependentOption)
88
include(GNUInstallDirs)
9-
cmake_dependent_option(CO_BUILD_TESTS
10-
"Build the unit tests when BUILD_TESTING is enabled and we are the root project" ON
9+
cmake_dependent_option(BUILD_TESTING
10+
"Build the unit tests when BUILD_TESTING is enabled and we are the root project" OFF
1111
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
1212

1313
message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")
1414

1515
set(CMAKE_CONFIGURATION_TYPES=Debug;Release)
16-
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
16+
set(BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
1717
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIR})
18-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/coroutine-built")
18+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/built")
1919

2020
option(LIBUV_BUILD_SHARED "Build shared lib" OFF)
21+
2122
add_subdirectory(deps/libuv)
2223

2324
file(GLOB lib_files
24-
${CMAKE_SOURCE_DIR}/src/*.c
25+
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
2526
)
2627

2728
add_definitions(-DCO_SCRAPE_SIZE=64)
@@ -48,7 +49,7 @@ else()
4849
endif()
4950

5051
target_include_directories(coroutine
51-
AFTER PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
52+
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
5253

5354
if(UNIX)
5455
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -D NDEBUG -D CO_USE_VALGRIND ")
@@ -61,10 +62,10 @@ if(WIN32)
6162
add_definitions("/wd4244 /wd4267 /wd4033 /wd4715")
6263
endif()
6364

64-
find_package(Threads REQUIRED)
65-
target_link_libraries(coroutine ${CMAKE_THREAD_LIBS_INIT})
65+
add_subdirectory(deps/raii)
66+
target_link_libraries(coroutine PUBLIC raii)
6667

67-
if(CO_BUILD_TESTS)
68+
if(BUILD_TESTING)
6869
add_subdirectory(examples)
6970
endif()
7071

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,14 +735,14 @@ int co_main(int argc, char **argv)
735735
736736
## Installation
737737
738-
The build system uses **cmake**, that produces _single_ **static** library stored under `coroutine-built`, and the complete `include` folder is needed.
738+
The build system uses **cmake**, that produces _single_ **static** library stored under `built`, and the complete `include` folder is needed.
739739
740740
**Linux**
741741
742742
```shell
743743
mkdir build
744744
cd build
745-
cmake .. -DCMAKE_BUILD_TYPE=Debug/Release -DBUILD_TESTING=ON/OFF # use to build files examples folder
745+
cmake .. -DCMAKE_BUILD_TYPE=Debug/Release -DBUILD_TESTING=ON # use to build files in examples folder
746746
cmake --build .
747747
```
748748

@@ -751,7 +751,7 @@ cmake --build .
751751
```shell
752752
mkdir build
753753
cd build
754-
cmake .. -D BUILD_TESTING=ON/OFF # use to build files examples folder
754+
cmake .. -D BUILD_TESTING=ON # use to build files in examples folder
755755
cmake --build . --config Debug/Release
756756
```
757757

deps/raii/.cl_32.bat

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@echo off
2+
if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" (
3+
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars32.bat"
4+
) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community" (
5+
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
6+
) else if EXIST "C:\Program Files\Microsoft Visual Studio\2022\BuildTools" (
7+
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars32.bat"
8+
) else if EXIST "C:\Program Files\Microsoft Visual Studio\2022\Community" (
9+
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat"
10+
) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" (
11+
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars32.bat"
12+
)

deps/raii/.cl_64.bat

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@echo off
2+
if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" (
3+
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
4+
) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community" (
5+
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
6+
) else if EXIST "C:\Program Files\Microsoft Visual Studio\2022\BuildTools" (
7+
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
8+
) else if EXIST "C:\Program Files\Microsoft Visual Studio\2022\Community" (
9+
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
10+
) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" (
11+
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
12+
)

deps/raii/.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

deps/raii/.github/workflows/ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Windows & Linux & macOS
2+
on:
3+
pull_request:
4+
branches: [ main ]
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
name: Linux ${{ matrix.target }}
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
include:
15+
- target: amd64
16+
flags: -m64
17+
- target: x86
18+
flags: -m32
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Prepare
22+
run: |
23+
sudo dpkg --add-architecture i386
24+
sudo apt-get update -q -y
25+
sudo apt-get install -y gcc-multilib g++-multilib valgrind libc6-dbg libc6-dbg:i386
26+
- name: Configure & build
27+
run: |
28+
mkdir build
29+
cd build
30+
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DCMAKE_C_FLAGS=${{ matrix.flags }} ..
31+
cmake --build .
32+
- name: Run test examples
33+
run: |
34+
cd build
35+
./test-defer
36+
./test-exceptions
37+
38+
build-windows:
39+
name: Windows (${{ matrix.arch }})
40+
runs-on: windows-2019
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
arch: [x64, Win32]
45+
steps:
46+
- uses: ilammy/msvc-dev-cmd@v1
47+
with:
48+
arch: ${{ matrix.arch }}
49+
- uses: actions/checkout@v4
50+
- name: Configure & build
51+
run: |
52+
mkdir build
53+
cd build
54+
cmake .. -D BUILD_TESTING=ON -A ${{ matrix.arch }}
55+
cmake --build . --config Debug
56+
- name: Run test examples
57+
shell: cmd
58+
run: |
59+
cd build\Debug
60+
.\test-defer.exe
61+
.\test-exceptions.exe
62+
63+
build-macos:
64+
name: macOS
65+
runs-on: macos-11
66+
steps:
67+
- uses: actions/checkout@v4
68+
- name: Setup
69+
run: |
70+
brew install cmake
71+
- name: Configure & build
72+
run: |
73+
mkdir build
74+
cd build
75+
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON ..
76+
cmake --build .
77+
- name: Run test examples
78+
run: |
79+
cd build
80+
./test-defer
81+
./test-exceptions
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
2+
name: Deploy Jekyll with GitHub Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["main"]
8+
paths:
9+
- "docs/**"
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
21+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
22+
concurrency:
23+
group: "pages"
24+
cancel-in-progress: false
25+
26+
jobs:
27+
# Build job
28+
build:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
- name: Setup Pages
34+
uses: actions/configure-pages@v3
35+
- name: Build with Jekyll
36+
uses: actions/jekyll-build-pages@v1
37+
with:
38+
source: ./docs
39+
destination: ./_site
40+
- name: Upload artifact
41+
uses: actions/upload-pages-artifact@v2
42+
43+
# Deployment job
44+
deploy:
45+
environment:
46+
name: github-pages
47+
url: ${{ steps.deployment.outputs.page_url }}
48+
runs-on: ubuntu-latest
49+
needs: build
50+
steps:
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v2

deps/raii/.gitignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Object files
5+
*.o
6+
*.ko
7+
*.obj
8+
*.elf
9+
10+
# Linker output
11+
*.ilk
12+
*.map
13+
*.exp
14+
15+
# Precompiled Headers
16+
*.gch
17+
*.pch
18+
19+
# Libraries
20+
*.lib
21+
*.a
22+
*.la
23+
*.lo
24+
25+
# Shared objects (inc. Windows DLLs)
26+
*.dll
27+
*.so
28+
*.so.*
29+
*.dylib
30+
31+
# Executables
32+
*.exe
33+
*.out
34+
*.app
35+
*.i*86
36+
*.x86_64
37+
*.hex
38+
39+
# Debug files
40+
*.dSYM/
41+
*.su
42+
*.idb
43+
*.pdb
44+
45+
# Kernel Module Compile Results
46+
*.mod*
47+
*.cmd
48+
.tmp_versions/
49+
modules.order
50+
Module.symvers
51+
Mkfile.old
52+
dkms.conf
53+
.vscode/settings.json
54+
build/
55+
built/

deps/raii/CMakeLists.txt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
cmake_minimum_required(VERSION 2.8...3.14)
2+
3+
project(c-raii LANGUAGES C)
4+
5+
set(C_STANDARD 89)
6+
7+
include(CMakeDependentOption)
8+
include(GNUInstallDirs)
9+
message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")
10+
11+
set(CMAKE_CONFIGURATION_TYPES=Debug;Release)
12+
set(BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
13+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIR})
14+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/built")
15+
16+
cmake_dependent_option(BUILD_TESTING
17+
"Build the unit tests when BUILD_TESTING is enabled and we are the root project" OFF
18+
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
19+
20+
option(BUILD_SHARED_LIBS "Build the library as a shared (dynamically-linked) " OFF)
21+
22+
file(GLOB raii_files
23+
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
24+
)
25+
26+
if(BUILD_SHARED_LIBS)
27+
add_library(raii SHARED ${raii_files})
28+
else()
29+
add_library(raii STATIC ${raii_files})
30+
endif()
31+
32+
set_property(TARGET raii PROPERTY POSITION_INDEPENDENT_CODE True)
33+
34+
target_include_directories(raii PUBLIC
35+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
36+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
37+
)
38+
39+
if(UNIX)
40+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -D NDEBUG")
41+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fomit-frame-pointer -Wno-return-type")
42+
endif()
43+
44+
if(WIN32)
45+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /D NDEBUG")
46+
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
47+
add_definitions("/wd4244 /wd4267 /wd4033 /wd4715")
48+
endif()
49+
50+
find_package(Threads)
51+
target_link_libraries(raii PUBLIC ${CMAKE_THREAD_LIBS_INIT})
52+
53+
if (BUILD_TESTING)
54+
enable_testing()
55+
add_subdirectory(tests)
56+
add_subdirectory(examples)
57+
endif()
58+
59+
set(_fmt TGZ)
60+
if(WIN32)
61+
set(_fmt ZIP)
62+
endif()
63+
64+
set(CPACK_GENERATOR ${_fmt})
65+
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
66+
set(CPACK_DEB_COMPONENT_INSTALL ON)
67+
set(CPACK_RPM_COMPONENT_INSTALL ON)
68+
set(CPACK_NUGET_COMPONENT_INSTALL ON)
69+
set(CPACK_WIX_COMPONENT_INSTALL ON)
70+
set(CPACK_NSIS_MODIFY_PATH ON)
71+
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
72+
set(CPACK_VERBATIM_VARIABLES YES)
73+
74+
set(CPACK_PACKAGE_VENDOR "https://github.com/zelang-dev/c-raii")
75+
set(CPACK_PACKAGE_VERSION 0.0.0)
76+
include(CPack)
77+
78+
set(CMAKE_INSTALL_CONFIG_NAME ${CMAKE_BUILD_TYPE})
79+
install(TARGETS ${raii} DESTINATION lib)
80+
install(DIRECTORY include/ DESTINATION include)

0 commit comments

Comments
 (0)