diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 714c9d2f..e17eae83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,8 @@ jobs: fail-fast: false matrix: os: - - ubuntu-latest + - ubuntu-20.04 + - macos-11 php-version: - "7.0" - "7.1" @@ -47,6 +48,7 @@ jobs: uses: actions/checkout@v2 - name: Install libclang + if: matrix.os == 'ubuntu-20.04' run: sudo apt-get install -y llvm-10-dev libclang-10-dev - name: Setup PHP @@ -55,16 +57,22 @@ jobs: php-version: ${{ matrix.php-version }} tools: php-config - - name: Setup php-fpm + - name: Setup php-fpm for Linux + if: matrix.os == 'ubuntu-20.04' run: | sudo apt-get install -y php${{ matrix.php-version }}-fpm sudo rm -f /usr/sbin/php-fpm sudo ln -s /usr/sbin/php-fpm${{ matrix.php-version }} /usr/sbin/php-fpm + - name: Setup php-fpm for Macos + if: matrix.os == 'macos-11' + run: | + brew install php@${{ matrix.php-version }} + - name: PHP version run: | php-config || true - /usr/sbin/php-fpm --version + php-fpm --version - name: Install Rust Nightly uses: actions-rs/toolchain@v1 @@ -87,18 +95,18 @@ jobs: command: fmt args: --all -- --check - - name: Cargo build + - name: Cargo clippy uses: actions-rs/cargo@v1 with: toolchain: stable - command: build + command: clippy args: --release - - name: Cargo clippy + - name: Cargo build uses: actions-rs/cargo@v1 with: toolchain: stable - command: clippy + command: build args: --release - name: Cargo test @@ -124,7 +132,7 @@ jobs: fail-fast: false matrix: os: - - ubuntu-latest + - ubuntu-20.04 php-version: - "7.4" features: diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index c1db07d0..8676d60f 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -20,7 +20,7 @@ on: jobs: license-check: name: License check - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 241a64a6..0eaa542c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,7 +26,7 @@ jobs: publish: name: Publish - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout uses: actions/checkout@v2 diff --git a/README.md b/README.md index 9651dd67..5c8c866b 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ The framework that allows us to write PHP extensions using pure and safe Rust wh - **OS** - [x] linux - - [ ] macos + - [x] macos - [ ] windows - **PHP** - **version** diff --git a/examples/hello/build.rs b/examples/hello/build.rs index 190ba756..0c111d7a 100644 --- a/examples/hello/build.rs +++ b/examples/hello/build.rs @@ -10,4 +10,10 @@ fn main() { phper_build::register_configures(); + + #[cfg(target_os = "macos")] + { + println!("cargo:rustc-link-arg=-undefined"); + println!("cargo:rustc-link-arg=dynamic_lookup"); + } } diff --git a/examples/http-client/build.rs b/examples/http-client/build.rs new file mode 100644 index 00000000..682a4a6b --- /dev/null +++ b/examples/http-client/build.rs @@ -0,0 +1,17 @@ +// Copyright (c) 2022 PHPER Framework Team +// PHPER is licensed under Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan +// PSL v2. You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +// See the Mulan PSL v2 for more details. + +fn main() { + #[cfg(target_os = "macos")] + { + println!("cargo:rustc-link-arg=-undefined"); + println!("cargo:rustc-link-arg=dynamic_lookup"); + } +} diff --git a/examples/http-server/build.rs b/examples/http-server/build.rs new file mode 100644 index 00000000..682a4a6b --- /dev/null +++ b/examples/http-server/build.rs @@ -0,0 +1,17 @@ +// Copyright (c) 2022 PHPER Framework Team +// PHPER is licensed under Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan +// PSL v2. You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +// See the Mulan PSL v2 for more details. + +fn main() { + #[cfg(target_os = "macos")] + { + println!("cargo:rustc-link-arg=-undefined"); + println!("cargo:rustc-link-arg=dynamic_lookup"); + } +} diff --git a/examples/logging/build.rs b/examples/logging/build.rs new file mode 100644 index 00000000..682a4a6b --- /dev/null +++ b/examples/logging/build.rs @@ -0,0 +1,17 @@ +// Copyright (c) 2022 PHPER Framework Team +// PHPER is licensed under Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan +// PSL v2. You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +// See the Mulan PSL v2 for more details. + +fn main() { + #[cfg(target_os = "macos")] + { + println!("cargo:rustc-link-arg=-undefined"); + println!("cargo:rustc-link-arg=dynamic_lookup"); + } +} diff --git a/phper-sys/build.rs b/phper-sys/build.rs index eaea8223..8f5e9fe8 100644 --- a/phper-sys/build.rs +++ b/phper-sys/build.rs @@ -189,6 +189,7 @@ fn main() { .blocklist_function("__hypotl") .blocklist_function("__ilogbf64x") .blocklist_function("__ilogbl") + .blocklist_function("__infl") .blocklist_function("__iscanonicall") .blocklist_function("__iseqsigl") .blocklist_function("__iseqsigl") diff --git a/phper-sys/php_wrapper.c b/phper-sys/php_wrapper.c index 81b3fce6..1a1b0042 100644 --- a/phper-sys/php_wrapper.c +++ b/phper-sys/php_wrapper.c @@ -183,7 +183,7 @@ bool phper_object_init_ex(zval *arg, zend_class_entry *class_type) { } bool phper_call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[]) { - function_table = function_table; + (void)function_table; // suppress "unused parameter" warnings. return call_user_function(function_table, object, function_name, retval_ptr, param_count, params) == SUCCESS; } diff --git a/phper/build.rs b/phper/build.rs index 78e1c7a6..2975236d 100644 --- a/phper/build.rs +++ b/phper/build.rs @@ -15,8 +15,8 @@ fn main() { #[cfg(target_os = "macos")] { - println!("cargo:rustc-cdylib-link-arg=-undefined"); - println!("cargo:rustc-cdylib-link-arg=dynamic_lookup"); + println!("cargo:rustc-link-arg=-undefined"); + println!("cargo:rustc-link-arg=dynamic_lookup"); } assert_eq!( diff --git a/tests/integration/build.rs b/tests/integration/build.rs new file mode 100644 index 00000000..682a4a6b --- /dev/null +++ b/tests/integration/build.rs @@ -0,0 +1,17 @@ +// Copyright (c) 2022 PHPER Framework Team +// PHPER is licensed under Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan +// PSL v2. You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +// See the Mulan PSL v2 for more details. + +fn main() { + #[cfg(target_os = "macos")] + { + println!("cargo:rustc-link-arg=-undefined"); + println!("cargo:rustc-link-arg=dynamic_lookup"); + } +}