Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"version": "3.31.9"
},
"ghcr.io/msclock/features/vcpkg:2": {
"version": "stable",
"version": "latest",
"vcpkgAutoUpdate": true
}
},
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ testcontainers-c/testcontainers-c.so
testcontainers-c/testcontainers.so
testcontainers-c/testcontainers.dll
testcontainers-c/testcontainers.h
testcontainers-bridge/testcontainers-bridge.h

# VCPKG
**/vcpkg_installed/**


*.so
*.out
*.exe
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 3.26)
project (TESTCONTAINERS-C
project (TESTCONTAINERS-NATIVE
VERSION 0.1.0
DESCRIPTION "Testcontainers for C and other native languages"
LANGUAGES C CXX
Expand Down
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ To skip the demo builds and tests, use the `SKIP_DEMOS` variable:
cmake -DSKIP_DEMOS=true .
```

## Building the VCPKG

To build the VCPkg for the local environment, use the following:

```shell
vcpkg install testcontainers-bridge --overlay-ports=$(pwd)/ports/
vcpkg install testcontainers-c --overlay-ports=$(pwd)/ports/
```

## Contributing to the Documentation

The documentation is structured in the MkDocs format and uses Material for MkDocs.
Expand Down
2 changes: 1 addition & 1 deletion modules/wiremock/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(TARGET testcontainers-c-wiremock)
set(TARGET_NAME ${TARGET})
set(TARGET_DESCRIPTION "Wiremock testcontainer abstractions for C")
set(TARGET_DESCRIPTION "WireMock Testcontainers abstractions for C")
set(TARGET_VERSION ${PROJECT_VERSION})

add_library(${TARGET} SHARED
Expand Down
4 changes: 4 additions & 0 deletions ports/testcontainers-bridge/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testcontainers-bridge provides CMake targets:

find_package(testcontainers-bridge CONFIG REQUIRED)
target_link_libraries(main PRIVATE testcontainers-bridge::testcontainers-bridge)
17 changes: 17 additions & 0 deletions ports/testcontainers-bridge/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "testcontainers-bridge",
"version-string": "0.1.0",
"description": "Testcontainers Go bridge library for native languages",
"homepage": "https://github.com/testcontainers/testcontainers-native",
"license": "MIT",
"dependencies":[
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
27 changes: 27 additions & 0 deletions ports/testcontainers-c/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Build using the port directory as source. We expect this repository to be
# available to the vcpkg build as a submodule or local path. If building from
# a remote registry, replace this with vcpkg_from_github / vcpkg_from_git.

set(ROOT_SRC ${CURRENT_PORT_DIR}/../../testcontainers-c)


# Configure from repository root so that testcontainers-bridge is built first
vcpkg_cmake_configure(
SOURCE_PATH ${ROOT_SRC}
GENERATOR "Unix Makefiles"
OPTIONS
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
)

vcpkg_build_cmake()

# Install from CMake install rules
vcpkg_install_cmake()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

# Add a short README to the package to indicate local build origin
file(WRITE ${CURRENT_PACKAGES_DIR}/debug/share/${PORT}/README "This package was built from local repo source.\n")

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
4 changes: 4 additions & 0 deletions ports/testcontainers-c/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testcontainers-c provides CMake targets:

find_package(testcontainers-c CONFIG REQUIRED)
target_link_libraries(main PRIVATE testcontainers-c::testcontainers-c)
21 changes: 21 additions & 0 deletions ports/testcontainers-c/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "testcontainers-c",
"version-string": "0.1.0",
"description": "Testcontainers library for C - C API and shared library",
"homepage": "https://github.com/testcontainers/testcontainers-native",
"license": "MIT",
"dependencies": [
{
"name": "testcontainers-bridge",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That part does not work in vcpkg runs yet, even if local installation is fine.
Likely, the port files are messed up somehow

"host": true
},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
16 changes: 15 additions & 1 deletion testcontainers-bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
cmake_minimum_required (VERSION 3.26)
project (TESTCONTAINERS-BRIDGE
VERSION 0.1.0
DESCRIPTION "Testcontainers Go library for native languages"
LANGUAGES C
)
include(GNUInstallDirs)

set(SRCS testcontainers-bridge.go)

set(SHIM_TARGET testcontainers-bridge-shim)
Expand All @@ -16,7 +24,7 @@ add_custom_target(${SHIM_TARGET} DEPENDS ${SHIM_TARGET_LIB} ${SHIM_TARGET_HEADER

set(TARGET testcontainers-bridge)
set(TARGET_NAME ${TARGET})
set(TARGET_DESCRIPTION "Go to C bridge for Testcontainers functionality")
set(TARGET_DESCRIPTION "Go to C bridge for Testcontainers Go functionality")
set(TARGET_VERSION ${PROJECT_VERSION})

add_library(${TARGET} STATIC IMPORTED GLOBAL)
Expand All @@ -27,3 +35,9 @@ set_target_properties(${TARGET} PROPERTIES
PUBLIC_HEADER ${SHIM_TARGET_HEADER}
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${SHIM_TARGET_LIB}
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR})

# Install library and header files
configure_file(cmake.pc.in ${TARGET}.pc @ONLY)
install(FILES ${SHIM_TARGET_LIB} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${SHIM_TARGET_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${CMAKE_BINARY_DIR}/${TARGET}.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
12 changes: 12 additions & 0 deletions testcontainers-bridge/cmake.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Name: @TARGET_NAME@
Description: @TARGET_DESCRIPTION@
Version: @TARGET_VERSION@

Requires:
Libs: -L${libdir}
Cflags: -I${includedir}
5 changes: 5 additions & 0 deletions testcontainers-bridge/testcontainers-bridge-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/testcontainers-bridge-targets.cmake")

check_required_components(testcontainers-bridge)
25 changes: 20 additions & 5 deletions testcontainers-c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
cmake_minimum_required (VERSION 3.26)
project (TESTCONTAINERS-C
VERSION 0.1.0
DESCRIPTION "Testcontainers library for C"
LANGUAGES C
)
include(GNUInstallDirs)

set(TARGET testcontainers-c)
set(TARGET_NAME ${TARGET})
set(TARGET_DESCRIPTION "Testcontainer library for C")
set(TARGET_DESCRIPTION "Testcontainers library for C")
set(TARGET_VERSION ${PROJECT_VERSION})

# Try to find testcontainers-bridge via find_package (for vcpkg/installed case)
# If not found, assume it's built in the same project (source build)
find_package(testcontainers-bridge QUIET)
if(NOT testcontainers-bridge_FOUND)
if(NOT TARGET testcontainers-bridge)
message(FATAL_ERROR "testcontainers-bridge not found. Will assume the local presence.")
endif()
endif()

add_library(${TARGET} SHARED
src/container.c
)
Expand All @@ -16,8 +33,6 @@ target_sources(${TARGET}
target_link_libraries(${TARGET} PRIVATE testcontainers-bridge)

configure_file(cmake.pc.in ${TARGET}.pc @ONLY)
install(FILES ${SHIM_TARGET_LIB}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${SHIM_TARGET_HEADER}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${SHIM_TARGET_LIB} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${SHIM_TARGET_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${CMAKE_BINARY_DIR}/${TARGET}.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)