Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 0 additions & 107 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,6 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_MODULE_STD 26)
set(CMAKE_CXX_MODULE_EXTENSIONS OFF)

option(CPP_CORE_ENABLE_AST_EXPORT "Enable clang-based JSON AST export for the FFI headers" ON)
set(
CPP_CORE_AST_JSON_OUTPUT
"${CMAKE_BINARY_DIR}/ast/cpp_core_ffi_ast.json"
CACHE FILEPATH
"Output path for the generated FFI AST JSON file"
)
set(
CPP_CORE_AST_CLANGXX
""
CACHE FILEPATH
"Path to the clang++ executable used for AST JSON export"
)
set(
CPP_CORE_AST_SLIM_JSON_OUTPUT
"${CMAKE_BINARY_DIR}/ast/cpp_core_ffi_api.json"
CACHE FILEPATH
"Output path for the reduced FFI API JSON metadata"
)

include(cmake/CPM.cmake)

CPMAddPackage(
Expand Down Expand Up @@ -93,85 +73,6 @@ if(BUILD_TESTING)
target_link_libraries(cpp_core_compile_tests PRIVATE cpp_core_strict_warnings)
endif()

if(CPP_CORE_ENABLE_AST_EXPORT)
find_package(Python3 COMPONENTS Interpreter REQUIRED)

file(
GLOB _cpp_core_ast_interface_headers
CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/include/cpp_core/interface/*.h"
)

set(
_cpp_core_ast_headers
"${CMAKE_CURRENT_SOURCE_DIR}/include/cpp_core/serial.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/cpp_core/error_callback.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/cpp_core/module_api.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/cpp_core/version.hpp"
${_cpp_core_ast_interface_headers}
)

if(CPP_CORE_AST_CLANGXX)
set(_cpp_core_ast_clangxx "${CPP_CORE_AST_CLANGXX}")
else()
find_program(_cpp_core_ast_clangxx NAMES clang++)
endif()

if(NOT _cpp_core_ast_clangxx)
message(
FATAL_ERROR
"CPP_CORE_ENABLE_AST_EXPORT=ON requires clang++. "
"Install clang++ or set CPP_CORE_AST_CLANGXX to an explicit path."
)
endif()

set(_cpp_core_ast_wrapper "${CMAKE_CURRENT_BINARY_DIR}/ast/cpp_core_ffi_ast.cpp")
get_filename_component(_cpp_core_ast_json_dir "${CPP_CORE_AST_JSON_OUTPUT}" DIRECTORY)
get_filename_component(_cpp_core_ast_slim_json_dir "${CPP_CORE_AST_SLIM_JSON_OUTPUT}" DIRECTORY)

file(
GENERATE
OUTPUT "${_cpp_core_ast_wrapper}"
CONTENT "#include <cpp_core/serial.h>\n"
)

add_custom_command(
OUTPUT "${CPP_CORE_AST_JSON_OUTPUT}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${_cpp_core_ast_json_dir}"
COMMAND
${CMAKE_COMMAND}
-DCPP_CORE_AST_CLANGXX=${_cpp_core_ast_clangxx}
-DCPP_CORE_AST_INCLUDE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/include
-DCPP_CORE_AST_OUTPUT=${CPP_CORE_AST_JSON_OUTPUT}
-DCPP_CORE_AST_SOURCE=${_cpp_core_ast_wrapper}
-DCPP_CORE_AST_STANDARD=${CMAKE_CXX_STANDARD}
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/export_ast_json.cmake
DEPENDS "${_cpp_core_ast_wrapper}" ${_cpp_core_ast_headers}
COMMENT "Exporting FFI header AST JSON with clang++"
VERBATIM
)

add_custom_command(
OUTPUT "${CPP_CORE_AST_SLIM_JSON_OUTPUT}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${_cpp_core_ast_slim_json_dir}"
COMMAND
"${Python3_EXECUTABLE}"
"${CMAKE_CURRENT_SOURCE_DIR}/tools/clang_ast_to_ffi_json.py"
--input "${CPP_CORE_AST_JSON_OUTPUT}"
--output "${CPP_CORE_AST_SLIM_JSON_OUTPUT}"
--source-root "${CMAKE_CURRENT_SOURCE_DIR}"
--public-header "cpp_core/serial.h"
DEPENDS
"${CPP_CORE_AST_JSON_OUTPUT}"
"${CMAKE_CURRENT_SOURCE_DIR}/tools/clang_ast_to_ffi_json.py"
COMMENT "Reducing clang AST JSON to compact FFI API metadata"
VERBATIM
)

add_custom_target(cpp_core_ast_raw_json DEPENDS "${CPP_CORE_AST_JSON_OUTPUT}")
add_custom_target(cpp_core_ast_slim_json DEPENDS "${CPP_CORE_AST_SLIM_JSON_OUTPUT}")
endif()

# Install rules --------------------------------------------------------------
include(GNUInstallDirs)

Expand All @@ -185,14 +86,6 @@ install(
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

if(CPP_CORE_ENABLE_AST_EXPORT)
install(
FILES "${CPP_CORE_AST_SLIM_JSON_OUTPUT}"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cpp_core
OPTIONAL
)
endif()

# CMake package configuration ------------------------------------------------
include(CMakePackageConfigHelpers)

Expand Down
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,6 @@ The CMake project exports the package target and also builds these relevant targ
- `cpp_core::cpp_core`: header-only interface target
- `cpp_core_compile_tests`: compile-time validation target when testing is enabled

Optional FFI AST export:

```sh
cmake -S . -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE=cmake/gcc-toolchain.cmake -DCPP_CORE_ENABLE_AST_EXPORT=ON
cmake --build build --target cpp_core_ast_slim_json
```

- The project still configures with GCC; the AST export itself invokes `clang++` separately
- The current FFI generation workflow is validated with `clang++ 22.1.4` (`Fedora 22.1.4-1.fc44`)
- `cpp_core_ast_raw_json` builds only the raw clang AST dump
- Requires `clang++` on `PATH` or `-DCPP_CORE_AST_CLANGXX=/path/to/clang++`
- Requires a Python 3 interpreter for the slim metadata reduction step
- Writes the combined FFI header AST JSON to `build/ast/cpp_core_ffi_ast.json`
- Writes compact, ship-friendly FFI metadata to `build/ast/cpp_core_ffi_api.json`
- Exports the `#include <cpp_core/serial.h>` surface intended for downstream FFI adapter generation

## ABI Surface

The main aggregated interface lives in:
Expand Down
50 changes: 0 additions & 50 deletions cmake/export_ast_json.cmake

This file was deleted.

Loading