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#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/112468984?s=200&v=4")]
15
16use phper_sys::*;
17
18/// Register all php build relative configure parameters, used in `build.rs`.
19pub fn register_all() {
20    register_link_args();
21    register_configures();
22}
23
24/// Register useful rust cfg for project using phper.
25pub fn register_configures() {
26    // versions
27    println!(
28        "cargo::rustc-cfg=phper_major_version=\"{}\"",
29        PHP_MAJOR_VERSION
30    );
31    println!(
32        "cargo::rustc-cfg=phper_minor_version=\"{}\"",
33        PHP_MINOR_VERSION
34    );
35    println!(
36        "cargo::rustc-cfg=phper_release_version=\"{}\"",
37        PHP_RELEASE_VERSION
38    );
39
40    if PHP_DEBUG != 0 {
41        println!("cargo::rustc-cfg=phper_debug");
42    }
43
44    if USING_ZTS != 0 {
45        println!("cargo::rustc-cfg=phper_zts");
46    }
47
48    if PHP_VERSION_ID >= 80100 {
49        println!("cargo::rustc-cfg=phper_enum_supported");
50    }
51}
52
53/// Register link arguments for os-specified situation.
54pub fn register_link_args() {
55    #[cfg(target_os = "macos")]
56    {
57        println!("cargo::rustc-link-arg=-undefined");
58        println!("cargo::rustc-link-arg=dynamic_lookup");
59    }
60}