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
21 changes: 21 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
- A bug in some LLM coding environments makes Bazel difficult to use, so agents should rely on CMake.
- Keep both the CMake and Bazel builds working at all times.

## Building with CMake

When building with CMake, use parallel flags to speed up the process.

- When using `cmake --build`, add the `--parallel` flag.
- When using `make`, add the `-j` flag (e.g., `make -j$(nproc)`).

## Running Tests with CMake

To run the tests, execute the following commands from the root of the repository:

```bash
mkdir -p build
cd build
cmake ..
cmake --build . --parallel
ctest
```



## Building the Python Wheel

To build the Python wheel for `tesseract_decoder` locally, you will need to use the `bazel build` command and provide the version and Python target version as command-line arguments. This is because the `py_wheel` rule in the `BUILD` file uses "Make" variable substitution, which expects these values to be defined at build time.
Expand Down
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ FetchContent_Declare(
set(PYBIND11_TEST OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(pybind11)

# Google Test
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
FetchContent_MakeAvailable(googletest)


set(OPT_COPTS -Ofast -fno-fast-math -march=native)

set(TESSERACT_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
Expand Down Expand Up @@ -111,3 +120,14 @@ set_target_properties(tesseract_decoder PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${PROJECT_SOURCE_DIR}/src
)

# === Tests ===
enable_testing()

add_executable(common_test ${TESSERACT_SRC_DIR}/common.test.cc)
target_link_libraries(common_test PRIVATE common GTest::gtest_main)
add_test(NAME common_test COMMAND common_test)

add_executable(tesseract_test ${TESSERACT_SRC_DIR}/tesseract.test.cc)
target_link_libraries(tesseract_test PRIVATE tesseract_lib simplex GTest::gtest_main)
add_test(NAME tesseract_test COMMAND tesseract_test)

2 changes: 0 additions & 2 deletions src/tesseract.pybind.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ void add_tesseract_module(py::module& root) {
`TesseractConfig` object.
)pbdoc");



py::class_<TesseractDecoder>(m, "TesseractDecoder", R"pbdoc(
A class that implements the Tesseract decoding algorithm.

Expand Down
Loading