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
64 changes: 63 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,64 @@ jobs:
run: |
docker run --rm liblpm-go:ci

# Perl bindings test
test-perl-bindings:
name: Test Perl Bindings
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Perl container
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.perl
push: false
load: true
tags: liblpm-perl:ci
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run Perl tests
run: |
docker run --rm liblpm-perl:ci

# PHP bindings test
test-php-bindings:
name: Test PHP Bindings
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build PHP container
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.php
push: false
load: true
tags: liblpm-php:ci
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run PHP tests
run: |
docker run --rm liblpm-php:ci

# Python bindings test
test-python-bindings:
name: Test Python Bindings
Expand Down Expand Up @@ -223,7 +281,7 @@ jobs:
ci-summary:
name: CI Summary
runs-on: ubuntu-latest
needs: [build-and-test, test-cpp-bindings, test-go-bindings, test-python-bindings, code-quality]
needs: [build-and-test, test-cpp-bindings, test-go-bindings, test-perl-bindings, test-php-bindings, test-python-bindings, code-quality]
if: always()

steps:
Expand All @@ -233,13 +291,17 @@ jobs:
echo "Build and test: ${{ needs.build-and-test.result }}"
echo "C++ bindings: ${{ needs.test-cpp-bindings.result }}"
echo "Go bindings: ${{ needs.test-go-bindings.result }}"
echo "Perl bindings: ${{ needs.test-perl-bindings.result }}"
echo "PHP bindings: ${{ needs.test-php-bindings.result }}"
echo "Python bindings: ${{ needs.test-python-bindings.result }}"
echo "Code quality: ${{ needs.code-quality.result }}"

# Fail if any required job failed
if [[ "${{ needs.build-and-test.result }}" == "failure" ]] || \
[[ "${{ needs.test-cpp-bindings.result }}" == "failure" ]] || \
[[ "${{ needs.test-go-bindings.result }}" == "failure" ]] || \
[[ "${{ needs.test-perl-bindings.result }}" == "failure" ]] || \
[[ "${{ needs.test-php-bindings.result }}" == "failure" ]] || \
[[ "${{ needs.test-python-bindings.result }}" == "failure" ]]; then
echo "One or more required jobs failed"
exit 1
Expand Down
99 changes: 99 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ option(WITH_DPDK_BENCHMARK "Build DPDK comparison benchmark" OFF)
option(WITH_EXTERNAL_LPM_BENCHMARK "Build benchmarks with external LPM libraries" OFF)
option(BUILD_GO_WRAPPER "Build Go wrapper and bindings" OFF)
option(BUILD_CPP_WRAPPER "Build C++ wrapper and bindings" OFF)
option(BUILD_PERL_WRAPPER "Build Perl wrapper and bindings" OFF)
option(BUILD_PHP_WRAPPER "Build PHP wrapper and bindings" OFF)
option(BUILD_PYTHON_WRAPPER "Build Python wrapper and bindings" OFF)
option(LPM_TS_RESOLVERS "Enable thread-safe resolvers (for dlopen contexts)" OFF)

Expand Down Expand Up @@ -418,6 +420,93 @@ if(BUILD_GO_WRAPPER)
endif()
endif()

# Perl wrapper
if(BUILD_PERL_WRAPPER)
find_program(PERL_EXECUTABLE perl)
if(PERL_EXECUTABLE)
message(STATUS "Found Perl: ${PERL_EXECUTABLE}")

# Custom target to configure Perl wrapper
add_custom_target(perl_configure
COMMAND ${PERL_EXECUTABLE} Makefile.PL
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/perl
DEPENDS lpm
COMMENT "Configuring Perl wrapper"
)

# Custom target to build Perl wrapper
add_custom_target(perl_wrapper ALL
COMMAND make
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/perl
DEPENDS perl_configure
COMMENT "Building Perl wrapper and bindings"
)

# Custom target to test Perl wrapper
add_custom_target(perl_test
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}:$ENV{LD_LIBRARY_PATH}" make test
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/perl
DEPENDS perl_wrapper
COMMENT "Testing Perl wrapper"
)

