crazywhalecc / static-php-cli

Build standalone PHP binary on Linux, macOS, FreeBSD, Windows, with PHP project together, with popular extensions included.
https://static-php.dev
MIT License
1.34k stars 234 forks source link

feat: A proper way to use environment variables #382

Closed crazywhalecc closed 7 months ago

crazywhalecc commented 8 months ago

According to the descriptions of #377 and #379, spc now needs to add a series of customizable environment variables to implement custom compilation parameters.

Demand is expected to be as follows:

  1. Customize the environment variables for compiling PHP commands, such as CFLAGS, LDFLAGS, etc.
  2. Customize the environment variables of various libraries, such as ZLIB_CFLAGS, etc.
  3. Customize various compilation commands (if necessary, of course, there is a high probability that it may not be considered)

Possible problems expected in response to demand are as follows:

  1. If you directly use global default variable names such as CFLAGS, consider the interference of the default environment on spc's default CFLAGS.
  2. The prefix of the library name needs to be carefully considered according to the rules, or a table of variable names needs to be maintained in the docs.
  3. It is necessary to intervene in shell()->exec(), or completely use configuration form instead of PHP code function build().

Another biggest problem is different libs use different build tools (cmake, configure or direct cc make), of course they accepts different vars.

I'm not opposed to a lot of modification, but I don't know where the boundaries of customization are. There are many different libraries that can directly insert the variables they need through export before building, and we should probably create a branch to determine which values need to be replaced through environment variables.