Skip to content

Commit 8c1ada9

Browse files
committed
integrate verbm
1 parent ab78a1f commit 8c1ada9

File tree

15 files changed

+74
-408
lines changed

15 files changed

+74
-408
lines changed

.clangd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Diagnostics:
2+
UnusedIncludes: Strict

.github/ISSUE_TEMPLATE/sweep-template.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/bump.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: bump
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
bump:
12+
runs-on: ubuntu-latest
13+
if: ${{ ! startsWith(github.event.head_commit.message, 'Version bumped') }}
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
ref: main
20+
fetch-depth: 0 # we need all history to get tags and analyze commits
21+
22+
- run: |
23+
git config user.name "Maxim Voloshin"
24+
git config user.email "[email protected]"
25+
26+
- name: Install verbm
27+
run: pipx install verbm
28+
29+
- name: Bump version
30+
run: verbm up auto --commit --tag --push

.github/workflows/cmake.yml

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,27 @@ on:
77
branches: [main]
88
workflow_dispatch: {}
99

10-
env:
11-
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
12-
BUILD_TYPE: Release
13-
1410
jobs:
1511
build:
16-
# The CMake configure and build commands are platform agnostic and should work equally
17-
# well on Windows or Mac. You can convert this to a matrix build if you need
18-
# cross-platform coverage.
19-
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
2012
runs-on: ubuntu-22.04
2113

2214
steps:
23-
- name: Checkout repository
24-
uses: actions/checkout@v2
25-
26-
# - name: Get version
27-
# run: echo "VERSION=$(python ./version.py get -f vcpkg.json)" >> $GITHUB_ENV
15+
- name: Checkout
16+
uses: actions/checkout@v4
2817

2918
- name: Configure CMake
30-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
31-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
3219
run: >
33-
cmake -B ${{ github.workspace }}/build
34-
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
35-
36-
- name: Install generator
37-
run: |
38-
wget -O gen.zip https://github.com/chocolacula/easy_reflection_cpp/releases/download/3.0.0/er_gen-ubuntu22-x64.zip
39-
unzip gen.zip -d output
40-
chmod +x output/er_gen
20+
mkdir build && cd build &&
21+
cmake ..
22+
-DCMAKE_BUILD_TYPE:STRING=Release
23+
-DENABLE_GENERATOR:STRING=ON
4124
4225
- name: Build
43-
run: cmake --build ./build -j $(grep -c 'processor' /proc/cpuinfo) -t tests
26+
run: >
27+
cmake --build ./build
28+
-j $(grep -c 'processor' /proc/cpuinfo)
29+
-t er_gen tests
4430
4531
- name: Test
46-
working-directory: ${{ github.workspace }}/build
32+
working-directory: ./build
4733
run: ctest --rerun-failed --output-on-failure

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
.idea
22
.vs
33
.cache
4-
.DS_Store
4+
55
output
66
cmake-build*
77
build
88

99
example/generated
1010
tests/generated
1111
benchmarks/generated
12+
13+
.DS_Store

CMakeLists.txt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,6 @@ set_policies()
66

77
set(CMAKE_TOOLCHAIN_FILE vcpkg/scripts/buildsystems/vcpkg.cmake)
88

9-
# Get version from vcpkg.json manifest
10-
file(READ "${CMAKE_SOURCE_DIR}/vcpkg.json" VCPKG_MANIFEST_JSON)
11-
12-
string(JSON
13-
VCPKG_MANIFEST_PROJECT_VERSION
14-
ERROR_VARIABLE VCPKG_VERSION_ERROR
15-
GET ${VCPKG_MANIFEST_JSON} "version")
16-
17-
if(VCPKG_VERSION_ERROR)
18-
message(WARNING ${VCPKG_VERSION_ERROR})
19-
set(VCPKG_MANIFEST_PROJECT_VERSION "0.0.0")
20-
endif()
21-
229
# Enable vcpkg features
2310
option(ENABLE_TESTS "Enable tests" ON)
2411
option(ENABLE_GENERATOR "Enable generator" OFF)
@@ -35,13 +22,12 @@ if(ENABLE_BENCHMARKS)
3522
endif()
3623

3724
# Setup project
38-
project(easy_reflection VERSION ${VCPKG_MANIFEST_PROJECT_VERSION})
25+
project(easy_reflection VERSION 0.1.0)
3926

4027
set(CMAKE_CXX_STANDARD 17)
4128
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
4229
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
4330

44-
include(Dart)
4531
enable_testing()
4632

4733
add_subdirectory(library)

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ It parses C++ source code for special attributes. In the most straightforward si
88
The main idea is to use kinda dynamic typing for some type agnostic operations, like copying or getting the name of a type.
99
It makes it possible to determine a variable type and do the right job - print, serialize/deserialize.
1010

11-
If you are curious about the details of how it works you can find them in [DEV article](https://dev.to/chocolacula/how-to-write-reflection-for-c-4527).
11+
It's generally a proof of concept, created with the idea that it could be used for many years. If you are curious about the details of how it works, you can find them in [DEV article](https://dev.to/chocolacula/how-to-write-reflection-for-c-4527).
1212

1313
## Features
1414

@@ -83,5 +83,3 @@ JetBrains for Open Source Support
8383
<a href="https://jb.gg/OpenSourceSupport">
8484
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg" alt="JetBrains Logo" style="width:128px;height:128px;">
8585
</a>
86-
87-

example/main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include "data/colors.h"
88
#include "er/reflection/reflection.h"
99
#include "er/serialization/json.h"
10-
#include "er/serialization/yaml.h"
11-
#include "er/variable/box.h"
1210
#include "generated/reflection.h"
1311
#include "print.h"
1412

generator/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ set(SOURCES
2525

2626
add_executable(${PROJECT_NAME} ${SOURCES})
2727

28-
target_compile_definitions(${PROJECT_NAME} PRIVATE VERSION="${PROJECT_VERSION}")
29-
3028
find_path(TCLAP_INCLUDE_DIRS "tclap/Arg.h")
3129
include_directories(${TCLAP_INCLUDE_DIRS})
3230

generator/main.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020
#include "inja/inja.hpp"
2121
#include "inja/template.hpp"
2222

23+
namespace {
24+
const char* const kVersion = "0.1.0";
25+
} // namespace
26+
2327
int main(int argc, const char** argv) {
24-
TCLAP::CmdLine cmd("Easy Reflection code generator", ' ', VERSION);
28+
TCLAP::CmdLine cmd("Easy Reflection code generator", ' ', kVersion);
2529

2630
Files file_manager;
2731

readme/installation.md

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,15 @@ The project consits of two main parts:
55
- [Reflection library](../library)
66
- [Code generator](../generator)
77

8-
The Easy Reflection C++ Generator utilizes **Clang** libraries to analyze C++ source code. By default, these libraries are statically linked to facilitate distribution and provide precompiled binary [releases](https://github.com/chocolacula/easy_reflection_cpp/releases).
8+
The Easy Reflection C++ Generator utilizes **Clang** libraries to analyze C++ source code. To support reflection attributes in the source code, I had to patch `llvm` and link it as a dependency. Therefore, the only option is to build `llvm` from source. Be patient, as this process will not be quick.
99

10-
Before getting started, you should decide whether to use the precompiled binary release or build the generator manually. If you choose the manual option, configure and build the generator. CMake will handle everything for you.
11-
12-
Once you have the `er_gen` binary, you can start analyzing your project and generating code. To do this, ensure that your project produces a `compile_commands.json` file. If you're using CMake, you can easily enable this by adding the following line to your CMakeLists.txt file:
10+
To analyze your project and generate reflection code, ensure you have a `compile_commands.json` file. If you're using CMake, you can easily enable this by adding the following line to your `CMakeLists.txt` file:
1311

1412
```cmake
1513
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1614
```
1715

18-
### Troubleshooting
19-
20-
If you encounter errors like `stddef.h` or `stdarg.h` not being found during the generation process, add the following line to your `CMakeLists.txt` file:
21-
22-
```cmake
23-
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
24-
```
25-
26-
### Windows
16+
## Windows
2717

2818
Visual Studio CMake generators do not create `compile_commands.json`. However, you can use [Ninja](https://ninja-build.org/) instead.
2919

@@ -38,10 +28,6 @@ If you choose the MSVC compiler, additionally install:
3828
- C++ ATL
3929
- Windows SDK
4030

41-
### Docker
42-
43-
This repository includes a `Dockerfile` that sets up an `Ubuntu 22.04` environment, builds the generator, and runs tests on startup.
44-
4531
## Further steps
4632

4733
Another submodule is [vcpkg](https://github.com/microsoft/vcpkg) which manages most of the dependencies, all of them will be installed by CMake automatically.
@@ -54,45 +40,14 @@ If, for some reason, you want to exclude `simdjson` from the dependencies, you c
5440
-DUSE_SIMD_JSON=OFF
5541
```
5642

57-
## LLVM & Clang dynamic linking
58-
59-
It is not supported officialy but nevertheless it exists.
60-
61-
Replace lines in the end of [CMakeLists.txt](../generator/CMakeLists.txt)
62-
63-
```cmake
64-
find_package(LLVM REQUIRED)
65-
66-
include_directories(${LLVM_INCLUDE_DIR})
67-
link_directories(${LLVM_LIBRARY_DIR})
68-
69-
target_link_libraries(${PROJECT_NAME} PRIVATE LLVM clang-cpp)
70-
```
71-
72-
### Linux
73-
74-
You can install libraries from package manager of your distro such as **Ubuntu** or **Arch Linux** or build them from source:
75-
76-
```bash
77-
cd llvm-project/build
43+
## Docker
7844

79-
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang -DLLVM_ENABLE_RTTI=ON -DLLVM_LINK_LLVM_DYLIB=ON -DCLANG_LINK_CLANG_DYLIB=ON ../llvm
80-
```
81-
82-
### Apple
45+
This repository includes a `Dockerfile` that sets up an `Ubuntu 22.04` environment, builds the generator, and runs tests on startup.
8346

84-
Apple's macOS doesn't have standard Clang libs by default, but happily you can use `brew`.
47+
## Troubleshooting
8548

86-
```bash
87-
brew install llvm
88-
```
89-
90-
Don't forget to specify the path to LLVM.
49+
If you encounter errors like `stddef.h` or `stdarg.h` not being found during the generation process, add the following line to your `CMakeLists.txt` file:
9150

92-
```bash
93-
-DLLVM_DIR=/opt/homebrew/opt/llvm/lib/cmake/llvm
51+
```cmake
52+
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
9453
```
95-
96-
### Windows
97-
98-
Regrettably, MSVC does not support for this feature. However, there is some dark magic with MinGW and Clang you can delve into. Unfortunately, I cannot provide assistance with that particular matter.

sweep.yaml

Lines changed: 0 additions & 42 deletions
This file was deleted.

vcpkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reflection-cpp",
3-
"version": "3.1.0",
3+
"version": "0.1.0",
44
"default-features": [
55
"library"
66
],

0 commit comments

Comments
 (0)