Skip to content

Commit

Permalink
feat: use pkg-config to find Wasmer libs
Browse files Browse the repository at this point in the history
  • Loading branch information
jubianchi committed Feb 8, 2021
1 parent 701897b commit 8c204b0
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 1,294 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
- name: Install Wasmer
run: |
curl https://get.wasmer.io -sSfL | sh
sudo mkdir -p /usr/local/lib/pkgconfig
wasmer config --pkg-config | sudo tee /usr/local/lib/pkgconfig/wasmer.pc
- name: Checkout code
uses: actions/checkout@v2
- name: Configure
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Install Wasmer
run: |
curl https://get.wasmer.io -sSfL | sh
sudo mkdir -p /usr/local/lib/pkgconfig
wasmer config --pkg-config | sudo tee /usr/local/lib/pkgconfig/wasmer.pc
- name: Checkout code
uses: actions/checkout@v2
- name: Configure
Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ execute_process (
)
string(REGEX REPLACE "\n$" "" PHP_SOURCE "${PHP_SOURCE}")

message("Using source directory: ${PHP_SOURCE}")
execute_process (
COMMAND wasmer config --includedir
OUTPUT_VARIABLE WASMER_SOURCE
)
string(REGEX REPLACE "\n$" "" WASMER_SOURCE "${WASMER_SOURCE}")

message("Using PHP include directory: ${PHP_SOURCE}")
message("Using Wasmer include directory: ${WASMER_SOURCE}")

include_directories(${PHP_SOURCE})
include_directories(${PHP_SOURCE}/main)
include_directories(${PHP_SOURCE}/Zend)
include_directories(${PHP_SOURCE}/TSRM)
include_directories(${WASMER_SOURCE})
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/include)

Expand Down
10 changes: 6 additions & 4 deletions config.m4
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
dnl config.m4 for extension Wasmer

PHP_ARG_ENABLE(wasmer, whether to enable Wasmer support,
AS_HELP_STRING(--enable-wasmer, Enable Wasmer support))
PHP_ARG_WITH(wasmer, for Wasmer support,
AS_HELP_STRING(--with-wasmer, Include Wasmer support))

if test "$PHP_WASMER" != "no"; then
AC_DEFINE(HAVE_WASMER, 1, [ Have Wasmer support ])
PKG_CHECK_MODULES([LIBWASMER], [wasmer >= 1.0.2])
PKG_CHECK_MODULES([LIBWASMER], [wasmer < 2.0.0])
PHP_EVAL_INCLINE($LIBWASMER_CFLAGS)
PHP_EVAL_LIBLINE($LIBWASMER_LIBS, WASMER_SHARED_LIBADD)

PHP_SUBST(WASMER_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(wasmer, ./lib, WASMER_SHARED_LIBADD)

WASMER_API="src/api/config.c src/api/engine.c src/api/store.c src/api/wasmer.c src/api/wat.c"
WASMER_API_OBJECTS="src/api/objects/extern.c src/api/objects/foreign.c src/api/objects/func.c src/api/objects/frame.c src/api/objects/global.c src/api/objects/instance.c src/api/objects/memory.c src/api/objects/module.c src/api/objects/table.c src/api/objects/trap.c src/api/objects/val.c"
Expand Down
Loading

0 comments on commit 8c204b0

Please sign in to comment.