Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit 7625aeb

Browse files
committed
CLI generator update: windows and upx support
1 parent 34729f5 commit 7625aeb

File tree

4 files changed

+60
-12
lines changed

4 files changed

+60
-12
lines changed

docs/.vitepress/components/CliGenerator.vue

+52-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<label :for="index">{{ index }}</label>
1515
</div>
1616
</div>
17-
<div class="my-btn" @click="selectCommon">{{ I18N[lang].selectCommon }}</div>
17+
<div class="my-btn" v-if="selectedSystem !== 'windows'" @click="selectCommon">{{ I18N[lang].selectCommon }}</div>
1818
<div class="my-btn" @click="checkedExts = []">{{ I18N[lang].selectNone }}</div>
1919

2020
<details class="details custom-block">
@@ -41,20 +41,24 @@
4141
<p class="custom-block-title">WARNING</p>
4242
<p>{{ I18N[lang].microUnavailable }}</p>
4343
</div>
44+
<div v-if="selectedSystem === 'windows' && (checkedTargets.indexOf('fpm') !== -1 || checkedTargets.indexOf('embed') !== -1)" class="warning custom-block">
45+
<p class="custom-block-title">WARNING</p>
46+
<p>{{ I18N[lang].windowsSAPIUnavailable }}</p>
47+
</div>
4448
<h2>{{ I18N[lang].buildOptions }}</h2>
4549
<div class="option-line">
4650
<span class="option-title">{{ I18N[lang].buildEnvironment }}</span>
4751
<select v-model="selectedEnv">
4852
<option value="native">{{ I18N[lang].buildEnvNative }}</option>
4953
<option value="spc">{{ I18N[lang].buildEnvSpc }}</option>
50-
<option value="docker">{{ I18N[lang].buildEnvDocker }}</option>
54+
<option value="docker" v-if="selectedSystem !== 'windows'">{{ I18N[lang].buildEnvDocker }}</option>
5155
</select>
5256
</div>
5357
<div v-if="selectedEnv === 'spc'" class="option-line">
5458
<span class="option-title">{{ I18N[lang].selectedArch }}</span>
5559
<select v-model="selectedArch">
5660
<option value="x86_64">x86_64 (amd64)</option>
57-
<option value="aarch64">aarch64 (arm64)</option>
61+
<option value="aarch64" v-if="selectedSystem !== 'windows'">aarch64 (arm64)</option>
5862
</select>
5963
</div>
6064
<div class="option-line">
@@ -87,14 +91,28 @@
8791
<input type="radio" id="show-download-no" :value="0" v-model="downloadByExt" />
8892
<label for="show-download-no">{{ I18N[lang].no }}</label>
8993
</div>
94+
<div class="option-line" v-if="selectedSystem !== 'macos'">
95+
<span class="option-title">{{ I18N[lang].useUPX }}</span>
96+
<input type="radio" id="upx-yes" :value="1" v-model="enableUPX" />
97+
<label for="upx-yes">{{ I18N[lang].yes }}</label>
98+
99+
<input type="radio" id="upx-no" :value="0" v-model="enableUPX" />
100+
<label for="upx-no">{{ I18N[lang].no }}</label>
101+
</div>
90102
<h2>{{ I18N[lang].hardcodedINI }}</h2>
91103
<textarea class="textarea" :placeholder="I18N[lang].hardcodedINIPlacehoder" v-model="hardcodedINIData" rows="5" />
92104
<h2>{{ I18N[lang].resultShow }}</h2>
93105
<div v-if="selectedEnv === 'spc'" class="command-container">
94106
<b>{{ I18N[lang].downloadSPCBinaryCommand }}</b>
95-
<div class="command-preview">
107+
<div class="command-preview" v-if="selectedSystem !== 'windows'">
96108
curl -o spc.tgz https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-{{ selectedSystem }}-{{ selectedArch }}.tar.gz && tar -zxvf spc.tgz && rm spc.tgz<br>
97109
</div>
110+
<div v-else>
111+
<div class="warning custom-block">
112+
<p class="custom-block-title">WARNING</p>
113+
<p>{{ I18N[lang].windowsDownSPCWarning }}</p>
114+
</div>
115+
</div>
98116
</div>
99117
<div v-if="downloadByExt" class="command-container">
100118
<b>{{ I18N[lang].downloadExtOnlyCommand }}</b>
@@ -106,7 +124,7 @@
106124
</div>
107125
<div class="command-container">
108126
<b>{{ I18N[lang].compileCommand }}</b>
109-
<div class="command-preview">{{ spcCommand }} build {{ buildCommand }} "{{ extList }}"{{ additionalLibs }}{{ debug ? ' --debug' : '' }}{{ zts ? ' --enable-zts' : '' }}{{ displayINI }}</div>
127+
<div class="command-preview">{{ spcCommand }} build {{ buildCommand }} "{{ extList }}"{{ additionalLibs }}{{ debug ? ' --debug' : '' }}{{ zts ? ' --enable-zts' : '' }}{{ enableUPX ? ' --with-upx-pack' : '' }}{{ displayINI }}</div>
110128
</div>
111129
</div>
112130
</template>
@@ -137,7 +155,7 @@ defineProps({
137155
const osList = [
138156
{ os: 'linux', label: 'Linux', disabled: false },
139157
{ os: 'macos', label: 'macOS', disabled: false },
140-
{ os: 'windows', label: 'Windows', disabled: true },
158+
{ os: 'windows', label: 'Windows', disabled: false },
141159
];
142160
143161
const availablePhpVersions = [
@@ -177,6 +195,9 @@ const I18N = {
177195
buildLibs: '要构建的库',
178196
depTips: '选择扩展后,不可选中的项目为必需的依赖,编译的依赖库列表中可选的为现有扩展和依赖库的可选依赖。选择可选依赖后,将生成 --with-libs 参数。',
179197
microUnavailable: 'micro 不支持 PHP 7.4 及更早版本!',
198+
windowsSAPIUnavailable: 'Windows 目前不支持 fpm、embed 构建!',
199+
useUPX: '是否开启 UPX 压缩(减小二进制体积)',
200+
windowsDownSPCWarning: 'Windows 下请手动下载 spc.exe 二进制文件并解压到当前目录!',
180201
},
181202
en: {
182203
selectExt: 'Select Extensions',
@@ -205,7 +226,10 @@ const I18N = {
205226
selectedSystem: 'Select Build OS',
206227
buildLibs: 'Select Dependencies',
207228
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.',
208-
microUnavailable: 'Micro does not support PHP 7.4 and earlier versions!'
229+
microUnavailable: 'Micro does not support PHP 7.4 and earlier versions!',
230+
windowsSAPIUnavailable: 'Windows does not support fpm and embed build!',
231+
useUPX: 'Enable UPX compression (reduce binary size)',
232+
windowsDownSPCWarning: 'Please download the spc.exe binary file manually and extract it to the current directory on Windows!',
209233
}
210234
};
211235
@@ -275,6 +299,9 @@ const zts = ref(0);
275299
// chosen download by extensions
276300
const downloadByExt = ref(1);
277301
302+
// chosen upx
303+
const enableUPX = ref(0);
304+
278305
const hardcodedINIData = ref('');
279306
280307
const selectedSystem = ref('linux');
@@ -286,6 +313,9 @@ const spcCommand = computed(() => {
286313
case 'native':
287314
return 'bin/spc';
288315
case 'spc':
316+
if (selectedSystem.value === 'windows') {
317+
return '.\\spc.exe';
318+
}
289319
return './spc';
290320
case 'docker':
291321
return 'bin/spc-alpine-docker';
@@ -334,6 +364,11 @@ const calculateExtDepends = (input) => {
334364
if (depends.length === 0) {
335365
return;
336366
}
367+
} else if (selectedSystem.value === 'windows') {
368+
depends = ext.value[node]['ext-depends-windows'] ?? ext.value[node]['ext-depends'] ?? [];
369+
if (depends.length === 0) {
370+
return;
371+
}
337372
}
338373
339374
depends.forEach((dep) => {
@@ -364,6 +399,11 @@ const calculateExtLibDepends = (input) => {
364399
if (depends.length === 0) {
365400
return;
366401
}
402+
} else if (selectedSystem.value === 'windows') {
403+
depends = lib.value[node]['lib-depends-windows'] ?? lib.value[node]['lib-depends'] ?? [];
404+
if (depends.length === 0) {
405+
return;
406+
}
367407
}
368408
369409
depends.forEach((dep) => {
@@ -385,6 +425,11 @@ const calculateExtLibDepends = (input) => {
385425
if (depends.length === 0) {
386426
return;
387427
}
428+
} else if (selectedSystem.value === 'windows') {
429+
depends = ext.value[node]['lib-depends-windows'] ?? ext.value[node]['lib-depends'] ?? [];
430+
if (depends.length === 0) {
431+
return;
432+
}
388433
}
389434
390435
depends.forEach((dep) => {

docs/.vitepress/components/DependencyUtil.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
export function getMetaList(meta, type, name, list_name) {
22
if (meta.os === 'linux') {
3-
return meta[type][name][list_name + '-linux'] ?? meta[type][name][list_name + '-unix'] ??meta[type][name][list_name] ?? [];
3+
return meta[type][name][list_name + '-linux'] ?? meta[type][name][list_name + '-unix'] ?? meta[type][name][list_name] ?? [];
44
}
55
if (meta.os === 'macos') {
6-
return meta[type][name][list_name + '-macos'] ?? meta[type][name][list_name + '-unix'] ??meta[type][name][list_name] ?? [];
6+
return meta[type][name][list_name + '-macos'] ?? meta[type][name][list_name + '-unix'] ?? meta[type][name][list_name] ?? [];
7+
}
8+
if (meta.os === 'windows') {
9+
return meta[type][name][list_name + '-windows'] ?? meta[type][name][list_name] ?? [];
710
}
811
return [];
912
}

docs/en/guide/cli-generator.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import CliGenerator from "../../.vitepress/components/CliGenerator.vue";
55
# CLI Build Command Generator
66

77
::: tip
8-
There is currently no `spc` binary for Windows systems, so there is no Windows option yet.
9-
To compile on Windows, use static-php-cli from git source.
8+
The extensions selected below may contain extensions that are not supported by the selected operating system,
9+
which may cause compilation to fail. Please check [Supported Extensions](./extensions) first.
1010
:::
1111

1212
<cli-generator lang="en" />

docs/zh/guide/cli-generator.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import CliGenerator from "../../.vitepress/components/CliGenerator.vue";
55
# CLI 编译命令生成器
66

77
::: tip
8-
目前未提供 Windows 系统的 `spc` 二进制,所以暂未提供 Windows 的选项。要在 Windows 编译,请从源码使用 static-php-cli
8+
下面选择扩展可能包含所选操作系统不支持的扩展,这可能导致编译失败。请先查阅 [支持的扩展](./extensions)
99
:::
1010

1111
<cli-generator lang="zh" />

0 commit comments

Comments
 (0)