phper_build/
lib.rs

1// Copyright (c) 2022 PHPER Framework Team
2// PHPER is licensed under Mulan PSL v2.
3// You can use this software according to the terms and conditions of the Mulan
4// PSL v2. You may obtain a copy of Mulan PSL v2 at:
5//          http://license.coscl.org.cn/MulanPSL2
6// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
7// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
8// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9// See the Mulan PSL v2 for more details.
10
11#![warn(rust_2018_idioms, missing_docs)]
12#![warn(clippy::dbg_macro)]
13#![doc = include_str!("../README.md")]
14
15use phper_sys::*;
16
17/// Register all php build relative configure parameters, used in `build.rs`.
18pub fn register_all() {
19    register_link_args();
20    register_configures();
21}
22
23/// Register useful rust cfg for project using phper.
24pub fn register_configures() {
25    // versions
26    println!(
27        "cargo::rustc-cfg=phper_major_version=\"{}\"",
28        PHP_MAJOR_VERSION
29    );
30    println!(
31        "cargo::rustc-cfg=phper_minor_version=\"{}\"",
32        PHP_MINOR_VERSION
33    );
34    println!(
35        "cargo::rustc-cfg=phper_release_version=\"{}\"",
36        PHP_RELEASE_VERSION
37    );
38
39    if PHP_DEBUG != 0 {
40        println!("cargo::rustc-cfg=phper_debug");
41    }
42
43    if USING_ZTS != 0 {
44        println!("cargo::rustc-cfg=phper_zts");
45    }
46
47    if PHP_VERSION_ID >= 80100 {
48        println!("cargo::rustc-cfg=phper_enum_supported");
49    }
50}
51
52/// Register link arguments for os-specified situation.
53pub fn register_link_args() {
54    #[cfg(target_os = "macos")]
55    {
56        println!("cargo::rustc-link-arg=-undefined");
57        println!("cargo::rustc-link-arg=dynamic_lookup");
58    }
59}