message(STATUS "Perl wrapper targets added:")
message(STATUS " make perl_wrapper - Build Perl wrapper")
message(STATUS " make perl_test - Run Perl tests")
else()
message(WARNING "Perl not found. Perl wrapper will not be built.")
message(WARNING "Install Perl to build the wrapper: sudo apt install perl")
endif()
endif()

# PHP wrapper
if(BUILD_PHP_WRAPPER)
find_program(PHP_EXECUTABLE php)
find_program(PHPIZE_EXECUTABLE phpize)
if(PHP_EXECUTABLE AND PHPIZE_EXECUTABLE)
message(STATUS "Found PHP: ${PHP_EXECUTABLE}")
message(STATUS "Found phpize: ${PHPIZE_EXECUTABLE}")

# Custom target to configure PHP extension
add_custom_target(php_configure
COMMAND ${PHPIZE_EXECUTABLE}
COMMAND ./configure --with-liblpm=${CMAKE_INSTALL_PREFIX}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/php
DEPENDS lpm
COMMENT "Configuring PHP extension"
)

# Custom target to build PHP extension
add_custom_target(php_wrapper ALL
COMMAND make
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/php
DEPENDS php_configure
COMMENT "Building PHP extension and bindings"
)

# Custom target to test PHP extension
add_custom_target(php_test
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}:$ENV{LD_LIBRARY_PATH}" make test
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/php
DEPENDS php_wrapper
COMMENT "Testing PHP extension"
)

message(STATUS "PHP wrapper targets added:")
message(STATUS " make php_wrapper - Build PHP extension")
message(STATUS " make php_test - Run PHP tests")
else()
if(NOT PHP_EXECUTABLE)
message(WARNING "PHP not found. PHP extension will not be built.")
message(WARNING "Install PHP to build the extension: sudo apt install php php-dev")
endif()
if(NOT PHPIZE_EXECUTABLE)
message(WARNING "phpize not found. PHP extension will not be built.")
message(WARNING "Install PHP development tools: sudo apt install php-dev")
endif()
endif()
endif()

# Print configuration summary
message(STATUS "liblpm configuration:")
message(STATUS " Version: ${PROJECT_VERSION}")
Expand Down Expand Up @@ -463,6 +552,16 @@ if(BUILD_CPP_WRAPPER)
else()
message(STATUS " Build C++ wrapper: OFF")
endif()
if(BUILD_PERL_WRAPPER AND PERL_EXECUTABLE)
message(STATUS " Build Perl wrapper: ON")
else()
message(STATUS " Build Perl wrapper: OFF")
endif()
if(BUILD_PHP_WRAPPER AND PHP_EXECUTABLE AND PHPIZE_EXECUTABLE)
message(STATUS " Build PHP wrapper: ON")
else()
message(STATUS " Build PHP wrapper: OFF")
endif()
if(BUILD_PYTHON_WRAPPER AND Python_FOUND AND CYTHON_EXECUTABLE)
message(STATUS " Build Python wrapper: ON")
else()
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ docker run --rm --cpus=4 liblpm-fuzz
- **liblpm-fuzz**: AFL++ fuzzing for security testing
- **liblpm-cpp**: C++ bindings development and testing
- **liblpm-go**: Go bindings development and testing
- **liblpm-perl**: Perl XS bindings development and testing
- **liblpm-php**: PHP bindings development and testing
- **liblpm-python**: Python bindings development and testing
- **liblpm-benchmark**: DPDK rte_lpm performance comparison

For complete documentation, see [docs/DOCKER.md](docs/DOCKER.md).
Expand Down Expand Up @@ -273,6 +276,9 @@ man lpm_algorithms # Algorithm-specific APIs
- [Byte Order and Data Format](docs/BYTE_ORDER.md) - Endianness, IP address storage, and integration guide
- [C++ API Reference](bindings/cpp/README.md) - C++ wrapper documentation
- [Go API Reference](bindings/go/README.md) - Go bindings documentation
- [Perl API Reference](bindings/perl/README.md) - Perl XS bindings documentation
- [PHP API Reference](bindings/php/README.md) - PHP extension documentation
- [Python API Reference](bindings/python/README.md) - Python bindings documentation

## Security

Expand Down
Empty file added bindings/perl/LPM.bs
Empty file.
Loading
Loading