{{ I18N[lang].downloadUPXCommand }}
@@ -162,6 +186,14 @@ const osList = [
{ os: 'windows', label: 'Windows', disabled: false },
];
+const isSupported = (extName, os) => {
+ // Convert os to target: linux->Linux, macos->Darwin, windows->Windows (using map)
+ const a = new Map([['linux', 'Linux'], ['macos', 'Darwin'], ['windows', 'Windows']]);
+ const osName = a.get(os);
+ const osSupport = ext.value[extName]?.support?.[osName] ?? 'yes';
+ return osSupport === 'yes' || osSupport === 'partial';
+};
+
const availablePhpVersions = [
'7.4',
'8.0',
@@ -201,8 +233,9 @@ const I18N = {
depTips: '选择扩展后,不可选中的项目为必需的依赖,编译的依赖库列表中可选的为现有扩展和依赖库的可选依赖。选择可选依赖后,将生成 --with-libs 参数。',
microUnavailable: 'micro 不支持 PHP 7.4 及更早版本!',
windowsSAPIUnavailable: 'Windows 目前不支持 fpm、embed 构建!',
- useUPX: '是否开启 UPX 压缩(减小二进制体积,但很少见的情况下 micro SAPI 无法使用)',
+ useUPX: '是否开启 UPX 压缩(减小二进制体积)',
windowsDownSPCWarning: 'Windows 下请手动下载 spc.exe 二进制文件并解压到当前目录!',
+ usePreBuilt: '如果可能,下载预编译的依赖库(减少编译时间)',
},
en: {
selectExt: 'Select Extensions',
@@ -234,8 +267,9 @@ const I18N = {
depTips: 'After selecting the extensions, the unselectable items are essential dependencies. In the compiled dependencies list, optional dependencies consist of existing extensions and optional dependencies of libraries. Optional dependencies will be added in --with-libs parameter.',
microUnavailable: 'Micro does not support PHP 7.4 and earlier versions!',
windowsSAPIUnavailable: 'Windows does not support fpm and embed build!',
- useUPX: 'Enable UPX compression (reduce binary size, but in rare cases micro SAPI doesn\'t work with UPX)',
+ useUPX: 'Enable UPX compression (reduce binary size)',
windowsDownSPCWarning: 'Please download the spc.exe binary file manually and extract it to the current directory on Windows!',
+ usePreBuilt: 'Download pre-built dependencies if possible (reduce compile time)',
}
};
@@ -305,6 +339,9 @@ const zts = ref(0);
// chosen download by extensions
const downloadByExt = ref(1);
+// use pre-built
+const preBuilt = ref(1);
+
// chosen upx
const enableUPX = ref(0);
diff --git a/docs/en/develop/source-module.md b/docs/en/develop/source-module.md
index c6010523..561c1b7c 100644
--- a/docs/en/develop/source-module.md
+++ b/docs/en/develop/source-module.md
@@ -24,7 +24,8 @@ The following is the source download configuration corresponding to the `libeven
"type": "ghrel",
"repo": "libevent/libevent",
"match": "libevent.+\\.tar\\.gz",
- "license": {
+ "provide-pre-built": true,
+ "license": {
"type": "file",
"path": "LICENSE"
}
@@ -55,6 +56,8 @@ Each source file in source.json has the following params:
- `license`: the open source license of the source code, see **Open Source License** section below
- `type`: must be one of the types mentioned above
- `path` (optional): release the source code to the specified directory instead of `source/{name}`
+- `provide-pre-built` (optional): whether to provide precompiled binary files.
+ If `true`, it will automatically try to download precompiled binary files when running `bin/spc download`
::: tip
The `path` parameter in `source.json` can specify a relative or absolute path. When specified as a relative path, the path is based on `source/`.
diff --git a/docs/en/develop/structure.md b/docs/en/develop/structure.md
index 87e6958b..e43b6d6d 100644
--- a/docs/en/develop/structure.md
+++ b/docs/en/develop/structure.md
@@ -19,7 +19,7 @@ The project is mainly divided into several folders:
- `bin/`: used to store program entry files, including `bin/spc`, `bin/spc-alpine-docker`, `bin/setup-runtime`.
- `config/`: Contains all the extensions and dependent libraries supported by the project,
- as well as the download link and download methods of these sources. It is divided into files: `lib.json`, `ext.json`, `source.json`, `pkg.json` .
+ as well as the download link and download methods of these sources. It is divided into files: `lib.json`, `ext.json`, `source.json`, `pkg.json`, `pre-built.json` .
- `src/`: The core code of the project, including the entire framework and commands for compiling various extensions and libraries.
- `vendor/`: The directory that Composer depends on, you do not need to make any modifications to it.
diff --git a/docs/en/guide/manual-build.md b/docs/en/guide/manual-build.md
index 92b2734e..95d08ebd 100644
--- a/docs/en/guide/manual-build.md
+++ b/docs/en/guide/manual-build.md
@@ -157,6 +157,9 @@ bin/spc download php-src,micro,zstd,ext-zstd
# Download only extensions and libraries to be compiled (use extensions, including suggested libraries)
bin/spc download --for-extensions=openssl,swoole,zip,pcntl,zstd
+# Download resources, prefer to download dependencies with pre-built packages (reduce the time to compile dependencies)
+bin/spc download --for-extensions="curl,pcntl,xml,mbstring" --prefer-pre-built
+
# Download only the extensions and dependent libraries to be compiled (use extensions, excluding suggested libraries)
bin/spc download --for-extensions=openssl,swoole,zip,pcntl --without-suggestions
@@ -388,6 +391,8 @@ when you use static-php-cli to build PHP or modify and enhance the static-php-cl
- `dev:sort-config`: Sort the list of configuration files in the `config/` directory in alphabetical order
- `dev:lib-ver `: Read the version from the source code of the dependency library (only available for specific dependency libraries)
- `dev:ext-ver `: Read the corresponding version from the source code of the extension (only available for specific extensions)
+- `dev:pack-lib `: Package the specified library into a tar.gz file (maintainer only)
+- `dev:gen-ext-docs`: Generate extension documentation (maintainer only)
```bash
# output all extensions information
@@ -523,3 +528,12 @@ Commonly used objects and functions using the `-P` function are:
static-php-cli has many open methods, which cannot be listed in the docs,
but as long as it is a `public function` and is not marked as `@internal`, it theoretically can be called.
:::
+
+## Multiple builds
+
+If you need to build multiple times locally, the following method can save you time downloading resources and compiling.
+
+- If you only switch the PHP version without changing the dependent libraries, you can use `bin/spc switch-php-version` to quickly switch the PHP version, and then re-run the same `build` command.
+- If you want to rebuild once, but do not re-download the source code, you can first `rm -rf buildroot source` to delete the compilation directory and source code directory, and then rebuild.
+- If you want to update a version of a dependency, you can use `bin/spc del-download ` to delete the specified source code, and then use `download ` to download it again.
+- If you want to update all dependent versions, you can use `bin/spc download --clean` to delete all downloaded sources, and then download them again.
diff --git a/docs/zh/develop/source-module.md b/docs/zh/develop/source-module.md
index 51e9131a..a97dce34 100644
--- a/docs/zh/develop/source-module.md
+++ b/docs/zh/develop/source-module.md
@@ -18,6 +18,7 @@ static-php-cli 的下载资源模块是一个主要的功能,它包含了所
"type": "ghrel",
"repo": "libevent/libevent",
"match": "libevent.+\\.tar\\.gz",
+ "provide-pre-built": true,
"license": {
"type": "file",
"path": "LICENSE"
@@ -44,6 +45,7 @@ source.json 中每个源文件拥有以下字段:
- `license`: 源代码的开源许可证,见下方 **开源许可证** 章节
- `type`: 必须为上面提到的类型之一
- `path`(可选): 释放源码到指定目录而非 `source/{name}`
+- `provide-pre-built`(可选): 是否提供预编译的二进制文件,如果为 `true`,则会在 `bin/spc download` 时尝试自动下载预编译的二进制文件
::: tip
`source.json` 中的 `path` 参数可指定相对路径或绝对路径。当指定为相对路径时,路径基于 `source/`。
diff --git a/docs/zh/develop/structure.md b/docs/zh/develop/structure.md
index 1e290998..16c3a9e4 100644
--- a/docs/zh/develop/structure.md
+++ b/docs/zh/develop/structure.md
@@ -14,7 +14,7 @@ static-php-cli 主要包含三种逻辑组件:资源、依赖库、扩展。
项目主要分为几个文件夹:
- `bin/`: 用于存放程序入口文件,包含 `bin/spc`、`bin/spc-alpine-docker`、`bin/setup-runtime`。
-- `config/`: 包含了所有项目支持的扩展、依赖库以及这些资源下载的地址、下载方式等,分为四个文件:`lib.json`、`ext.json`、`source.json`、`pkg.json`。
+- `config/`: 包含了所有项目支持的扩展、依赖库以及这些资源下载的地址、下载方式等,:`lib.json`、`ext.json`、`source.json`、`pkg.json`、`pre-built.json`。
- `src/SPC/`: 项目的核心代码,包含了整个框架以及编译各种扩展和库的命令。
- `src/globals/`: 项目的全局方法和常量、运行时需要的测试文件(例如:扩展的可用性检查代码)。
- `vendor/`: Composer 依赖的目录,你无需对它做出任何修改。
diff --git a/docs/zh/guide/manual-build.md b/docs/zh/guide/manual-build.md
index 01ea5a76..0c54456a 100644
--- a/docs/zh/guide/manual-build.md
+++ b/docs/zh/guide/manual-build.md
@@ -135,6 +135,9 @@ bin/spc download --for-libs=liblz4,libevent --without-suggestions
# 下载资源时,忽略部分资源的缓存,强制下载(如切换 PHP 版本)
bin/spc download --for-extensions=curl,pcntl,xml --ignore-cache-sources=php-src --with-php=8.3
+# 下载资源时,优先下载有预编译包的依赖库(减少编译依赖的时间)
+bin/spc download --for-extensions="curl,pcntl,xml,mbstring" --prefer-pre-built
+
# 下载所有依赖包
bin/spc download --all
@@ -346,6 +349,8 @@ bin/spc extract php-src,libxml2
- `dev:sort-config`: 对 `config/` 目录下的配置文件的列表按照字母表排序
- `dev:lib-ver `: 从依赖库的源码中读取版本(仅特定依赖库可用)
- `dev:ext-ver `: 从扩展的源码中读取对应版本(仅特定扩展可用)
+- `dev:pack-lib `: 打包指定的依赖库(仅发布者可用)
+- `dev:gen-ext-docs`: 生成扩展文档(仅发布者可用)
```bash
# 输出所有扩展
@@ -466,3 +471,12 @@ memory_limit => 8G => 8G
::: tip
static-php-cli 开放的方法非常多,文档中无法一一列举,但只要是 `public function` 并且不被标注为 `@internal`,均可调用。
:::
+
+## 多次构建
+
+如果你在本地要多次构建,以下方法可以为你节省下载资源、编译的时间。
+
+- 仅切换 PHP 版本,不更换依赖库版本时,可以使用 `bin/spc switch-php-version` 快速切换 PHP 版本,然后重新运行同样的 `build` 命令。
+- 如果你想重新构建一次,但不重新下载源码,可以先 `rm -rf buildroot source` 删除编译目录和源码目录,然后重新构建。
+- 如果你想更新某个依赖的版本,可以使用 `bin/spc del-download ` 删除指定的源码,然后使用 `download ` 重新下载。
+- 如果你想更新所有依赖的版本,可以使用 `bin/spc download --clean` 删除所有下载的源码,然后重新下载。