Skip to content

Commit

Permalink
Merge pull request #32 from contentauth/mathern/monorepo-build-fixes
Browse files Browse the repository at this point in the history
bugfix: Fix broken local builds due to previous PR
  • Loading branch information
tmathern authored Nov 19, 2024
2 parents cbb2cfc + 6b3af0c commit 66ba32a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ cmake:
mkdir -p $(BUILD_DIR)
cmake -S./ -B./$(BUILD_DIR) -G "Ninja"

unit-tests: cmake test-rust release
cmake --build ./$(BUILD_DIR) --target unit_tests
cd $(BUILD_DIR); tests/unit_tests

release:
cargo build --release
cbindgen --config cbindgen.toml --crate c2pa-c --output include/c2pa.h --lang c
Expand All @@ -36,9 +32,9 @@ test-c: release
$(CC) $(CFLAGS) tests/test.c -o target/ctest -lc2pa_c -L./target/release
$(ENV) target/ctest

test-cpp: cmake release
cmake --build ./$(BUILD_DIR) --target cpptest
target/cmake/cpptest
unit-tests: release cmake test-rust
cmake --build ./$(BUILD_DIR) --target unit_tests
cd $(BUILD_DIR); tests/unit_tests

demo: cmake release
cmake --build ./$(BUILD_DIR) --target demo
Expand All @@ -59,6 +55,6 @@ package:
cp README.md target/c2pa-c/README.md
cp include/* target/c2pa-c/include

test: check-format clippy test-rust test-c test-cpp
test: check-format clippy test-rust test-c unit-tests

all: unit-tests examples
6 changes: 3 additions & 3 deletions include/c2pa.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ struct CStream *c2pa_create_stream(struct StreamContext *context,
IMPORT extern void c2pa_release_stream(struct CStream *stream);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
} // extern "C"
#endif // __cplusplus

#endif /* c2pa_bindings_h */
#endif /* c2pa_bindings_h */
12 changes: 2 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,9 @@ set(SOURCES c2pa.cpp)
add_library(c2pa_cpp STATIC ${SOURCES})

# Add the Rust library
set(RUST_LIB ${CMAKE_SOURCE_DIR}/../target/release/libc2pa_c.dylib)
set(RUST_LIB_DEST ${CMAKE_SOURCE_DIR}/../target/release/libc2pa_c.dylib)
set(RUST_LIB ${CMAKE_SOURCE_DIR}/target/release/libc2pa_c.dylib)

# Copy the Rust library from the local path to the target/cmake/src directory
# file(COPY ${RUST_LIB_LOCAL_PATH} DESTINATION ${CMAKE_BINARY_DIR}/lib)

# Create a custom target for the Rust library
add_custom_target(build_rust_lib ALL DEPENDS ${RUST_LIB})
add_dependencies(c2pa_cpp build_rust_lib)

target_link_libraries(c2pa_cpp ${RUST_LIB_DEST})
target_link_libraries(c2pa_cpp ${RUST_LIB})

target_include_directories(c2pa_cpp PUBLIC ${INCLUDES})

Expand Down
7 changes: 6 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ add_library(test_signer test_signer.cpp)
# Ensure OpenSSL headers are available
target_include_directories(test_signer PUBLIC ${OPENSSL_INCLUDE_DIR})

# Add the Rust library
set(RUST_LIB ${CMAKE_SOURCE_DIR}/target/release/libc2pa_c.dylib)

# Create the unit test target.
file(GLOB unit_test_files CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/tests/*.test.cpp" "${CMAKE_SOURCE_DIR}/tests/test_signer.cpp")
add_executable(unit_tests ${unit_test_files})
target_include_directories(unit_tests PUBLIC "${CMAKE_SOURCE_DIR}/include/")

target_link_libraries(unit_tests OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(unit_tests nlohmann_json::nlohmann_json)
target_link_libraries(unit_tests ${RUST_C_LIB})
target_link_libraries(unit_tests c2pa_cpp test_signer)
target_link_libraries(unit_tests gtest_main)
target_link_libraries(unit_tests gtest_main)

# Ensure OpenSSL headers are available for unit tests
target_include_directories(unit_tests PUBLIC ${OPENSSL_INCLUDE_DIR})
Expand Down

0 comments on commit 66ba32a

Please sign in to comment.