diff --git a/ci.nix b/ci.nix index a7b8b6a2..fb0c730f 100644 --- a/ci.nix +++ b/ci.nix @@ -35,6 +35,7 @@ in xo-numeric xo-tokenizer2 xo-expression2 + xo-reader2 xo-allocutil xo-alloc xo-ratio diff --git a/pkgs/xo-reader2.nix b/pkgs/xo-reader2.nix new file mode 100644 index 00000000..7067c4a8 --- /dev/null +++ b/pkgs/xo-reader2.nix @@ -0,0 +1,43 @@ +{ + # nixpkgs dependencies + lib, stdenv, cmake, catch2, + + # xo dependencies + xo-numeric, + xo-procedure2, + xo-type, + xo-expression2, + xo-tokenizer2, + xo-gc, + xo-subsys, + xo-cmake, + + # config arguments + doCheck ? true +} : + +stdenv.mkDerivation (finalattrs : + { + name = "xo-expression2"; + + src = ../xo-expression2; + + cmakeFlags = ["-DCMAKE_MODULE_PATH=${xo-cmake}/share/cmake"] + ++ lib.optionals doCheck ["-DENABLE_TESTING=1"]; + + inherit doCheck; + + nativeBuildInputs = [ + cmake catch2 + xo-cmake + ]; + propagatedBuildInputs = [ + xo-numeric + xo-procedure2 + xo-type + xo-expression2 + xo-tokenizer2 + xo-gc + xo-subsys + ]; + }) diff --git a/shells.nix b/shells.nix index 7d563043..8078c94a 100644 --- a/shells.nix +++ b/shells.nix @@ -341,6 +341,7 @@ in numeric = pkgs.xo-numeric; tokenizer2 = pkgs.xo-tokenizer2; expression2 = pkgs.xo-expression2; + reader2 = pkgs.xo-reader2; allocutil = pkgs.xo-allocutil; alloc = pkgs.xo-alloc; diff --git a/xo-cmake/etc/xo/subsystem-list b/xo-cmake/etc/xo/subsystem-list index eea49525..61b69310 100644 --- a/xo-cmake/etc/xo/subsystem-list +++ b/xo-cmake/etc/xo/subsystem-list @@ -52,3 +52,8 @@ xo-process xo-pyprocess xo-kalmanfilter xo-pykalmanfilter +xo-imgui +xo-interpreter +xo-interpreter2 +xo-reader2 +xo-symboltable diff --git a/xo-pyrprintjson/.github/workflows/main.yml b/xo-pyrprintjson/.github/workflows/main.yml deleted file mode 100644 index af5526f6..00000000 --- a/xo-pyrprintjson/.github/workflows/main.yml +++ /dev/null @@ -1,196 +0,0 @@ -name: build xo-pyprintjson + dependencies - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - -jobs: - build: - # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. - # You can convert this to a matrix build if you need cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu-latest - - steps: - - name: checkout source - uses: actions/checkout@v3 - - - name: Install catch2 - # install catch2. see [[https://stackoverflow.com/questions/57982945/how-to-apt-get-install-in-a-github-actions-workflow]] - run: sudo apt-get install -y catch2 - - - name: Install pybind11-dev - run: sudo apt-get install -y pybind11-dev - - # ---------------------------------------------------------------- - - - name: Clone xo-cmake - uses: actions/checkout@v3 - with: - repository: Rconybea/xo-cmake - path: repo/xo-cmake - - - name: Configure xo-cmake - run: cmake -B ${{github.workspace}}/build_xo-cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/xo-cmake - - - name: Build xo-cmake (trivial) - run: cmake --build ${{github.workspace}}/build_xo-cmake --config ${{env.BUILD_TYPE}} - - - name: Install xo-cmake - run: cmake --install ${{github.workspace}}/build_xo-cmake - - # ---------------------------------------------------------------- - - - name: Clone indentlog - uses: actions/checkout@v3 - with: - repository: Rconybea/indentlog - path: repo/indentlog - - - name: Configure indentlog - # configure cmake for indentlog in dedicated build directory. - run: cmake -B ${{github.workspace}}/build_indentlog -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/indentlog - - - name: Build indentlog - run: cmake --build ${{github.workspace}}/build_indentlog --config ${{env.BUILD_TYPE}} - - - name: Install indentlog - # install into ${{github.workspace}}/local - run: cmake --install ${{github.workspace}}/build_indentlog - - # ---------------------------------------------------------------- - - - name: Clone subsys - uses: actions/checkout@v3 - with: - repository: Rconybea/subsys - path: repo/subsys - - - name: Configure subsys - # configure cmake for subsys in dedicated build directory. - run: cmake -B ${{github.workspace}}/build_subsys -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/subsys - - - name: Build subsys - run: cmake --build ${{github.workspace}}/build_subsys --config ${{env.BUILD_TYPE}} - - - name: Install subsys - # install into ${{github.workspace}}/local - run: cmake --install ${{github.workspace}}/build_subsys - - # ---------------------------------------------------------------- - - - name: Clone refcnt - uses: actions/checkout@v3 - with: - repository: Rconybea/refcnt - path: repo/refcnt - - - name: Configure refcnt - # configure cmake for refcnt in dedicated build directory. - run: cmake -B ${{github.workspace}}/build_refcnt -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/refcnt - - - name: Build refcnt - run: cmake --build ${{github.workspace}}/build_refcnt --config ${{env.BUILD_TYPE}} - - - name: Install refcnt - # install into ${{github.workspace}}/local - run: cmake --install ${{github.workspace}}/build_refcnt - - # ---------------------------------------------------------------- - - - name: Clone reflect - uses: actions/checkout@v3 - with: - repository: Rconybea/reflect - path: repo/reflect - - - name: Configure reflect - # configure cmake for reflect in dedicated build directory. - run: cmake -B ${{github.workspace}}/build_reflect -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/reflect - - - name: Build reflect - run: cmake --build ${{github.workspace}}/build_reflect --config ${{env.BUILD_TYPE}} - - - name: Install reflect - # install into ${{github.workspace}}/local - run: cmake --install ${{github.workspace}}/build_reflect - - # ---------------------------------------------------------------- - - - name: Clone printjson - uses: actions/checkout@v3 - with: - repository: Rconybea/xo-printjson - path: repo/printjson - - - name: Configure printjson - # configure cmake for printjson in dedicated build directory. - run: cmake -B ${{github.workspace}}/build_printjson -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/printjson - - - name: Build printjson - run: cmake --build ${{github.workspace}}/build_printjson --config ${{env.BUILD_TYPE}} - - - name: Install printjson - # install into ${{github.workspace}}/local - run: cmake --install ${{github.workspace}}/build_printjson - - # ---------------------------------------------------------------- - - - name: Clone pyutil - uses: actions/checkout@v3 - with: - repository: Rconybea/xo-pyutil - path: repo/pyutil - - - name: Configure pyutil - # configure cmake for pyutil in dedicated build directory. - run: cmake -B ${{github.workspace}}/build_pyutil -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/pyutil - - - name: Build pyutil - run: cmake --build ${{github.workspace}}/build_pyutil --config ${{env.BUILD_TYPE}} - - - name: Install pyutil - # install into ${{github.workspace}}/local - run: cmake --install ${{github.workspace}}/build_pyutil - - # ---------------------------------------------------------------- - - - name: Clone pyreflect - uses: actions/checkout@v3 - with: - repository: Rconybea/xo-pyreflect - path: repo/pyreflect - - - name: Configure pyreflect - # configure cmake for pyreflect in dedicated build directory. - run: cmake -B ${{github.workspace}}/build_pyreflect -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/pyreflect - - - name: Build pyreflect - run: cmake --build ${{github.workspace}}/build_pyreflect --config ${{env.BUILD_TYPE}} - - - name: Install pyreflect - # install into ${{github.workspace}}/local - run: cmake --install ${{github.workspace}}/build_pyreflect - - # ---------------------------------------------------------------- - - - name: Configure self (pyprintjson) - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build_pyprintjson -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - - - name: Build self (pyprintjson) - # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build_pyprintjson --config ${{env.BUILD_TYPE}} - - - name: Test self (pyprintjson) - working-directory: ${{github.workspace}}/build_pyprintjson - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C ${{env.BUILD_TYPE}} diff --git a/xo-pyrprintjson/.gitignore b/xo-pyrprintjson/.gitignore deleted file mode 100644 index 13c0afb7..00000000 --- a/xo-pyrprintjson/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# clangd working space (see emacs+lsp) -.cache -# typical cmake build directory (source-tree-nephew) -.build* -# symlink to builddir/compile_commands.json; should be set manually in dev sandbox -compile_commands.json diff --git a/xo-pyrprintjson/CMakeLists.txt b/xo-pyrprintjson/CMakeLists.txt deleted file mode 100644 index dd29fbc9..00000000 --- a/xo-pyrprintjson/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# xo-pyprintjson/CMakeLists.txt - -cmake_minimum_required(VERSION 3.10) - -project(xo_pyprintjson VERSION 1.0) - -include(GNUInstallDirs) -include(cmake/xo-bootstrap-macros.cmake) - -xo_cxx_toplevel_options3() - -# ---------------------------------------------------------------- -# c++ settings (usually temporary) - -set(PROJECT_CXX_FLAGS "") -add_definitions(${PROJECT_CXX_FLAGS}) - -# ---------------------------------------------------------------- -# sources - -add_subdirectory(src/pyprintjson) -#add_subdirectory(utest) - -# ---------------------------------------------------------------- -# provide find_package() support - -xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) - -# end CMakeLists.txt diff --git a/xo-pyrprintjson/README.md b/xo-pyrprintjson/README.md deleted file mode 100644 index e85bc227..00000000 --- a/xo-pyrprintjson/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# python bindings for c++ printjson library (xo-printjson) - -## Getting Started - -### build + install dependencies - -- [github/Rconybea/xo-pyutil](https://github.com/Rconybea/xo-pyutil) -- [github/Rconybea/xo-printjson](https://github.com/Rconybea/xo-printjson) - -### build + install - -``` -$ cd xo-pyprintjson -$ mkdir build -$ cd build -$ INSTALL_PREFIX=/usr/local # or wherever you prefer, e.g. ~/local -$ cmake \ - -DCMAKE_MODULE_PATH=${INSTALL_PREFIX}/share/cmake \ - -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} \ - -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} .. -$ make -$ make install -``` -(also see .github/workflows/main.yml) - -## Examples - -``` -PYTHONPATH=~/local2/lib:$PYTHONPATH python ->>> import xo_pyprintjson ->>> dir(xo_pyprintjson) -['PrintJson', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__'] ->>> dir(xo_pyprintjson.PrintJson) -['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'instance', 'print'] ->>> -``` - -## Development - -### build for unit test coverage -``` -$ cd xo-pyprintjson -$ mkdir build-ccov -$ cd build-ccov -$ cmake \ - -DCMAKE_MODULE_PATH=${INSTALL_PREFIX}/share/cmake \ - -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} \ - -DCODE_COVERAGE=ON \ - -DCMAKE_BUILD_TYPE=Debug .. -``` - -### 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. - -``` -$ cd xo-pyprintjson -$ ln -s build/compile_commands.json # supply compile commands to LSP -``` - -### display cmake variables - -- `-L` list variables -- `-A` include 'advanced' variables -- `-H` include help text - -``` -$ cd xo-pyprintjson/build -$ cmake -LAH -``` diff --git a/xo-pyrprintjson/cmake/xo-bootstrap-macros.cmake b/xo-pyrprintjson/cmake/xo-bootstrap-macros.cmake deleted file mode 100644 index aba31169..00000000 --- a/xo-pyrprintjson/cmake/xo-bootstrap-macros.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# ---------------------------------------------------------------- -# for example: -# $ PREFIX=/usr/local # for example -# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=$PREFIX -B .build -# -# will get -# CMAKE_MODULE_PATH -# from xo-cmake-config --cmake-module-path -# -# and expect .cmake macros in -# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake -# ---------------------------------------------------------------- - -find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED) - -if ("${XO_CMAKE_CONFIG_EXECUTABLE}" STREQUAL "XO_CMAKE_CONFIG_EXECUTABLE-NOT_FOUND") - message(FATAL "could not find xo-cmake-config executable") -endif() - -message(STATUS "XO_CMAKE_CONFIG_EXECUTABLE=${XO_CMAKE_CONFIG_EXECUTABLE}") - -if (NOT XO_SUBMODULE_BUILD) - if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) - # default to typical install location for xo-project-macros - execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) - message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") - endif() -endif() - -# 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_cxx) - -xo_cxx_bootstrap_message() diff --git a/xo-pyrprintjson/cmake/xo_pyprintjsonConfig.cmake.in b/xo-pyrprintjson/cmake/xo_pyprintjsonConfig.cmake.in deleted file mode 100644 index eb9a3b16..00000000 --- a/xo-pyrprintjson/cmake/xo_pyprintjsonConfig.cmake.in +++ /dev/null @@ -1,5 +0,0 @@ -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Share.cmake") -check_required_components("@PROJECT_NAME@") diff --git a/xo-pyrprintjson/include/README.md b/xo-pyrprintjson/include/README.md deleted file mode 100644 index 5d2b4c67..00000000 --- a/xo-pyrprintjson/include/README.md +++ /dev/null @@ -1 +0,0 @@ -placeholder for future pyprintjson #include files diff --git a/xo-pyrprintjson/src/pyprintjson/CMakeLists.txt b/xo-pyrprintjson/src/pyprintjson/CMakeLists.txt deleted file mode 100644 index defff223..00000000 --- a/xo-pyrprintjson/src/pyprintjson/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# xo_pyprintjson/src/pyprintjson/CMakeLists.txt - -set(SELF_LIB xo_pyprintjson) -set(SELF_SRCS pyprintjson.cpp) - -# ---------------------------------------------------------------- - -xo_pybind11_library(${SELF_LIB} ${PROJECT_NAME}Targets ${SELF_SRCS}) -xo_pybind11_dependency(${SELF_LIB} printjson) -xo_pybind11_header_dependency(${SELF_LIB} xo_pyreflect) diff --git a/xo-pyrprintjson/src/pyprintjson/EXAMPLES b/xo-pyrprintjson/src/pyprintjson/EXAMPLES deleted file mode 100644 index 5965b9b6..00000000 --- a/xo-pyrprintjson/src/pyprintjson/EXAMPLES +++ /dev/null @@ -1,2 +0,0 @@ -import pyprintjson -pj=pyprintjson.PrintJson() diff --git a/xo-pyrprintjson/src/pyprintjson/pyprintjson.cpp b/xo-pyrprintjson/src/pyprintjson/pyprintjson.cpp deleted file mode 100644 index 1e107f31..00000000 --- a/xo-pyrprintjson/src/pyprintjson/pyprintjson.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* @file pyprintjson.cpp */ - -// note: need pyreflect/ here bc pyreflect.hpp is generated, located in build directory -#include "pyprintjson.hpp" -#include "xo/pyreflect/pyreflect.hpp" - -#include "xo/printjson/PrintJson.hpp" -#include "xo/reflect/TaggedRcptr.hpp" -//#include "reflect/SelfTagging.hpp" -//#include "refcnt/Refcounted.hpp" -//#include "refcnt/Unowned.hpp" -#include "xo/pyutil/pyutil.hpp" -//#include -//#include -//#include -//#include - -namespace xo { - namespace py = pybind11; - - namespace json { - using xo::reflect::SelfTagging; - using xo::reflect::TaggedRcptr; - using xo::ref::unowned_ptr; - - PYBIND11_MODULE(PYPRINTJSON_MODULE_NAME(), m) { - PYREFLECT_IMPORT_MODULE(); - - py::class_>(m, "PrintJson") - .def_static("instance", &PrintJsonSingleton::instance) - .def("print", - [](PrintJson & pj, TaggedRcptr p) - { - pj.print_tp(p, &std::cout); std::cout << "\n"; - }, - py::arg("value")) - .def("print", - [](PrintJson & pj, rp const & p) - { - pj.print_obj(p, &std::cout); std::cout << "\n"; - }, - py::arg("value")); - - //m.def("print_json", [](){ return PrintJsonSingleton::instance_ptr(); }); - } /*pyprintjson*/ - } /*namespace json*/ -} /*namespace xo*/ - -/* end pyprintjson.cpp */ diff --git a/xo-pyrprintjson/src/pyprintjson/pyprintjson.hpp.in b/xo-pyrprintjson/src/pyprintjson/pyprintjson.hpp.in deleted file mode 100644 index d80e5aba..00000000 --- a/xo-pyrprintjson/src/pyprintjson/pyprintjson.hpp.in +++ /dev/null @@ -1,25 +0,0 @@ -/* @file pyprintjson.hpp - * - * automatically generated from src/pyprintjson/pyprintjson.hpp.in - * see src/pyprintjson/CMakeLists.txt - */ - -/* python requires module name = library name - * example: - * PYBIND11_MODULE(PYPRINTJSON_MODULE_NAME(), m) { ... } - */ -#define PYPRINTJSON_MODULE_NAME() @SELF_LIB@ - -/* example: - * py::module_::import(PYPRINTJSON_MODULE_NAME_STR) - */ -#define PYPRINTJSON_MODULE_NAME_STR "@SELF_LIB@" - -/* example: - * PYPRINTJSON_IMPORT_MODULE() - * replaces - * py::module_::import("pyprintjson") - */ -#define PYPRINTJSON_IMPORT_MODULE() py::module_::import("@SELF_LIB@") - -/* end pyprintjson.hpp */ diff --git a/xo-reader2/src/reader2/CMakeLists.txt b/xo-reader2/src/reader2/CMakeLists.txt index c2ba12e9..55aba46f 100644 --- a/xo-reader2/src/reader2/CMakeLists.txt +++ b/xo-reader2/src/reader2/CMakeLists.txt @@ -112,7 +112,4 @@ xo_dependency(${SELF_LIB} xo_gc) xo_dependency(${SELF_LIB} xo_type) xo_dependency(${SELF_LIB} xo_tokenizer2) xo_dependency(${SELF_LIB} xo_expression2) -#xo_dependency(${SELF_LIB} reflect) -#xo_dependency(${SELF_LIB} xo_flatstring) xo_dependency(${SELF_LIB} subsys) -#xo_dependency(${SELF_LIB} indentlog) diff --git a/xo.nix b/xo.nix index 454e4081..25dc826b 100644 --- a/xo.nix +++ b/xo.nix @@ -48,6 +48,7 @@ let xo-numeric = callPackage pkgs/xo-numeric.nix { stdenv = jitStdenv; }; xo-tokenizer2 = callPackage pkgs/xo-tokenizer2.nix { stdenv = jitStdenv; buildExamples = true; }; xo-expression2 = callPackage pkgs/xo-expression2.nix { stdenv = jitStdenv; }; + xo-reader2 = callPackage pkgs/xo-reader2.nix { stdenv = jitStdenv; }; xo-allocutil = callPackage pkgs/xo-allocutil.nix { stdenv = jitStdenv; }; xo-alloc = callPackage pkgs/xo-alloc.nix { stdenv = jitStdenv; buildDocs = true; }; xo-ratio = callPackage pkgs/xo-ratio.nix { stdenv = jitStdenv; buildDocs = true; buildExamples = true; };