From 729975b14559f8a70ac7b9cf96aa68d4d8f0a29c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 20 Oct 2023 12:32:19 -0400 Subject: [PATCH 1/7] tidy: drop dead comments --- CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccf4b129..b2e5ca94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,8 +43,3 @@ add_subdirectory(src/pyreflect) # provide find_package() support xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) - -# ---------------------------------------------------------------- -# install .hpp files - -#xo_install_include_tree() From 3194fb35f78c94cc825d90cc5f2c5122d9c49e2d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 20 Oct 2023 12:34:06 -0400 Subject: [PATCH 2/7] fix include path for generated .hpp --- src/pyreflect/pyreflect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyreflect/pyreflect.cpp b/src/pyreflect/pyreflect.cpp index fc6e8fe8..c9b7f47a 100644 --- a/src/pyreflect/pyreflect.cpp +++ b/src/pyreflect/pyreflect.cpp @@ -1,7 +1,7 @@ /* @file pyreflect.cpp */ // note: need pyreflect/ here bc pyreflect.hpp is generated, located in build directory -#include "pyreflect.hpp" +#include "xo/pyreflect/pyreflect.hpp" #include "xo/reflect/TypeDescr.hpp" #include "xo/reflect/TaggedRcptr.hpp" #include "xo/reflect/SelfTagging.hpp" From 74a23f1132b54155567a9629b19b17d4a9feb2d6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 22 Oct 2023 14:55:32 -0400 Subject: [PATCH 3/7] pyreflect: + xo-pyutil dep --- src/pyreflect/CMakeLists.txt | 2 +- src/pyreflect/pyreflect.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyreflect/CMakeLists.txt b/src/pyreflect/CMakeLists.txt index 94a71814..64be5e08 100644 --- a/src/pyreflect/CMakeLists.txt +++ b/src/pyreflect/CMakeLists.txt @@ -9,4 +9,4 @@ set(SELF_SRCS pyreflect.cpp) xo_pybind11_library(${SELF_LIB} ${PROJECT_NAME}Targets ${SELF_SRCS}) xo_pybind11_dependency(${SELF_LIB} reflect) - +xo_pybind11_dependency(${SELF_LIB} xo_pyutil) diff --git a/src/pyreflect/pyreflect.cpp b/src/pyreflect/pyreflect.cpp index c9b7f47a..fc6e8fe8 100644 --- a/src/pyreflect/pyreflect.cpp +++ b/src/pyreflect/pyreflect.cpp @@ -1,7 +1,7 @@ /* @file pyreflect.cpp */ // note: need pyreflect/ here bc pyreflect.hpp is generated, located in build directory -#include "xo/pyreflect/pyreflect.hpp" +#include "pyreflect.hpp" #include "xo/reflect/TypeDescr.hpp" #include "xo/reflect/TaggedRcptr.hpp" #include "xo/reflect/SelfTagging.hpp" From 098c979f2dfbc3ebce880f5ffdb874370d39dc04 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 22 Oct 2023 15:53:04 -0400 Subject: [PATCH 4/7] cmake target pyreflect -> xo_pyreflect --- src/pyreflect/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyreflect/CMakeLists.txt b/src/pyreflect/CMakeLists.txt index 64be5e08..d4acdbfa 100644 --- a/src/pyreflect/CMakeLists.txt +++ b/src/pyreflect/CMakeLists.txt @@ -1,6 +1,6 @@ # xo_pyreflect/src/pyreflect/CMakeLists.txt -set(SELF_LIB pyreflect) +set(SELF_LIB xo_pyreflect) set(SELF_SRCS pyreflect.cpp) # ---------------------------------------------------------------- From 484b2e9f0d3118dbfae826a2beaa9417b13df0c3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Oct 2023 20:36:44 -0400 Subject: [PATCH 5/7] cosmetic: drop unneeded comments --- src/pyreflect/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pyreflect/CMakeLists.txt b/src/pyreflect/CMakeLists.txt index 94a71814..e53926d0 100644 --- a/src/pyreflect/CMakeLists.txt +++ b/src/pyreflect/CMakeLists.txt @@ -3,10 +3,5 @@ set(SELF_LIB pyreflect) set(SELF_SRCS pyreflect.cpp) -# ---------------------------------------------------------------- -# pybind11 dep - xo_pybind11_library(${SELF_LIB} ${PROJECT_NAME}Targets ${SELF_SRCS}) - xo_pybind11_dependency(${SELF_LIB} reflect) - From fd279f0e38601c288451354cf5d052c7ce3d9c0f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 15 Mar 2024 19:30:07 -0400 Subject: [PATCH 6/7] build: streamline CMAKE_MODULE_PATH interaction --- .gitignore | 2 +- CMakeLists.txt | 4 +--- README.md | 36 ++++++++++++++++++++++----------- cmake/xo-bootstrap-macros.cmake | 12 +++++++++++ 4 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 cmake/xo-bootstrap-macros.cmake diff --git a/.gitignore b/.gitignore index f52f1311..53a9c92f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # lsp keeps state here .cache # typical build directory -build +.build* # lsp: symlink to file in build directory (established manually) compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index b2e5ca94..5d84942e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,7 @@ cmake_minimum_required(VERSION 3.10) project(xo_pyreflect VERSION 0.1) enable_language(CXX) -# common XO cmake macros (see github.com:Rconybea/xo-cmake) -include(xo_macros/xo_cxx) -include(xo_macros/code-coverage) +include(cmake/xo-bootstrap-macros.cmake) # ---------------------------------------------------------------- # unit test setup diff --git a/README.md b/README.md index 7be07dd9..078e1a1b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# python bindings for c++ reflection library (xo-reflect) +# python bindings for c++ reflection library (xo-pyreflect) ## Getting Started @@ -22,6 +22,22 @@ $ make install ``` (also see .github/workflows/main.yml) +## Examples + +Assumes `xo-pyreflect` installed to `~/local2/lib` + +``` +PYTHONPATH=~/local2/lib python +>>> import xo_pyreflect +>>> dir(xo_pyreflect) +['SelfTagging', 'TaggedRcptr', 'TypeDescr', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__'] +>>> xo_pyreflect.TypeDescr.print_reflected_types() + +``` +(Not _immediately_ interesting: no reflected types in `pyreflect` itself) + +## Development + ### build for unit test coverage ``` $ cd xo-pyreflect @@ -37,24 +53,20 @@ $ cmake \ ### LSP (language server) support LSP looks for compile commands in the root of the source tree; -while Cmake creates them in the root of its build directory. +while `cmake` creates them in the root of its build directory. ``` $ cd xo-pyreflect $ ln -s build/compile_commands.json # supply compile commands to LSP ``` -## Examples +### display cmake variables -Assumes `xo-pyreflect` installed to `~/local2/lib` +- `-L` list variables +- `-A` include 'advanced' variables +- `-H` include help text ``` -PYTHONPATH=~/local2/lib python ->>> import pyreflect ->>> dir(pyreflect) -['SelfTagging', 'TaggedRcptr', 'TypeDescr', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__'] ->>> pyreflect.TypeDescr.print_reflected_types() - +$ cd xo-pyprintjson/build +$ cmake -LAH ``` - -Not _immediately_ interesting: no reflected types in `pyreflect` itself diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..16644435 --- /dev/null +++ b/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,12 @@ +if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix")) + # default to typical install location for xo-project-macros + set(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake) +endif() + +message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") +message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + +# needs to have been installed somewhere on CMAKE_MODULE_PATH, +# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) +# +include(xo_macros/xo-project-macros) From 17d26aaf4efa1e772ea7961d09c297f3d4055234 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 29 Mar 2024 14:33:41 -0400 Subject: [PATCH 7/7] build: suppress bootstrap message in submodule build --- cmake/xo-bootstrap-macros.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake index 16644435..96592216 100644 --- a/cmake/xo-bootstrap-macros.cmake +++ b/cmake/xo-bootstrap-macros.cmake @@ -3,8 +3,10 @@ if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "pr set(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake) endif() -message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") -message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") +if (NOT XO_SUBMODULE_BUILD) + message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") + message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") +endif() # needs to have been installed somewhere on CMAKE_MODULE_PATH, # (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX)