Skip to content

Commit

Permalink
removed/added dependence, updates for decoupling
Browse files Browse the repository at this point in the history
- files removed know part of a separate repo dependency https://github.com/zelang-dev/c-raii
  • Loading branch information
TheTechsTech committed May 15, 2024
1 parent 5bdd08b commit 18ba4c7
Show file tree
Hide file tree
Showing 101 changed files with 11,025 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dkms.conf
build/
.frontmatter/
frontmatter.json
coroutine-built/
built/
*.crt
*.pem
*.key
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ set(C_STANDARD 89)

include(CMakeDependentOption)
include(GNUInstallDirs)
cmake_dependent_option(CO_BUILD_TESTS
"Build the unit tests when BUILD_TESTING is enabled and we are the root project" ON
cmake_dependent_option(BUILD_TESTING
"Build the unit tests when BUILD_TESTING is enabled and we are the root project" OFF
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)

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

set(CMAKE_CONFIGURATION_TYPES=Debug;Release)
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
set(BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/coroutine-built")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/built")

option(LIBUV_BUILD_SHARED "Build shared lib" OFF)

add_subdirectory(deps/libuv)

file(GLOB lib_files
${CMAKE_SOURCE_DIR}/src/*.c
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
)

add_definitions(-DCO_SCRAPE_SIZE=64)
Expand All @@ -48,7 +49,7 @@ else()
endif()

target_include_directories(coroutine
AFTER PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

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

find_package(Threads REQUIRED)
target_link_libraries(coroutine ${CMAKE_THREAD_LIBS_INIT})
add_subdirectory(deps/raii)
target_link_libraries(coroutine PUBLIC raii)

if(CO_BUILD_TESTS)
if(BUILD_TESTING)
add_subdirectory(examples)
endif()

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -735,14 +735,14 @@ int co_main(int argc, char **argv)
## Installation
The build system uses **cmake**, that produces _single_ **static** library stored under `coroutine-built`, and the complete `include` folder is needed.
The build system uses **cmake**, that produces _single_ **static** library stored under `built`, and the complete `include` folder is needed.
**Linux**
```shell
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug/Release -DBUILD_TESTING=ON/OFF # use to build files examples folder
cmake .. -DCMAKE_BUILD_TYPE=Debug/Release -DBUILD_TESTING=ON # use to build files in examples folder
cmake --build .
```

Expand All @@ -751,7 +751,7 @@ cmake --build .
```shell
mkdir build
cd build
cmake .. -D BUILD_TESTING=ON/OFF # use to build files examples folder
cmake .. -D BUILD_TESTING=ON # use to build files in examples folder
cmake --build . --config Debug/Release
```

Expand Down
12 changes: 12 additions & 0 deletions deps/raii/.cl_32.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@echo off
if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" (
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars32.bat"
) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community" (
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
) else if EXIST "C:\Program Files\Microsoft Visual Studio\2022\BuildTools" (
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars32.bat"
) else if EXIST "C:\Program Files\Microsoft Visual Studio\2022\Community" (
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat"
) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" (
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars32.bat"
)
12 changes: 12 additions & 0 deletions deps/raii/.cl_64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@echo off
if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" (
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community" (
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
) else if EXIST "C:\Program Files\Microsoft Visual Studio\2022\BuildTools" (
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
) else if EXIST "C:\Program Files\Microsoft Visual Studio\2022\Community" (
%comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
) else if EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" (
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
)
2 changes: 2 additions & 0 deletions deps/raii/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
81 changes: 81 additions & 0 deletions deps/raii/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Windows & Linux & macOS
on:
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:
name: Linux ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: amd64
flags: -m64
- target: x86
flags: -m32
steps:
- uses: actions/checkout@v4
- name: Prepare
run: |
sudo dpkg --add-architecture i386
sudo apt-get update -q -y
sudo apt-get install -y gcc-multilib g++-multilib valgrind libc6-dbg libc6-dbg:i386
- name: Configure & build
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DCMAKE_C_FLAGS=${{ matrix.flags }} ..
cmake --build .
- name: Run test examples
run: |
cd build
./test-defer
./test-exceptions
build-windows:
name: Windows (${{ matrix.arch }})
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
arch: [x64, Win32]
steps:
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- uses: actions/checkout@v4
- name: Configure & build
run: |
mkdir build
cd build
cmake .. -D BUILD_TESTING=ON -A ${{ matrix.arch }}
cmake --build . --config Debug
- name: Run test examples
shell: cmd
run: |
cd build\Debug
.\test-defer.exe
.\test-exceptions.exe
build-macos:
name: macOS
runs-on: macos-11
steps:
- uses: actions/checkout@v4
- name: Setup
run: |
brew install cmake
- name: Configure & build
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON ..
cmake --build .
- name: Run test examples
run: |
cd build
./test-defer
./test-exceptions
53 changes: 53 additions & 0 deletions deps/raii/.github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy Jekyll with GitHub Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
paths:
- "docs/**"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./docs
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v2

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
55 changes: 55 additions & 0 deletions deps/raii/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
.vscode/settings.json
build/
built/
80 changes: 80 additions & 0 deletions deps/raii/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
cmake_minimum_required(VERSION 2.8...3.14)

project(c-raii LANGUAGES C)

set(C_STANDARD 89)

include(CMakeDependentOption)
include(GNUInstallDirs)
message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")

set(CMAKE_CONFIGURATION_TYPES=Debug;Release)
set(BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/built")

cmake_dependent_option(BUILD_TESTING
"Build the unit tests when BUILD_TESTING is enabled and we are the root project" OFF
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)

option(BUILD_SHARED_LIBS "Build the library as a shared (dynamically-linked) " OFF)

file(GLOB raii_files
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
)

if(BUILD_SHARED_LIBS)
add_library(raii SHARED ${raii_files})
else()
add_library(raii STATIC ${raii_files})
endif()

set_property(TARGET raii PROPERTY POSITION_INDEPENDENT_CODE True)

target_include_directories(raii PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

if(UNIX)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -D NDEBUG")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fomit-frame-pointer -Wno-return-type")
endif()

if(WIN32)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /D NDEBUG")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions("/wd4244 /wd4267 /wd4033 /wd4715")
endif()

find_package(Threads)
target_link_libraries(raii PUBLIC ${CMAKE_THREAD_LIBS_INIT})

if (BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
add_subdirectory(examples)
endif()

set(_fmt TGZ)
if(WIN32)
set(_fmt ZIP)
endif()

set(CPACK_GENERATOR ${_fmt})
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_NUGET_COMPONENT_INSTALL ON)
set(CPACK_WIX_COMPONENT_INSTALL ON)
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
set(CPACK_VERBATIM_VARIABLES YES)

set(CPACK_PACKAGE_VENDOR "https://github.com/zelang-dev/c-raii")
set(CPACK_PACKAGE_VERSION 0.0.0)
include(CPack)

set(CMAKE_INSTALL_CONFIG_NAME ${CMAKE_BUILD_TYPE})
install(TARGETS ${raii} DESTINATION lib)
install(DIRECTORY include/ DESTINATION include)
Loading

0 comments on commit 18ba4c7

Please sign in to comment.