diff --git a/.github/workflows/auto-cache-pool-tarball.yml b/.github/workflows/auto-cache-pool-tarball.yml index 3fc60289b2..ca16666b07 100644 --- a/.github/workflows/auto-cache-pool-tarball.yml +++ b/.github/workflows/auto-cache-pool-tarball.yml @@ -8,7 +8,7 @@ on: jobs: auto-cache-pool: - if: 1 + if: 0 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/linux-aarch64.yml b/.github/workflows/linux-aarch64.yml index 80f412a279..ab9370040e 100644 --- a/.github/workflows/linux-aarch64.yml +++ b/.github/workflows/linux-aarch64.yml @@ -7,7 +7,7 @@ env: jobs: linux-aarch64: - if: 1 + if: 0 runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/linux-x86_64.yml b/.github/workflows/linux-x86_64.yml index c362316986..a4fc310cfe 100644 --- a/.github/workflows/linux-x86_64.yml +++ b/.github/workflows/linux-x86_64.yml @@ -43,7 +43,7 @@ env: jobs: linux-x86_64: - if: 1 + if: 0 runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/macos-aarch64.yml b/.github/workflows/macos-aarch64.yml index 784fc5f92c..b2dc19d0d3 100644 --- a/.github/workflows/macos-aarch64.yml +++ b/.github/workflows/macos-aarch64.yml @@ -7,7 +7,7 @@ env: jobs: macos-aarch64: - if: 1 + if: 0 runs-on: macos-14 # macos-latest (macos-14) 变更了 CPU 架构,由 x86_64 变更为 arm64 # macos-14 CPU 架构 arm64 diff --git a/.github/workflows/macos-x86_64.yml b/.github/workflows/macos-x86_64.yml index fb0c898c78..aaff4653e1 100644 --- a/.github/workflows/macos-x86_64.yml +++ b/.github/workflows/macos-x86_64.yml @@ -9,7 +9,7 @@ env: jobs: macos-x86_64: - if: 1 + if: 0 runs-on: macos-13 # macos-latest (macos-14) 变更了 CPU 架构,由 x86_64 变更为 arm64 # macos-14 CPU 架构 arm64 diff --git a/.github/workflows/runner-os-readme.md b/.github/workflows/runner-os-readme.md index 6eb0093f43..78d8480225 100644 --- a/.github/workflows/runner-os-readme.md +++ b/.github/workflows/runner-os-readme.md @@ -1 +1,2 @@ https://github.com/actions/runner-images/tree/main/images +https://github.com/actions/runner-images diff --git a/.github/workflows/windows-cygwin.yml b/.github/workflows/windows-cygwin.yml index d663e19d45..183da70f78 100644 --- a/.github/workflows/windows-cygwin.yml +++ b/.github/workflows/windows-cygwin.yml @@ -9,7 +9,7 @@ env: jobs: windows-cygwin: - if: 1 + if: 0 runs-on: windows-latest strategy: matrix: diff --git a/.github/workflows/windows-native-vs2022.yml b/.github/workflows/windows-native-vs2022.yml new file mode 100644 index 0000000000..982ef5ebcb --- /dev/null +++ b/.github/workflows/windows-native-vs2022.yml @@ -0,0 +1,123 @@ +name: build-php-cli-windows-vs2022 + +on: + push: + pull_request: + +env: + BUILD_PHP_VERSION: 8.2.13 + +jobs: + windows-native: + if: 1 + runs-on: windows-2022 + strategy: + matrix: + php-version: + # - "8.2.13" + # - "8.1.27" + - "8.3.11" + + steps: + - uses: actions/checkout@v4 + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 + vsversion: + - name: show environment info + run: | + git config --global core.autocrlf false + git config --global core.eol lf + git config --global core.ignorecase false + env + ipconfig + uname -a + pwd + ipconfig /all + # 显示逻辑cpu 个数 + wmic cpu get NumberOfLogicalProcessors /value + # echo %NUMBER_OF_PROCESSORS% + Write-Output $env:NUMBER_OF_PROCESSORS + systeminfo + echo "BUILD_PHP_VERSION=${{ matrix.php-version }}" >> $Env:GITHUB_ENV + + - name: prepare deps soft + shell: cmd + run: | + sapi\quickstart\windows\native-build\windows-init.bat + + - name: Set Github ENV variables + run: | + $CURRENT_DIR = Get-Location + echo "PHP_SDK_ARCH=x64" >> $Env:GITHUB_ENV + echo "PHP_SDK_BIN_PATH=${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools\bin" >> $Env:GITHUB_ENV + echo "PHP_SDK_MSYS2_PATH=${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools\msys2\usr\bin" >> $Env:GITHUB_ENV + echo "PHP_SDK_OS_ARCH=x64" >> $Env:GITHUB_ENV + echo "PHP_SDK_PHP_CMD=${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools\bin\php\do_php.bat" >> $Env:GITHUB_ENV + echo "PHP_SDK_ROOT_PATH=${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools" >> $Env:GITHUB_ENV + echo "PHP_SDK_VC_DIR=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC" >> $Env:GITHUB_ENV + echo "PHP_SDK_VC_TOOLSET_VER=$env:VCToolsVersion" >> $Env:GITHUB_ENV + echo "PHP_SDK_VS=vs17" >> $Env:GITHUB_ENV + echo "PHP_SDK_VS_NUM=17" >> $Env:GITHUB_ENV + echo "PHP_SDK_VS_SHELL_CMD=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat amd64" >> $Env:GITHUB_ENV + + + $X_PATH = "${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools\bin;${CURRENT_DIR}\var\windows-build-deps\php-sdk-binary-tools\msys2\usr\bin;${CURRENT_DIR}\bin\runtime\nasm\;$env:PATH" + echo $X_PATH + echo "PATH=$X_PATH" >> $Env:GITHUB_ENV + + - name: show deps soft + if: 1 + run: | + $CURRENT_DIR = Get-Location + where perl + php -v + perl -v + nasm -v + + + - name: php prepare + shell: cmd + run: | + cd var\windows-build-deps\php-src\ + .\buildconf.bat -f + + - name: php config + shell: cmd + run: | + cd var\windows-build-deps\php-src\ + configure.bat ^ + --disable-all --disable-cgi --enable-cli ^ + --enable-sockets --enable-ctype --enable-pdo --enable-phar ^ + --enable-filter ^ + --enable-xmlreader --enable-xmlwriter ^ + --enable-tokenizer + + - name: php build + shell: cmd + run: | + cd var\windows-build-deps\php-src\ + where bison.exe + where re2c.exe + nmake /E + + - name: Show Build Result + run: | + cd var\windows-build-deps\php-src\ + + .\x64\Release_TS\php.exe -v + .\x64\Release_TS\php.exe -m + dumpbin /DEPENDENTS ".\x64\Release_TS\php.exe" + + - name: production artifacts + uses: actions/upload-artifact@v4 + with: + name: php-cli-v${{ env.BUILD_PHP_VERSION }}-vs16-x64 + retention-days: 90 + path: "var\windows-build-deps\php-src\\x64\Release_TS\php.exe" + + - name: gh release + uses: softprops/action-gh-release@v2 + if: 0 && startsWith(github.ref, 'refs/tags/') + with: + files: "var\windows-build-deps\php-src\\x64\Release_TS\php.exe" diff --git a/composer.json b/composer.json index 91bcbc5fdd..7e71b6d89a 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,10 @@ { "require": { "marcj/topsort": "^2.0", - "ext-posix": "*", "ext-curl": "*", "ext-json": "*", "ext-fileinfo": "*", + "ext-zip": "*", "phpunit/phpunit": "^9.6", "nikic/php-parser": "^5.0" }, diff --git a/prepare.php b/prepare.php index 509466d84c..f2e9fdd582 100755 --- a/prepare.php +++ b/prepare.php @@ -18,17 +18,25 @@ } +$osType = $p->getOsType(); # clean -# clean old make.sh -$p->cleanFile(__DIR__ . '/make.sh'); -$p->cleanFile(__DIR__ . '/make-install-deps.sh'); -$p->cleanFile(__DIR__ . '/make-env.sh'); -$p->cleanFile(__DIR__ . '/make-export-variables.sh'); -$p->cleanFile(__DIR__ . '/make-download-box.sh'); -$p->cleanFile(__DIR__ . '/cppflags.log'); -$p->cleanFile(__DIR__ . '/ldflags.log'); -$p->cleanFile(__DIR__ . '/libs.log'); -$p->cleanFile(__DIR__ . '/configure.backup'); + +if ($osType == 'win') { + +} else { + + # clean old make.sh + $p->cleanFile(__DIR__ . '/make.sh'); + $p->cleanFile(__DIR__ . '/make-install-deps.sh'); + $p->cleanFile(__DIR__ . '/make-env.sh'); + $p->cleanFile(__DIR__ . '/make-export-variables.sh'); + $p->cleanFile(__DIR__ . '/make-download-box.sh'); + $p->cleanFile(__DIR__ . '/cppflags.log'); + $p->cleanFile(__DIR__ . '/ldflags.log'); + $p->cleanFile(__DIR__ . '/libs.log'); + $p->cleanFile(__DIR__ . '/configure.backup'); + +} # PHP 默认版本 (此文件配置 /sapi/PHP-VERSION.conf 在 build_native_php分支 和 衍生分支 无效) @@ -88,12 +96,13 @@ echo PHP_EOL; // Sync code from php-src -$p->setPhpSrcDir($p->getWorkDir() . '/var/php-' . BUILD_PHP_VERSION); +$p->setPhpSrcDir($p->getWorkDir() . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'php-' . BUILD_PHP_VERSION); + // Compile directly on the host machine, not in the docker container if ($p->getInputOption('without-docker') || ($p->isMacos())) { $p->setWorkDir(__DIR__); - $p->setBuildDir(__DIR__ . '/thirdparty'); + $p->setBuildDir(__DIR__ . DIRECTORY_SEPARATOR . 'thirdparty'); } $p->setRootDir(__DIR__); @@ -102,7 +111,7 @@ if ($p->getInputOption('with-php-src')) { $p->setPhpSrcDir($p->getInputOption('with-php-src')); } else { - $p->setPhpSrcDir($p->getRootDir() . '/thirdparty/php-src'); + $p->setPhpSrcDir($p->getRootDir() . DIRECTORY_SEPARATOR . 'thirdparty' . DIRECTORY_SEPARATOR . 'php-src'); } //设置PHP 安装目录 @@ -158,6 +167,8 @@ $p->setProxyConfig($proxyConfig, $http_proxy); } +die(); + if ($p->isMacos()) { //$p->setExtraLdflags('-undefined dynamic_lookup'); diff --git a/sapi/quickstart/linux/run-rhel-container.sh b/sapi/quickstart/linux/run-rhel-container.sh index 7ba17080d4..3aafacfcb4 100644 --- a/sapi/quickstart/linux/run-rhel-container.sh +++ b/sapi/quickstart/linux/run-rhel-container.sh @@ -1,6 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash -set -exu +set -xu __DIR__=$( cd "$(dirname "$0")" pwd diff --git a/sapi/quickstart/windows/README.md b/sapi/quickstart/windows/README.md index 0ea31da6c6..67dda956fa 100644 --- a/sapi/quickstart/windows/README.md +++ b/sapi/quickstart/windows/README.md @@ -1,8 +1,15 @@ -# windows 快速准备构建环境 +# windows 快速准备构建环境 (2种构建方式) -## [windows cygwin 环境 构建步骤](../../../docs/Cygwin.md) + 1. 原生构建 + 2. cygwin 环境 构建 -## 双击如下两个脚本,自动下载cygwin 和 cygwin安装依赖库 +## 一、原生构建 + +### [windows 原生构建步骤](native-build/README.md) + +## 二、cygwin 环境 构建 + + cygwin 环境 构建 快速开始,双击如下两个脚本,自动下载cygwin 和 cygwin安装依赖库 ```shell @@ -14,7 +21,11 @@ sapi\quickstart\windows\install-cygwin.bat ``` -# windows 软连接例子 +### [windows cygwin 构建步骤](../../../docs/Cygwin.md) + +## 三、其它 + +### windows 软连接例子 ```bash @@ -22,10 +33,6 @@ mklink composer composer.phar ``` -## 其他 - -1. [windows build native php](./windows-native.md) -1. [install msys2 ](./install-msys2.md) diff --git a/sapi/quickstart/windows/cygwin-build/download-cygwin.bat b/sapi/quickstart/windows/cygwin-build/download-cygwin.bat new file mode 100644 index 0000000000..2af476f4b1 --- /dev/null +++ b/sapi/quickstart/windows/cygwin-build/download-cygwin.bat @@ -0,0 +1,24 @@ +@echo off + +setlocal + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-cygwin-build-deps\ + +cd /d %__PROJECT__%\var\windows-cygwin-build-deps\ + +:: cygwin site: https://cygwin.com/ +curl.exe -fSLo setup-x86_64.exe https://cygwin.com/setup-x86_64.exe + + +:: exit /b 0 + +cd /d %__PROJECT__%\ + +endlocal diff --git a/sapi/quickstart/windows/install-cygwin.bat b/sapi/quickstart/windows/cygwin-build/install-cygwin.bat similarity index 83% rename from sapi/quickstart/windows/install-cygwin.bat rename to sapi/quickstart/windows/cygwin-build/install-cygwin.bat index efc525ef24..94c988b3c5 100644 --- a/sapi/quickstart/windows/install-cygwin.bat +++ b/sapi/quickstart/windows/cygwin-build/install-cygwin.bat @@ -1,4 +1,19 @@ @echo off + +setlocal + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-cygwin-build-deps\ + +cd /d %__PROJECT__%\var\windows-cygwin-build-deps\ + + :: cygwin安装多个包,包之间,用逗号分隔 setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages make,git,curl,wget,tar,libtool,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils,openssl-devel @@ -9,4 +24,6 @@ setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site https://mirr setup-x86_64.exe --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages libzstd-devel +cd /d %__PROJECT__%\ +endlocal diff --git a/sapi/quickstart/windows/download-cygwin.bat b/sapi/quickstart/windows/download-cygwin.bat deleted file mode 100644 index 25086a1f0b..0000000000 --- a/sapi/quickstart/windows/download-cygwin.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -:: cygwin site: https://cygwin.com/ -start https://cygwin.com/setup-x86_64.exe diff --git a/sapi/quickstart/windows/download-msys2.bat b/sapi/quickstart/windows/download-msys2.bat deleted file mode 100644 index 35bd440020..0000000000 --- a/sapi/quickstart/windows/download-msys2.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -:: msys2 site: https://www.msys2.org/ -start https://mirror.msys2.org/distrib/x86_64/msys2-x86_64-20230526.exe - - diff --git a/sapi/quickstart/windows/native-build/README.md b/sapi/quickstart/windows/native-build/README.md new file mode 100644 index 0000000000..966ed6c739 --- /dev/null +++ b/sapi/quickstart/windows/native-build/README.md @@ -0,0 +1,204 @@ +# 构建原生 PHP + + 1. 准备 msys2 环境 + 2. msys2 环境下 下载软件包 、PHP 运行时 、PHP SDK 等 + 3. CMD 环境执行构建 + +## 一 、[msys2 环境 下载软件包 、PHP 运行时 、PHP SDK 等 ](msys2/README.md) + +## 二、CMD 环境构建 + +> bat 脚本不能包含中文 + +```bat +# 安装 vc 运行时 ( 可跳过 ) + + +# vs2019 + +cmd /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 + +# start /B +# cmd /c + +sapi\quickstart\windows\native-build\library\zlib.bat + +sapi\quickstart\windows\native-build\library\openssl.bat + + +cmd /k sapi\quickstart\windows\native-build\native-build-php-sdk-vs2019.bat + +:: phpsdk_deps -u +:: phpsdk_buildtree phpdev + +sapi\quickstart\windows\native-build\native-build-php-config.bat + +sapi\quickstart\windows\native-build\native-build-php-build.bat + +sapi\quickstart\windows\native-build\native-build-php-release.bat + +sapi\quickstart\windows\native-build\native-build-php-archive.bat + + +``` + +## 实验 vs2022 环境构建 + +```bat +# 自动打开指定文件夹 +start C:\msys64\home\Administrator\swoole-cli +start C:\msys64\home\Administrator\swoole-cli\php-src\ +start C:\msys64\home\Administrator\swoole-cli\php-src\x64\Release + +sapi\quickstart\windows\native-build\install-visualstudio-2022.bat + +# vs2022 +"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 + +sapi\quickstart\windows\native-build\native-build-php-sdk-vs2022.bat + +``` + +## 构建window PHP 工具 和 参考 + +[ download windows PHP ](https://windows.php.net/download#php-8.2) + +[windows build php 步骤](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2) + +[internals/windows/libs](https://wiki.php.net/internals/windows/libs) + +```shell + +git config core.ignorecase false # 设置 Git 在 Windows 上也区分大小写 + +``` + +Latest VC++ +https://learn.microsoft.com/en-AU/cpp/windows/latest-supported-vc-redist + +7zip +https://7-zip.org/ + +visualstudio +https://visualstudio.microsoft.com/zh-hans/downloads/ + +windows-sdk +https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ + +Windows PowerShell ISE 文本编辑器 + +## 通过命令行使用 MSVC 工具集 + + https://learn.microsoft.com/zh-cn/cpp/build/building-on-the-command-line?view=msvc-170 + +## 通过命令行使用 MSBuild + + https://learn.microsoft.com/zh-cn/cpp/build/msbuild-visual-cpp?view=msvc-170 + + // C:\Program Files\Microsoft Visual Studio\2022\Enterprise // + // C:\Program Files\Microsoft Visual Studio\2022\Community // + cl /? + +## Microsoft Visual C++ 可再发行程序包最新支持的下载 + + https://learn.microsoft.com/zh-cn/cpp/windows/latest-supported-vc-redist?view=msvc-170 + +Windows SDK +https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ + +消息编译器是 Windows SDK 的一部分 +消息编译器命令行在这里描述:MC.EXE + +Visual Studio 教程 | C++ +https://learn.microsoft.com/zh-cn/cpp/get-started/?view=msvc-170 + +## 使用命令行参数安装、更新和管理 Visual Studio + +https://learn.microsoft.com/zh-cn/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022 + +## Visual Studio 生成工具组件目录 + +https://learn.microsoft.com/zh-cn/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022 + +> MSVC 命令行工具使用 PATH、TMP、INCLUDE、LIB 和 LIBPATH 环境变量 + +```shell + + +VisualStudioSetup.exe +--locale en-US +--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 +--add Microsoft.Component.MSBuild +--add Microsoft.VisualStudio.Component.Roslyn.Compiler +--add Microsoft.Component.MSBuild +--add Microsoft.VisualStudio.Component.CoreBuildTools +--add Microsoft.VisualStudio.Workload.MSBuildTools +--add Microsoft.VisualStudio.Component.Windows11SDK.22000 +--add Microsoft.VisualStudio.Component.Windows10SDK.20348 +--add Microsoft.VisualStudio.Component.Windows10SDK +--path install="C:\VS" --path cache="C:\VS\cache" --path shared="C:\VS\shared" +--quiet --force --norestart +--channelId VisualStudio.16.Release ^ + +vs_buildtools.exe --quiet --force --norestart + +``` + +Microsoft Visual C++ 运行时库 +https://learn.microsoft.com/zh-cn/cpp/windows/latest-supported-vc-redist?view=msvc-170 +https://aka.ms/vs/17/release/vc_redist.x64.exe + +## 下载 visual studio 安装器 + + https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022 + https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2019 + + https://aka.ms/vs/17/release/vs_buildtools.exe + + curl -Lo VisualStudioSetup.exe 'https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022' + curl -Lo VisualStudioSetup.exe 'https://aka.ms/vs/17/release/vs_community.exe' + curl -Lo vs_buildtools.exe 'https://aka.ms/vs/17/release/vs_buildtools.exe' + +```shell +# 编译cpp +# https://learn.microsoft.com/zh-cn/cpp/build/walkthrough-creating-and-using-a-static-library-cpp?view=msvc-170 + +cl /c /EHsc MathLibrary.cpp + +cl /EHsc /MT test-vc.cpp /link LIBCMT.LIB /NODEFAULTLIB:msvcrt.lib + +LINK first.obj second.obj third.obj /OUT:filename.exe + +# 查看连接信息 + +dumpbin /DEPENDENTS test-vc.exe + +``` + +## 参考文档 + +1. [virtualstudio 命令行安装](https://learn.microsoft.com/zh-cn/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022) +1. [使用命令行参数安装、更新和管理 Visual Studio](https://learn.microsoft.com/zh-cn/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022) +1. [通过命令行使用 MSVC 工具集](https://learn.microsoft.com/zh-cn/cpp/build/building-on-the-command-line?view=msvc-170) +1. [从命令行使用 Microsoft C++ 工具集](https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170#download-and-install-the-tools) +1. [通过命令行使用 MSBuild](https://learn.microsoft.com/zh-cn/cpp/build/msbuild-visual-cpp?view=msvc-1700) +1. [Microsoft Visual C++ 最新运行时库](https://learn.microsoft.com/zh-cn/cpp/windows/latest-supported-vc-redist?view=msvc-170) +1. [Visual Studio 生成工具组件目录](https://learn.microsoft.com/zh-cn/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022) +1. [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) +1. [windows 环境下 构建 php 步骤](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2) +1. [VisualStudio 导入或导出安装配置](https://learn.microsoft.com/zh-cn/visualstudio/install/import-export-installation-configurations?view=vs-2022) +1. [Visual Studio 2019 版本 16.11 发行说明](https://learn.microsoft.com/zh-cn/visualstudio/releases/2019/release-notes) +1. [Visual Studio 2022 版本 17.9 发行说明](https://learn.microsoft.com/zh-cn/visualstudio/releases/2022/release-notes) +1. [MSVC 如何将清单嵌入到 C/C++ 应用程序中](https://learn.microsoft.com/zh-cn/cpp/build/understanding-manifest-generation-for-c-cpp-programs?view=msvc-170) +1. [Visual Studio 教程 | C++](https://learn.microsoft.com/zh-cn/cpp/get-started/?view=msvc-170) +1. [7zip](https://7-zip.org/) +1. [Visual Studio 许可证目录](https://visualstudio.microsoft.com/zh-hans/license-terms/) +1. [windows环境 使用ssh](https://learn.microsoft.com/zh-cn/windows-server/administration/openssh/openssh_install_firstuse) +1. [MSVC链接器选项](https://learn.microsoft.com/zh-cn/cpp/build/reference/linker-options?view=msvc-170) +1. [MSVC Mt.exe](https://learn.microsoft.com/en-us/windows/win32/sbscs/mt-exe?redirectedfrom=MSDN) +1. [/MD、/MT、/LD(使用运行时库)](https://learn.microsoft.com/zh-cn/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170) +1. [Install PowerShell on Windows, Linux, and macOS](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.4) +1. [Sysinternals Utilities Index](https://learn.microsoft.com/en-us/sysinternals/downloads/) +1. [curl 8.11.1 for Windows](https://curl.se/windows/) +1. [windows php release ](https://windows.php.net/downloads/releases/archives/) + diff --git a/sapi/quickstart/windows/native-build/build-static-php.bat b/sapi/quickstart/windows/native-build/build-static-php.bat new file mode 100644 index 0000000000..6f14fdd687 --- /dev/null +++ b/sapi/quickstart/windows/native-build/build-static-php.bat @@ -0,0 +1,26 @@ +@echo off + +setlocal + + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + + + +call "%__PROJECT__%\var\windows-build-deps\php-sdk-binary-tools\phpsdk-vs17-x64.bat" +call "%__PROJECT__%\sapi\quickstart\windows\native-build\native-build-php-config.bat" + + +if %ERRORLEVEL% neq 0 ( + echo 命令执行失败,退出状态为: %ERRORLEVEL% + exit /b %ERRORLEVEL% +) + +exit /b 0 + +endlocal diff --git a/sapi/quickstart/windows/native-build/build-static-php.ps1 b/sapi/quickstart/windows/native-build/build-static-php.ps1 new file mode 100644 index 0000000000..4cb34923b6 --- /dev/null +++ b/sapi/quickstart/windows/native-build/build-static-php.ps1 @@ -0,0 +1,45 @@ + +$__DIR__ = $PSScriptRoot + +$__DIR__ = Split-Path -Parent $MyInvocation.MyCommand.Definition +$__PROJECT__ = ( Convert-Path "$__DIR__\..\..\..\..\") + +Write-Host $__DIR__ +Write-Host $__PROJECT__ +Write-Host (Get-Location).Path + +<# + +var\windows-build-deps\php-sdk-binary-tools\phpsdk-vs17-x64.bat +cd var\windows-build-deps\php-src\ + +.\buildconf.bat -f +.\configure.bat --help + +configure.bat ^ +--disable-all --disable-cgi --enable-cli ^ +--enable-sockets --enable-ctype --enable-pdo --enable-phar ^ +--enable-filter ^ +--enable-xmlreader --enable-xmlwriter ^ +--enable-tokenizer + + + +nmake /E php.exe + +cd .\x64\Release_TS\ + +dumpbin /DEPENDENTS .\x64\Release_TS\php.exe + +# PHP 8.4 引入了默认的线程安全(ts)版本 + +#> + +exit + + +Invoke-Expression "cmd /c $__PROJECT__\var\windows-build-deps\php-sdk-binary-tools\phpsdk-vs17-x64.bat" +Invoke-Expression "cmd /c $__PROJECT__\sapi\quickstart\windows\native-build\native-build-php-config.bat" + + +cd $__PROJECT__ diff --git a/sapi/quickstart/windows/native-build/cmd-phpsdk-diff.md b/sapi/quickstart/windows/native-build/cmd-phpsdk-diff.md new file mode 100644 index 0000000000..4e74a47be0 --- /dev/null +++ b/sapi/quickstart/windows/native-build/cmd-phpsdk-diff.md @@ -0,0 +1,65 @@ +```bat + + +DevEnvDir=DevEnvDir=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\ +ExtensionSdkDir=C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs +EXTERNAL_INCLUDE=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt + +Framework40Version=v4.0 +FrameworkDir=C:\Windows\Microsoft.NET\Framework64\ +FrameworkDir64=C:\Windows\Microsoft.NET\Framework64\ +FrameworkVersion=v4.0.30319 +FrameworkVersion64=v4.0.30319 + +HOST_ARCH_NAME=amd64 +INCLUDE=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt +LIB=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\lib\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x64 +LIBPATH=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\lib\x86\store\references;C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.22000.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.22000.0;C:\Windows\Microsoft.NET\Framework64\v4.0.30319 + +NUMBER_OF_PROCESSORS=8 + +Path=c:\msys64\home\Administrator\php-sdk-binary-tools\bin;c:\msys64\home\Administrator\php-sdk-binary-tools\msys2\usr\bin;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\\x64;C:\Program Files (x86)\Windows Kits\10\bin\\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\\MSBuild\Current\Bin\amd64;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\;C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps +Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps; +PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC + +PHP_SDK_ARCH=x64 +PHP_SDK_BIN_PATH=c:\msys64\home\Administrator\php-sdk-binary-tools\bin +PHP_SDK_MSYS2_PATH=c:\msys64\home\Administrator\php-sdk-binary-tools\msys2\usr\bin +PHP_SDK_OS_ARCH=x64 +PHP_SDK_PHP_CMD=c:\msys64\home\Administrator\php-sdk-binary-tools\bin\php\do_php.bat +PHP_SDK_ROOT_PATH=c:\msys64\home\Administrator\php-sdk-binary-tools +PHP_SDK_VC_DIR=C:\Program Files\Microsoft Visual Studio\2022\Community\VC +PHP_SDK_VC_TOOLSET_VER=14.39.33523.0 +PHP_SDK_VS=vs17 +PHP_SDK_VS_NUM=17 +PHP_SDK_VS_SHELL_CMD="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 +Platform=x64 + +UCRTVersion=10.0.22000.0 +UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\10\ + +VCIDEInstallDir=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\VC\ +VCINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\ +VCToolsInstallDir=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\ +VCToolsRedistDir=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.38.33135\ +VCToolsVersion=14.39.33519 +VisualStudioVersion=17.0 +VS170COMNTOOLS=C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\ +VSCMD_ARG_app_plat=Desktop +VSCMD_ARG_HOST_ARCH=x64 +VSCMD_ARG_no_logo=yes +VSCMD_ARG_TGT_ARCH=x64 +VSCMD_VER=17.9.6 +VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio\2022\Community\ + +WindowsLibPath=C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.22000.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.22000.0 +WindowsSdkBinPath=C:\Program Files (x86)\Windows Kits\10\bin\ +WindowsSdkDir=C:\Program Files (x86)\Windows Kits\10\ +WindowsSDKLibVersion=10.0.22000.0\ +WindowsSdkVerBinPath=C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\ +WindowsSDKVersion=10.0.22000.0\ +__DOTNET_ADD_64BIT=1 +__DOTNET_PREFERRED_BITNESS=64 +__VSCMD_PREINIT_PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps; + +``` diff --git a/sapi/quickstart/windows/native-build/download-soft.ps1 b/sapi/quickstart/windows/native-build/download-soft.ps1 new file mode 100644 index 0000000000..f7f6901c9c --- /dev/null +++ b/sapi/quickstart/windows/native-build/download-soft.ps1 @@ -0,0 +1,116 @@ +# PowerShell 切换为超级用户 +powershell -NoProfile -Command "Start-Process powershell -Verb RunAs" + +# PowerShell 命令称为 cmdlet(读作 command-let) +# PowerShell ISE主要用于编写和调试PowerShell脚本 +# 在 Windows PowerShell 中 curl 命令被映射为 Invoke-WebRequest + + +Get-Alias -Name curl +Get-Command curl +Get-Command curl.exe + +# 包管理器(winget、chocolatey、scoop) + +# 安裝 WinGet +# https://github.com/microsoft/winget-cli/releases/ +# https://github.com/microsoft/winget-cli/releases/download/v1.10.40-preview/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle + +Add-AppxPackage -Path ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" + +Invoke-WebRequest -Uri "https://aka.ms/MicrosoftWinget" -UseBasicParsing | Invoke-Expression + +Invoke-WebRequest -Uri https://github.com/asheroto/winget-install/releases/latest/download/winget-install.ps1 -OutFile .\winget-install.ps1 + +irm https://github.com/asheroto/winget-install/releases/latest/download/winget-install.ps1 | iex + +irm winget.pro | iex + +winget install notepad++ + +winget install --id Git.Git -e --source winget +# 换源 +winget source remove winget +winget source add winget https://mirrors.ustc.edu.cn/winget-source +winget source reset winget + + + + +# Chocolatey是一个开源的包管理器 +# https://chocolatey.org/ +Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + +# https://community.chocolatey.org/install.ps1 + +irm https://community.chocolatey.org/install.ps1 | iex + +choco list +choco install -y copyq +choco install -y git +choco install -y winget +choco install -y microsoft-windows-terminal +choco install notepadplusplus + + +# Scoop是Windows的命令行安装程序。 +# https://github.com/ScoopInstaller/Install.git +Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser +Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression + +Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser +irm https://get.scoop.sh | iex +# irm get.scoop.sh -Proxy 'http://' | iex + +irm get.scoop.sh -outfile 'install.ps1' +.\install.ps1 -RunAsAdmin + +# 一行命令完成 +iex "& {$( irm get.scoop.sh )} -RunAsAdmin" + +# choco install +scoop install aria2 +scoop install notepad++ +scoop install winget +scoop install windows-terminal + + + +# Windows Terminal +# https://github.com/microsoft/terminal + +# Add-AppxPackage Microsoft.WindowsTerminal_.msixbundle +# https://github.com/microsoft/terminal/releases/download/v1.21.3231.0/Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle + +Invoke-WebRequest -Uri "https://github.com/microsoft/terminal/releases/download/v1.21.3231.0/Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle" -OutFile .\"Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle" + +Add-AppxPackage -Path ".\Microsoft.UI.Xaml.2.8.x64.appx" +Add-AppxPackage -Path ".\Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle" + +winget install --id Microsoft.WindowsTerminal -e + + + +# curl windows +# https://curl.se/windows/ + +Invoke-WebRequest -Uri https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/Git-2.47.1-64-bit.exe -OutFile .\Git-2.47.1-64-bit.exe + +start /wait .\Git-2.47.1-64-bit.exe /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEONEXIT=1 /DIR="C:\Program Files\Git" + + + + +# vcpkg +# https://learn.microsoft.com/zh-cn/vcpkg/get_started/overview +# https://vcpkg.io/en/packages + +git clone https://github.com/microsoft/vcpkg.git + + + +# nmake /f Makefile.vc mode=dll VC=17 MACHINE=x86 DEBUG=yes + + + + diff --git a/sapi/quickstart/windows/native-build/install-example.md b/sapi/quickstart/windows/native-build/install-example.md new file mode 100644 index 0000000000..3ec51fb0ff --- /dev/null +++ b/sapi/quickstart/windows/native-build/install-example.md @@ -0,0 +1,91 @@ +可以借助 MSYS2 环境 和 CMD 环境 进行构建 + +1. MSYS2 环境 用于下载软件 (msys2 集成了 Mingw 和 Cygwin ,同时还提供了包管理工具 `pacman`) +2. CMD 环境 安装Visual Studio +3. CMD 环境 执行编译 + +## msys2下载软件 + +1. 下载 msys2 [msys2](https://www.msys2.org/]) + > 浏览器打开,自动给下载 msys2: https://mirror.msys2.org/distrib/x86_64/msys2-x86_64-20240507.exe +1. 安装 msys2 + > 双击 `msys2-x86_64-20240507.exe ` 进行安装 +1. msys2安装软件 + ```shell + pacman -Syy --noconfirm git curl + ``` +1. msys2 环境下使用curl 下载软件 + ```shell + # 下载 vs2022 + + # 方式一 + curl -Lo VisualStudioSetup.exe 'https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022' + # 方式二 + curl -Lo VisualStudioSetup.exe 'https://aka.ms/vs/17/release/vs_community.exe' + + ``` + + ```shell + # 下载 php 源码 + git clone -b php-8.3.6 --depth=1 https://github.com/php/php-src.git + + # 下载 php-sdk for windows + # git clone -b php-sdk-2.2.0 --depth=1 https://github.com/php/php-sdk-binary-tools.git + git clone -b master --depth=1 https://github.com/php/php-sdk-binary-tools.git + + ``` + +## CMD 环境 安装VisualStudio + +1. [使用命令行参数安装、更新和管理 Visual Studio](https://learn.microsoft.com/zh-cn/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022) +1. [Visual Studio 生成工具组件目录](https://learn.microsoft.com/zh-cn/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022) + +> 使用命令行快速安装 VisualStudio 组件 + +```bat +cd c:\msys64\home\Administrator\ + +VisualStudioSetup.exe ^ +--locale en-US ^ +--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^ +--add Microsoft.Component.MSBuild ^ +--add Microsoft.VisualStudio.Component.Roslyn.Compiler ^ +--add Microsoft.Component.MSBuild ^ +--add Microsoft.VisualStudio.Component.CoreBuildTools ^ +--add Microsoft.VisualStudio.Workload.MSBuildTools ^ +--add Microsoft.VisualStudio.Component.Windows11SDK.22000 ^ +--add Microsoft.VisualStudio.Component.Windows10SDK.20348 ^ +--add Microsoft.VisualStudio.Component.Windows10SDK ^ +--passive --force --norestart +``` + +## CMD 环境 编译构建 + +```bat +cd c:\msys64\home\Administrator\php-sdk-binary-tools +phpsdk-vs17-x64.bat + +``` + +```bat +cd c:\msys64\home\Administrator\php-src +buildconf.bat +configure.bat --help +configure.bat --disable-all --enable-cli --enable-static=yes --enable-shared=no +nmake + + +x64\Release_TS\php.exe -v +x64\Release_TS\php.exe -m + +``` + +## 参考文档 + +1. [通过命令行使用 MSVC 工具集](https://learn.microsoft.com/zh-cn/cpp/build/building-on-the-command-line?view=msvc-170) +1. [通过命令行使用 MSBuild](https://learn.microsoft.com/zh-cn/cpp/build/msbuild-visual-cpp?view=msvc-1700) +1. [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) +1. [windows 环境下 构建 php 步骤](https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2) +1. [VisualStudio 导入或导出安装配置](https://learn.microsoft.com/zh-cn/visualstudio/install/import-export-installation-configurations?view=vs-2022) +1. [Visual Studio 2019 版本 16.11 发行说明](https://learn.microsoft.com/zh-cn/visualstudio/releases/2019/release-notes) +1. [Visual Studio 2022 版本 17.9 发行说明](https://learn.microsoft.com/zh-cn/visualstudio/releases/2022/release-notes) diff --git a/sapi/quickstart/windows/native-build/library/brotli.bat b/sapi/quickstart/windows/native-build/library/brotli.bat new file mode 100644 index 0000000000..ae136c1a03 --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/brotli.bat @@ -0,0 +1,30 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\brotli +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\brotli" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON ^ +-DBROTLI_DISABLE_TESTS=OFF ^ +-DBROTLI_BUNDLED_MODE=OFF + +cmake --build . --config Release --target install + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/curl.bat b/sapi/quickstart/windows/native-build/library/curl.bat new file mode 100644 index 0000000000..4d8dd1eb7e --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/curl.bat @@ -0,0 +1,41 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\curl +dir + +mkdir build +cd build +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\curl" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON ^ +-DSSL_ENABLED=ON ^ +-DUSE_ZLIB=ON ^ +-DUSE_OPENSSL=ON ^ +-DUSE_WOLFSSL=OFF ^ +-DUSE_GNUTLS=OFF ^ +-DUSE_MBEDTLS=OFF ^ +-DENABLE_WEBSOCKETS=OFF ^ +-DCURL_USE_LIBSSH2=ON ^ +-DCMAKE_PREFIX_PATH="%__PROJECT__%\OpenSSL\;%__PROJECT__%\zlib\;%__PROJECT__%\libssh2\" + + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/freetype.bat b/sapi/quickstart/windows/native-build/library/freetype.bat new file mode 100644 index 0000000000..f325be2b9f --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/freetype.bat @@ -0,0 +1,29 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\freetype +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\freetype" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/icu.bat b/sapi/quickstart/windows/native-build/library/icu.bat new file mode 100644 index 0000000000..99feae8fc7 --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/icu.bat @@ -0,0 +1,19 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +cd thirdparty\icu +dir + + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/libexpat.bat b/sapi/quickstart/windows/native-build/library/libexpat.bat new file mode 100644 index 0000000000..bb1ebb1345 --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/libexpat.bat @@ -0,0 +1,30 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\libexpat\expat\ +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\libssh2" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/liblz4.bat b/sapi/quickstart/windows/native-build/library/liblz4.bat new file mode 100644 index 0000000000..01df93a2df --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/liblz4.bat @@ -0,0 +1,32 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\liblz4\build\cmake\ +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\liblz4" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON ^ +-DLZ4_POSITION_INDEPENDENT_LIB=ON ^ +-DLZ4_BUILD_LEGACY_LZ4C=ON ^ +-DLZ4_BUILD_CLI=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/liblzma.bat b/sapi/quickstart/windows/native-build/library/liblzma.bat new file mode 100644 index 0000000000..fe95545062 --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/liblzma.bat @@ -0,0 +1,29 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\liblzma\ +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\liblzma" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/libpng.bat b/sapi/quickstart/windows/native-build/library/libpng.bat new file mode 100644 index 0000000000..9ff394bfa4 --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/libpng.bat @@ -0,0 +1,33 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\libpng +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\libpng" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON ^ +-DPNG_SHARED=OFF ^ +-DPNG_STATIC=ON ^ +-DPNG_TESTS=OFF ^ +-DCMAKE_PREFIX_PATH="%__PROJECT__%\build\zlib\" + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/libssh2.bat b/sapi/quickstart/windows/native-build/library/libssh2.bat new file mode 100644 index 0000000000..5aef498011 --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/libssh2.bat @@ -0,0 +1,41 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\libssh2 +dir +mkdir build +cd build +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\libssh2" ^ +-DCMAKE_POLICY_DEFAULT_CMP0074=NEW ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON ^ +-DENABLE_ZLIB_COMPRESSION=ON ^ +-DCLEAR_MEMORY=ON ^ +-DENABLE_GEX_NEW=ON ^ +-DENABLE_CRYPT_NONE=OFF ^ +-DCRYPTO_BACKEND=OpenSSL ^ +-DBUILD_TESTING=OFF ^ +-DBUILD_EXAMPLES=OFF ^ +-DOPENSSL_ROOT_DIR="%__PROJECT__%\build\openssl\" ^ +-DZLIB_ROOT="%__PROJECT__%\build\zlib\" ^ +-DCMAKE_PREFIX_PATH="%__PROJECT__%\build\zlib\;%__PROJECT__%\build\openssl\" + + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/libwebp.bat b/sapi/quickstart/windows/native-build/library/libwebp.bat new file mode 100644 index 0000000000..81d51f78de --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/libwebp.bat @@ -0,0 +1,29 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\libwebp +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\webp" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/libyaml.bat b/sapi/quickstart/windows/native-build/library/libyaml.bat new file mode 100644 index 0000000000..029400c702 --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/libyaml.bat @@ -0,0 +1,29 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\libyaml +dir +mkdir build +cd build +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\libyaml" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/libzip.bat b/sapi/quickstart/windows/native-build/library/libzip.bat new file mode 100644 index 0000000000..2560f356e3 --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/libzip.bat @@ -0,0 +1,29 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\libzip\ +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\libzip" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/libzstd.bat b/sapi/quickstart/windows/native-build/library/libzstd.bat new file mode 100644 index 0000000000..c783219b2c --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/libzstd.bat @@ -0,0 +1,29 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\libzstd\build\cmake\ +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\libzstd" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/nghttp2.bat b/sapi/quickstart/windows/native-build/library/nghttp2.bat new file mode 100644 index 0000000000..69244435ff --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/nghttp2.bat @@ -0,0 +1,28 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\nghttp2\ +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\nghttp2" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/nghttp3.bat b/sapi/quickstart/windows/native-build/library/nghttp3.bat new file mode 100644 index 0000000000..e53fd16029 --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/nghttp3.bat @@ -0,0 +1,29 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\nghttp3\ +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\nghttp3" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/ngtcp2.bat b/sapi/quickstart/windows/native-build/library/ngtcp2.bat new file mode 100644 index 0000000000..2ba837da8a --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/ngtcp2.bat @@ -0,0 +1,29 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd thirdparty\ngtcp2\ +dir +mkdir build-dir +cd build-dir +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\ngtcp2" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/openssl.bat b/sapi/quickstart/windows/native-build/library/openssl.bat new file mode 100644 index 0000000000..1ddd72ae5e --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/openssl.bat @@ -0,0 +1,37 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + + +set "PATH=%__PROJECT__%\nasm\;C:\Strawberry\perl\bin;%PATH%" + + + +cd /d %__PROJECT__%\thirdparty\openssl +dir +echo %cd% +perl -v + +perl Configure VC-WIN64A threads no-shared no-tests --release --prefix="%__PROJECT__%\build\openssl" --openssldir="%__PROJECT__%\build\openssl\ssl" + +set CL=/MP + +rem document +rem openssl\Configurations\windows-makefile.tmpl + +nmake install_sw + +rem fix no found file " openssl/applink.c " +copy %__PROJECT__%\thirdparty\openssl\ms\applink.c %__PROJECT__%\build\openssl\include\openssl\applink.c + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/library/zlib.bat b/sapi/quickstart/windows/native-build/library/zlib.bat new file mode 100644 index 0000000000..52851a9ee4 --- /dev/null +++ b/sapi/quickstart/windows/native-build/library/zlib.bat @@ -0,0 +1,34 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% +mkdir build + +set CMAKE_BUILD_PARALLEL_LEVEL=%NUMBER_OF_PROCESSORS% + +cd /d %__PROJECT__%\thirdparty\zlib +dir + +mkdir build + +cd build +dir +echo %cd% + +cmake .. ^ +-DCMAKE_INSTALL_PREFIX="%__PROJECT__%\build\zlib" ^ +-DCMAKE_BUILD_TYPE=Release ^ +-DBUILD_SHARED_LIBS=OFF ^ +-DBUILD_STATIC_LIBS=ON + +cmake --build . --config Release --target install + + +cd /d %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/msys2/README.md b/sapi/quickstart/windows/native-build/msys2/README.md new file mode 100644 index 0000000000..69e3a84fa3 --- /dev/null +++ b/sapi/quickstart/windows/native-build/msys2/README.md @@ -0,0 +1,24 @@ +# msys2 环境准备 + +## [安装 msys2 ](install-msys2.md) + +## 下载 msys2 环境 软件包 运行时 + + + +```bash + +# msys2 下载安装 git curl wget openssl zip unzip xz lzip 软件包 +bash sapi/quickstart/windows/native-build/msys2/msys2-install-soft.sh + + +# 准备 PHP 运行时 +bash sapi/quickstart/windows/native-build/msys2/msys2-download-php-runtime.sh + + +# 准备 依赖库 和 扩展 +bash sapi/quickstart/windows/native-build/msys2/msys2-download-source-code.sh + + + +``` diff --git a/sapi/quickstart/windows/native-build/msys2/download-msys2.bat b/sapi/quickstart/windows/native-build/msys2/download-msys2.bat new file mode 100644 index 0000000000..3ba34bd0d4 --- /dev/null +++ b/sapi/quickstart/windows/native-build/msys2/download-msys2.bat @@ -0,0 +1,6 @@ +@echo off +:: msys2 site: https://www.msys2.org/ + + +:: curl.exe -fSLo msys2-x86_64-20230526.exe https://mirror.msys2.org/distrib/x86_64/msys2-x86_64-20230526.exe +curl.exe -fSLo msys2-x86_64-20241208.exe https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20241208.exe diff --git a/sapi/quickstart/windows/install-msys2.md b/sapi/quickstart/windows/native-build/msys2/install-msys2.md similarity index 51% rename from sapi/quickstart/windows/install-msys2.md rename to sapi/quickstart/windows/native-build/msys2/install-msys2.md index 229f54fe44..d2a2ff2847 100644 --- a/sapi/quickstart/windows/install-msys2.md +++ b/sapi/quickstart/windows/native-build/msys2/install-msys2.md @@ -8,7 +8,9 @@ > 使用镜像站点 https://mirror.tuna.tsinghua.edu.cn/help/msys2/ 下载 msys2 安装包 -> https://mirrors.tuna.tsinghua.edu.cn/msys2/distrib/x86_64/msys2-x86_64-20230526.exe +> https://mirrors.tuna.tsinghua.edu.cn/msys2/distrib/x86_64/msys2-x86_64-20230526.exe (支持 win7 的最后一版本) + +> https://mirrors.tuna.tsinghua.edu.cn/msys2/distrib/x86_64/msys2-x86_64-20240507.exe > 安装 msys2 @@ -16,11 +18,11 @@ > MSYS2 包搜索 https://packages.msys2.org/queue -> [ msys2环境信息 ](https://www.msys2.org/docs/environments/) +> [ msys2 各版本环境 区别 ](https://www.msys2.org/docs/environments/) > msys2 集成了 Mingw 和 Cygwin ,同时还提供了包管理工具 `pacman` -### msys2 终端下 +## msys2 安装后初始化 ```shell # 换源 ( 不换源,不需要执行此条命令) @@ -29,31 +31,10 @@ sed -i "s#https\?://mirror.msys2.org/#https://mirrors.tuna.tsinghua.edu.cn/msys2 # 更新源 pacman -Syy --noconfirm # 无须确认安装包 -pacman -Syy --noconfirm git curl wget openssl zip unzip xz gcc gcc-g++ cmake make - -pacman -Syy --noconfirm openssl-devel libreadline - +pacman -Syy --noconfirm git # msys2 环境下 拉取 swoole-cli 源码 -git clone --recursive https://github.com:swoole/swoole-cli.git - -# msys2 环境下下载 cygwin (也可以用浏览器下载) 安装包 -wget https://cygwin.com/setup-x86_64.exe - -# 将 cygwin 安装包 移动到 window 指定盘符根目 (这里以 C盘为例) -mv setup-x86_64.exe C:/setup-x86_64.exe - - -``` - -### windows 自带默认终端 - -```shell - -# windows 开始菜单,打开 新的 windows 自带终端,执行安装 cygwin -cd c:\ +git clone --recursive https://github.com/swoole/swoole-cli.git -# 添加 pgsql -setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode --disable-buggy-antivirus --site https://mirrors.ustc.edu.cn/cygwin/ --packages libpq5 libpq-deve ``` diff --git a/sapi/quickstart/windows/native-build/msys2/msys2-download-php-runtime.sh b/sapi/quickstart/windows/native-build/msys2/msys2-download-php-runtime.sh new file mode 100644 index 0000000000..d7e3e3efd8 --- /dev/null +++ b/sapi/quickstart/windows/native-build/msys2/msys2-download-php-runtime.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +set -x + +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../../../ + pwd +) +cd ${__PROJECT__} + +# https://windows.php.net/downloads/releases/archives/ + +test -d php/ && rm -rf php/ +test -f php-8.2.19-nts-Win32-vs16-x64.zip || curl -Lo php-8.2.19-nts-Win32-vs16-x64.zip https://windows.php.net/downloads/releases/archives/php-8.2.19-nts-Win32-vs16-x64.zip + +unzip -d php php-8.2.19-nts-Win32-vs16-x64.zip + +pwd +cp -f php/php.ini-production php/php.ini + +mkdir -p bin/runtime/ +test -f bin/runtime/composer.phar || curl -Lo bin/runtime/composer.phar https://getcomposer.org/download/latest-stable/composer.phar +export PATH=$PATH:${__PROJECT__}/php/ + +php -v + +df -h / +PHP_EXT_DIR='' +if [[ -n "$GITHUB_WORKSPACE" ]] && [[ -n "$GITHUB_ACTION" ]] ; then + PHP_EXT_DIR=${GITHUB_WORKSPACE}'\php\ext\' +else + DISK_DRIVE=$( df -h / | sed -n '2p' | awk '{ print $1 }' )$(pwd) + echo $DISK_DRIVE + WIND_DIR=$(echo $DISK_DRIVE | sed 's/\//\\/g') + + # PHP_EXT_DIR='C:\msys64\home\Administrator\swoole-cli\php\ext\' + PHP_EXT_DIR=${WIND_DIR}'\php\ext\' + echo $PHP_EXT_DIR +fi + +while [ $# -gt 0 ]; do + case "$1" in + --php-ext-dir) + PHP_EXT_DIR="$2" + ;; + esac + shift $(($# > 0 ? 1 : 0)) +done + +#echo 'extension_dir=C:\msys64\home\Administrator\swoole-cli\php\ext\' >> php/php.ini +echo "extension_dir=${PHP_EXT_DIR}" >> php/php.ini +echo 'extension=php_curl.dll' >> php/php.ini +echo 'extension=php_bz2.dll' >> php/php.ini +echo 'extension=php_openssl.dll' >> php/php.ini +echo 'extension=php_fileinfo.dll' >> php/php.ini + +php -v +php -m +php bin/runtime/composer.phar install --no-interaction --no-autoloader --no-scripts --profile --ignore-platform-req=ext-posix --ignore-platform-req=ext-yaml +php bin/runtime/composer.phar dump-autoload --optimize --profile --ignore-platform-req=ext-posix --ignore-platform-req=ext-yaml diff --git a/sapi/quickstart/windows/native-build/msys2/msys2-download-source-code.sh b/sapi/quickstart/windows/native-build/msys2/msys2-download-source-code.sh new file mode 100644 index 0000000000..1010b6ead2 --- /dev/null +++ b/sapi/quickstart/windows/native-build/msys2/msys2-download-source-code.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -x + +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../../../ + pwd +) +cd ${__PROJECT__} + +test -d ext && rm -rf ext + +export PATH=$PATH:${__PROJECT__}/php/ + +php prepare.php --without-docker=1 --skip-download=1 --with-libavif=0 -swoole +swow -uuid +apcu +ds +xlswriter +ssh2 + +ls -lh var/download-box/ + +bash var/download-box/download_extension_use_git.sh +bash var/download-box/download_library_use_script_for_windows.sh +bash var/download-box/download_library_use_git.sh +bash sapi/download-box/download-box-dependencies-sync.sh +bash var/download-box/extract-files.sh + diff --git a/sapi/quickstart/windows/native-build/msys2/msys2-install-soft.sh b/sapi/quickstart/windows/native-build/msys2/msys2-install-soft.sh new file mode 100644 index 0000000000..b48e7d831c --- /dev/null +++ b/sapi/quickstart/windows/native-build/msys2/msys2-install-soft.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# 更新源 +pacman -Syy --noconfirm +# 无须确认安装包 +pacman -Syy --noconfirm git curl wget openssl zip unzip xz lzip +# pacman -Syy --noconfirm binutils + diff --git a/sapi/quickstart/windows/native-build/native-build-php-build.bat b/sapi/quickstart/windows/native-build/native-build-php-build.bat new file mode 100644 index 0000000000..e65f9ca0fa --- /dev/null +++ b/sapi/quickstart/windows/native-build/native-build-php-build.bat @@ -0,0 +1,61 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% +cd %__PROJECT__%\php-src\ + + + +rem set "INCLUDE=%INCLUDE%;%__PROJECT__%\build\openssl\include\;%__PROJECT__%\build\zlib\include" +rem set "LIB=%LIB%;%__PROJECT__%\build\openssl\lib\;%__PROJECT__%\build\zlib\lib" +rem set "LIBPATH=%LIBPATH%;%__PROJECT__%\build\openssl\lib\;%__PROJECT__%\build\zlib\lib\" + +echo %INCLUDE% +echo %LIB% +echo %LIBPATH% + +rem set "CFLAGS=/EHsc /MT " +rem set "LDFLAGS=/WHOLEARCHIVE /FORCE:MULTIPLE" + +configure.bat ^ +--disable-all --disable-cgi --enable-cli ^ +--enable-sockets --enable-ctype --enable-pdo --enable-phar ^ +--enable-filter ^ +--enable-xmlreader --enable-xmlwriter ^ +--enable-tokenizer + +:: --disable-zts ^ +:: --enable-apcu ^ +:: --enable-bcmath ^ +:: --enable-zlib ^ +:: --with-openssl=static ^ +:: --with-toolset=vs ^ +:: --with-extra-includes="%INCLUDE%" ^ +:: --with-extra-libs="%LIB%" + + +:: --enable-mbstring +:: --enable-redis ^ +:: --enable-phar-native-ssl +:: --enable-fileinfo +:: --with-curl=static + +cd /d %__PROJECT__% + + +rem cd %__PROJECT__%\php-src\x64\Release_TS\ +cd /d %__PROJECT__%\php-src\x64\Release\ +dir + +rem .\php -v +rem .\php -m + + +set __PROJECT__= +endlocal diff --git a/sapi/quickstart/windows/native-build/native-build-php-clean.bat b/sapi/quickstart/windows/native-build/native-build-php-clean.bat new file mode 100644 index 0000000000..2e0a72e3c9 --- /dev/null +++ b/sapi/quickstart/windows/native-build/native-build-php-clean.bat @@ -0,0 +1,15 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% +cd %__PROJECT__%\php-src\ + +nmake clean + +endlocal diff --git a/sapi/quickstart/windows/native-build/native-build-php-config.bat b/sapi/quickstart/windows/native-build/native-build-php-config.bat new file mode 100644 index 0000000000..d19bac3f2b --- /dev/null +++ b/sapi/quickstart/windows/native-build/native-build-php-config.bat @@ -0,0 +1,65 @@ +@echo off + +setlocal +rem show current file location +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% +cd /d %__PROJECT__%\var\windows-build-deps\php-src\ +echo %cd% + + + +buildconf.bat -f + +echo "====================" + +configure.bat --help + + + +rem set "INCLUDE=%INCLUDE%;%__PROJECT__%\build\openssl\include\;%__PROJECT__%\build\zlib\include" +rem set "LIB=%LIB%;%__PROJECT__%\build\openssl\lib\;%__PROJECT__%\build\zlib\lib" +rem set "LIBPATH=%LIBPATH%;%__PROJECT__%\build\openssl\lib\;%__PROJECT__%\build\zlib\lib\" + +echo %INCLUDE% +echo %LIB% +echo %LIBPATH% + +rem set "CFLAGS=/EHsc /MT " +rem set "LDFLAGS=/WHOLEARCHIVE /FORCE:MULTIPLE" + +configure.bat ^ +--disable-all --disable-cgi --enable-cli ^ +--enable-sockets --enable-ctype --enable-pdo --enable-phar ^ +--enable-filter ^ +--enable-xmlreader --enable-xmlwriter ^ +--enable-tokenizer + +:: --disable-zts ^ +:: --enable-apcu ^ +:: --enable-bcmath ^ +:: --enable-zlib ^ +:: --with-openssl=static ^ +:: --with-toolset=vs ^ +:: --with-extra-includes="%INCLUDE%" ^ +:: --with-extra-libs="%LIB%" + + +:: --enable-mbstring +:: --enable-redis ^ +:: --enable-phar-native-ssl +:: --enable-fileinfo +:: --with-curl=static + +cd /d %__PROJECT__% + + + + +cd %__PROJECT__% + +endlocal diff --git a/sapi/quickstart/windows/native-build/native-build-php-release-show-var.bat b/sapi/quickstart/windows/native-build/native-build-php-release-show-var.bat new file mode 100644 index 0000000000..6207286b62 --- /dev/null +++ b/sapi/quickstart/windows/native-build/native-build-php-release-show-var.bat @@ -0,0 +1,92 @@ +@echo off + +setlocal enabledelayedexpansion +rem show current file location +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% +cd %__PROJECT__%\php-src\ + +rem set "INCLUDE=%INCLUDE%;%__PROJECT__%\openssl\include\;%__PROJECT__%\zlib\include" +rem set "LIB=%LIB%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib" +rem set "LIBPATH=%LIBPATH%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib\" + +set CL=/MP +rem set RTLIBCFG=static +rem nmake mode=static debug=false + +rem nmake all + + +set x_makefile=%__PROJECT__%\php-src\Makefile + + + +findstr /C:"x-show-var: " %x_makefile% +findstr /C:"x-show-var: " %x_makefile% >nul + +if errorlevel 1 ( +echo custom makefile x-show-var config! +goto x-release-php-start +) else ( +echo custom makefile file exits ! +goto x-release-php-end +) + +:x-release-php-start +echo #x-show-var >> %x_makefile% +echo x-show-var: >> %x_makefile% +echo ^@echo DEPS_CLI: $(DEPS_CLI) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo CLI_GLOBAL_OBJ: $(CLI_GLOBAL_OBJS) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +rem echo ^@echo PHP_GLOBAL_OBJS: $(PHP_GLOBAL_OBJS) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +rem echo ^@echo STATIC_EXT_OBJS: $(STATIC_EXT_OBJS) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo ASM_OBJS: $(ASM_OBJS) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo STATIC_EXT_LIBS: $(STATIC_EXT_LIBS) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo STATIC_EXT_LDFLAGS: $(STATIC_EXT_LDFLAGS) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo STATIC_EXT_CFLAGS: $(STATIC_EXT_CFLAGS) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo BUILD_DIR\PHPLIB: $(BUILD_DIR)\$(PHPLIB) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo CLI_GLOBAL_OBJS_RESP: $(CLI_GLOBAL_OBJS_RESP) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo PHP_LDFLAGS: $(PHP_LDFLAGS) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo LIBS: $(LIBS) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo LIBS_CLI: $(LIBS_CLI) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo LDFLAGS: $(LDFLAGS) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo LDFLAGS_CLI: $(LDFLAGS_CLI) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo _VC_MANIFEST_EMBED_EXE: $(_VC_MANIFEST_EMBED_EXE) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo PHPDEF: $(PHPDEF) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo PHPDLL_RES: $(PHPDLL_RES) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo ASM_OBJS: $(ASM_OBJS) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% +echo ^@echo MCFILE: $(MCFILE) >> %x_makefile% +echo ^@echo ================== >> %x_makefile% + +:x-release-php-end + + +rem nmake show-variable +nmake x-show-var + +rem nmake install + +cd %__PROJECT__% +endlocal diff --git a/sapi/quickstart/windows/native-build/native-build-php-release.bat b/sapi/quickstart/windows/native-build/native-build-php-release.bat new file mode 100644 index 0000000000..f381fad265 --- /dev/null +++ b/sapi/quickstart/windows/native-build/native-build-php-release.bat @@ -0,0 +1,75 @@ +@echo off + +setlocal enabledelayedexpansion +rem show current file location +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% +cd %__PROJECT__%\php-src\ + +rem set "INCLUDE=%INCLUDE%;%__PROJECT__%\openssl\include\;%__PROJECT__%\zlib\include" +rem set "LIB=%LIB%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib" +rem set "LIBPATH=%LIBPATH%;%__PROJECT__%\openssl\lib\;%__PROJECT__%\zlib\lib\" + +set CL=/MP +rem set RTLIBCFG=static +rem nmake mode=static debug=false + +rem nmake all + + +set x_makefile=%__PROJECT__%\php-src\Makefile + + + +findstr /C:"x-release-php: " %x_makefile% +findstr /C:"x-release-php: " %x_makefile% >nul + +if errorlevel 1 ( +echo custom makefile x-release-php config! +goto x-release-php-start +) else ( +echo custom makefile file exits ! +goto x-release-php-end +) + +:x-release-php-start +echo #custom build static link php library >> %x_makefile% +echo x-build-php-lib^: generated_files $(PHP_GLOBAL_OBJS) $(CLI_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(MCFILE) >> %x_makefile% +echo #custom build php.exe >> %x_makefile% +echo x-release-php^: $(DEPS_CLI) $(CLI_GLOBAL_OBJS) x-build-php-lib $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(BUILD_DIR)^\php.exe.res $(BUILD_DIR)^\php.exe.manifest >> %x_makefile% +rem https://www.cnblogs.com/sherry-best/archive/2013/04/15/3022705.html +rem https://learn.microsoft.com/zh-CN/cpp/c-runtime-library/crt-library-features?view=msvc-170&viewFallbackFrom=vs-2019 +rem echo ^@"$(LINK)" ^/nologo $(PHP_GLOBAL_OBJS) $(PHP_GLOBAL_OBJS_RESP) $(CLI_GLOBAL_OBJS) $(CLI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)^\php.exe.res /out:$(BUILD_DIR)^\php.exe $(LDFLAGS) $(LDFLAGS_CLI) >> %x_makefile% +rem echo ^@"$(LINK)" ^/nologo $(DEPS_CLI) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)^\php.exe.res /out:$(BUILD_DIR)^\php.exe $(LDFLAGS) $(LDFLAGS_CLI) >> %x_makefile% +rem echo -@$(_VC_MANIFEST_EMBED_EXE) >> %x_makefile% +rem echo ^@echo SAPI sapi\cli build complete >> %x_makefile% +rem echo @if exist php.exe.manifest $(MT) -nologo -manifest php.exe.manifest -outputresource:php.exe >> %x_makefile% + +rem /WHOLEARCHIVE /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib /FORCE:MULTIPLE +rem libcpmt.lib libvcruntime.lib libucrt.lib msvcrt.lib +rem /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib +rem libvcruntime.lib libcmt.lib + +rem /MANIFEST:php.exe.manifest /MANIFESTUAC:uiAccess /SUBSYSTEM:CONSOLE /subsystem:windows + +:x-release-php-end + + +rem nmake show-variable +rem nmake /E x-release-php +nmake /E php.exe +rem nmake x-build-php-lib + +rem nmake install + +.\x64\Release\php.exe -v +.\x64\Release\php.exe -m +dumpbin /DEPENDENTS ".\x64\Release\php.exe" + +cd %__PROJECT__% +endlocal + diff --git a/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2019.bat b/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2019.bat new file mode 100644 index 0000000000..caff661c75 --- /dev/null +++ b/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2019.bat @@ -0,0 +1,30 @@ +@echo off + +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% + +rem %__PROJECT__%\php-sdk-binary-tools\phpsdk-vs16-x64.bat + + +set PHP_SDK_ARCH=x64 +set PHP_SDK_BIN_PATH=%__PROJECT__%\php-sdk-binary-tools\bin\ +set PHP_SDK_MSYS2_PATH=%__PROJECT__%\php-sdk-binary-tools\msys2\usr\bin\ +set PHP_SDK_OS_ARCH=x64 +set PHP_SDK_PHP_CMD=%__PROJECT__%\php-sdk-binary-tools\bin\php\do_php.bat +set PHP_SDK_ROOT_PATH=%__PROJECT__%\php-sdk-binary-tools\ +set "PHP_SDK_VC_DIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC" +set "PHP_SDK_VC_TOOLSET_VER=%VCToolsVersion%" +set PHP_SDK_VS=vs16 +set PHP_SDK_VS_NUM=16 +set "PHP_SDK_VS_SHELL_CMD=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat amd64" +set "PATH=%__PROJECT__%\php-sdk-binary-tools\bin;%__PROJECT__%\php-sdk-binary-tools\msys2\usr\bin;%__PROJECT__%\php\;%__PROJECT__%\nasm\;C:\Strawberry\perl\bin;C:\Program Files\Git\bin;%PATH%" +echo %PATH% + +cd /d %__PROJECT__% + +set __PROJECT__= diff --git a/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2022.bat b/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2022.bat new file mode 100644 index 0000000000..22156b5a49 --- /dev/null +++ b/sapi/quickstart/windows/native-build/native-build-php-sdk-vs2022.bat @@ -0,0 +1,30 @@ +@echo off + +rem show current file location +echo %~dp0 +cd %~dp0 +cd ..\..\..\..\ + +set __PROJECT__=%cd% +cd /d %__PROJECT__% + +rem %__PROJECT__%\php-sdk-binary-tools\phpsdk-vs17-x64.bat + + +set PHP_SDK_ARCH=x64 +set PHP_SDK_BIN_PATH=%__PROJECT__%\php-sdk-binary-tools\bin\ +set PHP_SDK_MSYS2_PATH=%__PROJECT__%\php-sdk-binary-tools\msys2\usr\bin\ +set PHP_SDK_OS_ARCH=x64 +set PHP_SDK_PHP_CMD=%__PROJECT__%\php-sdk-binary-tools\bin\php\do_php.bat +set PHP_SDK_ROOT_PATH=%__PROJECT__%\php-sdk-binary-tools\ +set "PHP_SDK_VC_DIR=C:\Program Files\Microsoft Visual Studio\2022\Community\VC" +set "PHP_SDK_VC_TOOLSET_VER=%VCToolsVersion%" +set PHP_SDK_VS=vs17 +set PHP_SDK_VS_NUM=17 +set "PHP_SDK_VS_SHELL_CMD=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat amd64" +set "PATH=%__PROJECT__%\php-sdk-binary-tools\bin;%__PROJECT__%\php-sdk-binary-tools\msys2\usr\bin;%PATH%" +echo %PATH% + +cd /d %__PROJECT__% + +set __PROJECT__= diff --git a/sapi/quickstart/windows/native-build/windows-init-download-helper-soft.bat b/sapi/quickstart/windows/native-build/windows-init-download-helper-soft.bat new file mode 100644 index 0000000000..9c31d43c60 --- /dev/null +++ b/sapi/quickstart/windows/native-build/windows-init-download-helper-soft.bat @@ -0,0 +1,36 @@ +setlocal + + +echo %~dp0 +cd /d %~dp0 +cd /d .\..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-build-deps\ + +cd /d %__PROJECT__%\var\windows-build-deps\ + +:: set http_proxy=http://127.0.0.1:8016 +:: set https_proxy=http://127.0.0.1:8016 + + +curl.exe -fSLo npp.8.6.7.Installer.x64.exe https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.6.7/npp.8.6.7.Installer.x64.exe +curl.exe -fSLo socat-v1.8.0.1-cygwin-x64.zip https://github.com/jingjingxyk/build-static-socat/releases/download/v2.2.1/socat-v1.8.0.1-cygwin-x64.zip +curl.exe -fSLo Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle https://github.com/microsoft/terminal/releases/download/v1.21.3231.0/Microsoft.WindowsTerminal_1.21.3231.0_8wekyb3d8bbwe.msixbundle +curl.exe -fSLo winget-install.ps1 https://github.com/asheroto/winget-install/releases/latest/download/winget-install.ps1 +curl.exe -fSLo chocolatey-install.ps1 https://community.chocolatey.org/install.ps1 +curl.exe -fSLo scoop-install.ps1 https://get.scoop.sh + + + + + +:: curl.exe -fSLo npp.8.6.7.Installer.x64.exe https://php-cli.jingjingxyk.com/npp.8.6.7.Installer.x64.exe +:: curl.exe -fSLo socat-v1.8.0.1-cygwin-x64.zip https://php-cli.jingjingxyk.com/socat-v1.8.0.1-cygwin-x64.zip + +:: curl.exe -fSLo curl-8.11.1_1-win64-mingw.zip https://curl.se/windows/dl-8.11.1_1/curl-8.11.1_1-win64-mingw.zip +:: curl.exe -fSLo curl-8.11.1_1-win64arm-mingw.zip https://curl.se/windows/dl-8.11.1_1/curl-8.11.1_1-win64a-mingw.zip + +endlocal diff --git a/sapi/quickstart/windows/native-build/windows-init-download.bat b/sapi/quickstart/windows/native-build/windows-init-download.bat new file mode 100644 index 0000000000..125a6d01c2 --- /dev/null +++ b/sapi/quickstart/windows/native-build/windows-init-download.bat @@ -0,0 +1,50 @@ +setlocal + + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-build-deps\ + +cd /d %__PROJECT__%\var\windows-build-deps\ + +:: set http_proxy=http://127.0.0.1:8016 +:: set https_proxy=http://127.0.0.1:8016 + +curl.exe -fSLo Git-2.47.1-64-bit.exe https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/Git-2.47.1-64-bit.exe +curl.exe -fSLo strawberry-perl-5.38.2.2-64bit.msi https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_53822_64bit/strawberry-perl-5.38.2.2-64bit.msi +curl.exe -fSLo nasm-2.16.03-win64.zip https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/win64/nasm-2.16.03-win64.zip +curl.exe -fSLo 7z2409-x64.exe https://www.7-zip.org/a/7z2409-x64.exe +curl.exe -fSLo libarchive-v3.7.4-amd64.zip https://libarchive.org/downloads/libarchive-v3.7.4-amd64.zip + +:: vs2019 +:: curl -Lo VisualStudioSetup.exe 'https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2019' +:: curl -Lo VisualStudioSetup.exe 'https://aka.ms/vs/16/release/vs_community.exe' + +:: vs2022 +curl.exe -fSLo vc_redist.x64.exe https://aka.ms/vs/17/release/vc_redist.x64.exe +:: curl -fSL VisualStudioSetup.exe 'https://aka.ms/vs/17/release/vs_community.exe' +curl.exe -fSLo VisualStudioSetup.exe "https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022" + + +:: "https://windows.php.net/downloads/releases/php-8.4.1-nts-Win32-vs17-x64.zip" +curl.exe -fSLo php-nts-Win32-x64.zip "https://windows.php.net/downloads/releases/php-8.3.14-nts-Win32-vs16-x64.zip" +curl.exe -fSLo composer.phar "https://getcomposer.org/download/latest-stable/composer.phar" +curl.exe -fSLo cacert.pem "https://curl.se/ca/cacert.pem" + +git clone -b master --depth=1 https://github.com/php/php-sdk-binary-tools.git +git clone -b php-8.4.1 --depth=1 https://github.com/php/php-src.git + + +:: with mirror +:: curl.exe -fSLo Git-2.47.1-64-bit.exe https://php-cli.jingjingxyk.com/Git-2.47.1-64-bit.exe +:: curl.exe -fSLo 7z2409-x64.exe https://php-cli.jingjingxyk.com/7z2409-x64.exe +:: curl.exe -fSLo nasm-2.16.03-win64.zip https://php-cli.jingjingxyk.com/nasm-2.16.03-win64.zip + + + +endlocal diff --git a/sapi/quickstart/windows/native-build/windows-init-install-helper-soft.bat b/sapi/quickstart/windows/native-build/windows-init-install-helper-soft.bat new file mode 100644 index 0000000000..8dd385e55d --- /dev/null +++ b/sapi/quickstart/windows/native-build/windows-init-install-helper-soft.bat @@ -0,0 +1,32 @@ +setlocal + + +echo %~dp0 +cd /d %~dp0 +cd /d .\..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-build-deps\ + +cd /d %__PROJECT__%\var\windows-build-deps\ + +rem start /wait .\Git-2.47.1-64-bit.exe /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEONEXIT=1 /DIR="C:\Program Files\Git" + +:: 设置Git安装路径 +set "INSTALL_PATH=C:\Program Files\Git" + +:: 创建安装目录 +if not exist "%INSTALL_PATH%" mkdir "%INSTALL_PATH%" + +:: 静默安装Git +:: 查看git 安装参数 +:: .\Git-2.47.1-64-bit.exe /? +:: start /wait "" "%__PROJECT__%\var\windows-build-deps\Git-2.47.1-64-bit.exe" /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEONEXIT=1 /DIR="%INSTALL_PATH%" + + + + + +endlocal diff --git a/sapi/quickstart/windows/native-build/windows-init-install-vs-tools.bat b/sapi/quickstart/windows/native-build/windows-init-install-vs-tools.bat new file mode 100644 index 0000000000..51bdf2adca --- /dev/null +++ b/sapi/quickstart/windows/native-build/windows-init-install-vs-tools.bat @@ -0,0 +1,39 @@ +@echo off + +setlocal + + +echo %~dp0 + + +cd /d %~dp0 +cd /d ..\..\..\..\ + + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-build-deps\ + + +cd /d %__PROJECT__%\var\windows-build-deps\ +dir + +.\VisualStudioSetup.exe ^ +--locale en-US ^ +--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^ +--add Microsoft.VisualStudio.Component.VC.Modules.x86.x64 ^ +--add Microsoft.VisualStudio.Component.VC.CMake.Project ^ +--add Microsoft.VisualStudio.Component.Roslyn.Compiler ^ +--add Microsoft.VisualStudio.Component.CoreBuildTools ^ +--add Microsoft.VisualStudio.Component.Windows10SDK.20348 ^ +--add Microsoft.VisualStudio.Component.Windows10SDK ^ +--add Microsoft.VisualStudio.Component.Windows11SDK.22000 ^ +--add Microsoft.Component.VC.Runtime.UCRTSDK ^ +--add Microsoft.Component.MSBuild ^ +--add Microsoft.VisualStudio.Workload.MSBuildTools ^ +--add Microsoft.VisualStudio.Workload.NativeDesktop ^ +--path install="D:\vs" --path cache="D:\vs-cached" ^ +--passive --force --norestart + +endlocal diff --git a/sapi/quickstart/windows/native-build/windows-init-install.bat b/sapi/quickstart/windows/native-build/windows-init-install.bat new file mode 100644 index 0000000000..82076498b0 --- /dev/null +++ b/sapi/quickstart/windows/native-build/windows-init-install.bat @@ -0,0 +1,134 @@ +@echo off + +setlocal + + +echo %~dp0 + + +cd /d %~dp0 +cd /d ..\..\..\..\ + + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-build-deps\ +md %__PROJECT__%\bin\runtime\ + +cd /d %__PROJECT__%\var\windows-build-deps\ +dir + + +msiexec /i strawberry-perl-5.38.2.2-64bit.msi /passive + +.\vc_redist.x64.exe /install /passive /norestart + +.\7z2409-x64.exe /S + + +set "PATH=%ProgramFiles%\7-Zip;%PATH%;" +echo "%PATH%" +echo %ProgramFiles%\7-Zip + +cd /d %__PROJECT__%\bin\runtime\ +if exist ".\nasm\" ( + rd /s /q ".\nasm\" +) + +if exist ".\libarchive\" ( + rd /s /q ".\libarchive\" +) + +if exist ".\php\" ( + rd /s /q ".\php\" +) + +cd /d %__PROJECT__%\var\windows-build-deps\ + +call + +if exist ".\nasm\" ( + rmdir /s /q ".\nasm\" +) +if exist ".\libarchive\" ( + rmdir /s /q ".\libarchive\" +) + +if exist ".\php-nts-Win32-x64" ( + rmdir /s /q ".\php-nts-Win32-x64" +) + +cd /d %__PROJECT__%\var\windows-build-deps\ + +7z.exe x -onasm nasm-2.16.03-win64.zip +7z.exe x -ophp-nts-Win32-x64 php-nts-Win32-x64.zip +7z.exe x -olibarchive libarchive-v3.7.4-amd64.zip + +move nasm\nasm-2.16.03 %__PROJECT__%\bin\runtime\nasm +move libarchive\libarchive %__PROJECT__%\bin\runtime\libarchive +move php-nts-Win32-x64 %__PROJECT__%\bin\runtime\php +move cacert.pem %__PROJECT__%\bin\runtime\cacert.pem + +( +echo extension_dir="%__PROJECT__%\bin\runtime\php\ext\" +echo extension=php_curl.dll +echo extension=php_bz2.dll +echo extension=php_openssl.dll +echo extension=php_fileinfo.dll +echo extension=php_exif.dll +echo extension=php_gd.dll +echo extension=php_gettext.dll +echo extension=php_gmp.dll +echo extension=php_intl.dll +echo extension=php_mbstring.dll +echo extension=php_pdo_mysql.dll +echo extension=php_pdo_pgsql.dll +echo extension=php_sqlite3.dll +echo extension=php_sockets.dll +echo extension=php_sodium.dll +echo extension=php_xsl.dll +echo extension=php_zip.dll + +echo curl.cainfo="%__PROJECT__%\bin\runtime\cacert.pem" +echo openssl.cafile="%__PROJECT__%\bin\runtime\cacert.pem" +echo display_errors = On +echo error_reporting = E_ALL + +echo upload_max_filesize="128M" +echo post_max_size="128M" +echo memory_limit="1G" +echo date.timezone="UTC" + +echo opcache.enable_cli=1 +echo opcache.jit=1254 +echo opcache.jit_buffer_size=480M + +echo expose_php=Off +echo apc.enable_cli=1 + +) > %__PROJECT__%\bin\runtime\php.ini + + + +echo %comspec% +echo %ProgramFiles% +set "PATH=%ProgramFiles%\Git\bin;%__PROJECT__%\bin\runtime\;%__PROJECT__%\bin\runtime\nasm\;%__PROJECT__%\bin\runtime\php;%__PROJECT__%\bin\runtime\libarchive\bin;%PATH%" +echo "%PATH%" + +:: git config --global core.autocrlf false +:: git config --global core.eol lf +:: git config --global core.ignorecase false + +perl -v +nasm -v +git version +curl -V +php -v +php -c %__PROJECT__%\bin\runtime\php.ini -m +php -c %__PROJECT__%\bin\runtime\php.ini --ri curl + + + + +endlocal diff --git a/sapi/quickstart/windows/native-build/windows-init-uninstall-vs-tools.bat b/sapi/quickstart/windows/native-build/windows-init-uninstall-vs-tools.bat new file mode 100644 index 0000000000..24796a3f13 --- /dev/null +++ b/sapi/quickstart/windows/native-build/windows-init-uninstall-vs-tools.bat @@ -0,0 +1,27 @@ +@echo off + +setlocal + + +echo %~dp0 + + +cd /d %~dp0 +cd /d ..\..\..\..\ + + +set "__PROJECT__=%cd%" +echo %cd% + +md %__PROJECT__%\var\windows-build-deps\ + + +cd /d %__PROJECT__%\var\windows-build-deps\ +dir + +.\VisualStudioSetup.exe ^ +uninstall ^ +--path install="D:\vs" --path cache="D:\vs-cached" ^ +--passive --force --norestart + +endlocal diff --git a/sapi/quickstart/windows/native-build/windows-init.bat b/sapi/quickstart/windows/native-build/windows-init.bat new file mode 100644 index 0000000000..dc66b79d2d --- /dev/null +++ b/sapi/quickstart/windows/native-build/windows-init.bat @@ -0,0 +1,23 @@ +@echo off + +setlocal + + +echo %~dp0 +cd /d %~dp0 +cd /d ..\..\..\..\ + +set "__PROJECT__=%cd%" +echo %cd% + + +if not exist "%__PROJECT__%\var\windows-build-deps\php-nts-Win32-x64.zip" ( + echo "windows php runtime no found " + call "%__PROJECT__%\sapi\quickstart\windows\native-build\windows-init-download.bat" +) + +call "%__PROJECT__%\sapi\quickstart\windows\native-build\windows-init-install.bat" +rem call "%__PROJECT__%\sapi\quickstart\windows\native-build\windows-init-install-vs-tools.bat" +rem call "%__PROJECT__%\sapi\quickstart\windows\native-build\windows-init-uninstall-vs-tools.bat" + +endlocal diff --git a/sapi/quickstart/windows/windows-native.md b/sapi/quickstart/windows/windows-native.md deleted file mode 100644 index 718f8acb53..0000000000 --- a/sapi/quickstart/windows/windows-native.md +++ /dev/null @@ -1,31 +0,0 @@ -# 构建window PHP 工具 和 参考 - -[ download windows PHP ](https://windows.php.net/download#php-8.2) - -[windows build php 步骤](https://wiki.php.net/internals/windows/stepbystepbuild) - -```shell -git config core.ignorecase false # 设置 Git 在 Windows 上也区分大小写 -``` - -Latest VC++ -https://learn.microsoft.com/en-AU/cpp/windows/latest-supported-vc-redist - -7zip -https://7-zip.org/ - -visualstudio -https://visualstudio.microsoft.com/zh-hans/downloads/ - -windows-sdk -https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ - -Windows PowerShell ISE 文本编辑器 - -## 使用命令行快速安装 VisualStudio 组件 - -```shell - -VisualStudioSetup.exe --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Component.VC.ATLMFC --includeRecommended - -``` diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index eea6a830e7..729d732029 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -156,14 +156,18 @@ public function getOsType(): string public function getSystemArch(): string { - $uname = posix_uname(); - switch ($uname['machine']) { - case 'x86_64': - return 'x64'; - case 'aarch64': - return 'arm64'; - default: - return $uname['machine']; + if (function_exists('posix_uname')) { + $uname = posix_uname(); + switch ($uname['machine']) { + case 'x86_64': + return 'x64'; + case 'aarch64': + return 'arm64'; + default: + return $uname['machine']; + } + } else { + return 'x64'; } } diff --git a/sapi/src/PreprocessorTrait/DownloadBoxTrait.php b/sapi/src/PreprocessorTrait/DownloadBoxTrait.php index f6d30855a5..a99e1dd490 100644 --- a/sapi/src/PreprocessorTrait/DownloadBoxTrait.php +++ b/sapi/src/PreprocessorTrait/DownloadBoxTrait.php @@ -25,14 +25,29 @@ trait DownloadBoxTrait protected function generateDownloadLinks(): void { + $retry_number = DOWNLOAD_FILE_RETRY_NUMBE; + $wait_retry = DOWNLOAD_FILE_WAIT_RETRY; + $connect_timeout = DOWNLOAD_FILE_CONNECTION_TIMEOUT; + $this->mkdirIfNotExists($this->getRootDir() . '/var/download-box/', 0755, true); + $download_commands = ['POOL=$(realpath ${__DIR__}/../../pool/)']; + $download_commands[] = PHP_EOL; + + $extract_files = ['set -x']; + $extract_files[] = PHP_EOL; + $download_urls = []; foreach ($this->extensionMap as $item) { echo $item->name . PHP_EOL; if ((!empty($item->peclVersion) || !empty($item->url)) || $item->enableDownloadWithMirrorURL) { $download_urls[] = $item->url . PHP_EOL . " out=" . $item->file; + + $download_commands[] = "test -f \${POOL}/ext/{$item->file} || curl --connect-timeout {$connect_timeout} --retry {$retry_number} --retry-delay {$wait_retry} -Lo ext/{$item->file} {$item->url}" . PHP_EOL; + + $extract_files[] = "mkdir -p ext/{$item->name}" . PHP_EOL; + $extract_files[] = "tar --strip-components=1 -C ext/{$item->name} -xf pool/ext/{$item->file}" . PHP_EOL; } } file_put_contents($this->getRootDir() . '/var/download-box/download_extension_urls.txt', implode(PHP_EOL, $download_urls)); @@ -57,6 +72,10 @@ protected function generateDownloadLinks(): void EOF; $download_scripts[] = $downloadScript . PHP_EOL; + + $extract_files[] = "mkdir -p ext/{$item->name}" . PHP_EOL; + $extract_files[] = "tar --strip-components=1 -C ext/{$item->name} -xf pool/ext/{$item->file}" . PHP_EOL; + } } file_put_contents( @@ -78,9 +97,22 @@ protected function generateDownloadLinks(): void $url = implode("\t", $newMirrorUrls); } $download_urls[] = $url . PHP_EOL . " out=" . $item->file; + + $download_commands[] = "test -f \${POOL}/lib/{$item->file} || curl --connect-timeout {$connect_timeout} --retry {$retry_number} --retry-delay {$wait_retry} -Lo lib/{$item->file} {$item->url}" . PHP_EOL; + + $extract_files[] = "mkdir -p thirdparty/{$item->name}" . PHP_EOL; + $extract_files[] = "tar --strip-components=1 -C thirdparty/{$item->name} -xf pool/lib/{$item->file}" . PHP_EOL; + } } - file_put_contents($this->getRootDir() . '/var/download-box/download_library_urls.txt', implode(PHP_EOL, $download_urls)); + file_put_contents($this->getRootDir() . '/var/download-box/download_library_urls.txt', + implode(PHP_EOL, $download_urls) + ); + file_put_contents( + $this->rootDir . '/var/download-box/download_library_use_script_for_windows.sh', + $this->downloadScriptHeader . PHP_EOL . + implode(PHP_EOL, $download_commands) + ); $download_scripts = []; @@ -103,6 +135,11 @@ protected function generateDownloadLinks(): void EOF; $download_scripts[] = $downloadScript . PHP_EOL; + + + $extract_files[] = "mkdir -p thirdparty/{$item->name}" . PHP_EOL; + $extract_files[] = "tar --strip-components=1 -C thirdparty/{$item->name} -xf pool/lib/{$item->file}" . PHP_EOL; + } } file_put_contents( @@ -110,5 +147,11 @@ protected function generateDownloadLinks(): void $this->downloadScriptHeader . PHP_EOL . implode(PHP_EOL, $download_scripts) ); + + file_put_contents( + $this->rootDir . '/var/download-box/extract-files.sh', + implode(PHP_EOL, $extract_files) + ); + } } diff --git a/sapi/src/builder/extension/swow.php b/sapi/src/builder/extension/swow.php index 5f8ba1895d..2c2ada11bf 100644 --- a/sapi/src/builder/extension/swow.php +++ b/sapi/src/builder/extension/swow.php @@ -28,6 +28,7 @@ mv swow swow-t mv swow-t/ext swow rm -rf swow-t + EOF ) ->withBuildCached(false) diff --git a/setup-php-runtime.ps1 b/setup-php-runtime.ps1 new file mode 100644 index 0000000000..1338911126 --- /dev/null +++ b/setup-php-runtime.ps1 @@ -0,0 +1,99 @@ +Set-PSDebug -Strict +$__PROJECT__ = (Get-Location).Path +$__PROJECT__ = $PSScriptRoot + +# 获得当前脚本所在目录 +$__PROJECT__ = Split-Path -Parent $MyInvocation.MyCommand.Definition + +cmd /c $__PROJECT__\sapi\quickstart\windows\native-build\windows-init.bat + +cd $__PROJECT__ + + + +exit + +.\bin\runtime\php\php.exe -c .\bin\runtime\php.ini .\bin\runtime\composer.phar config -g repos.packagist composer https://mirrors.tencent.com/composer/ +.\bin\runtime\php\php.exe -c .\bin\runtime\php.ini .\bin\runtime\composer.phar update +.\bin\runtime\php\php.exe -c .\bin\runtime\php.ini .\bin\runtime\composer.pharr config -g repos.packagist composer https://packagist.org + + +.\sapi\quickstart\windows\native-build\build-static-php.ps1 + +exit + + +Write-Host $HOME + + +dir $HOME\AppData\Local\Microsoft\WindowsApps + +cmd /c dir %USERPROFILE%\AppData\Local\Microsoft\WindowsApps +cmd /c echo %USERPROFILE% +cmd /c echo %HOMEDRIVE% +cmd /c echo %HOMEPATH% +cmd /c echo %ProgramFiles% +cmd /c echo %NUMBER_OF_PROCESSORS% + +dir C:\Windows\System32\OpenSSH\ +cmd /c echo %SYSTEMROOT%\System32\OpenSSH\ +cmd /c dir %SYSTEMROOT%\System32\OpenSSH\ + +cmd /c where curl.exe + +exit +$env:PATH = "$env:PATH;%ProgramFiles%\7-Zip" + +# 执行需要使用临时 PATH 的命令 +# 例如 +# cmd /c echo %PATH% + +# 在会话结束时移除临时添加的路径 +$env:PATH = $env:PATH.Replace(";%ProgramFiles%\7-Zip", "") + + +New-Item -ItemType Directory -Path "$__PROJECT__\var\runtime\" -Force | Out-Null + +# Set-Location -Path "$__PROJECT__\var\runtime\" + + + + +# $env:http_proxy = "http://127.0.0.1:8016" +# $env:https_proxy = "http://127.0.0.1:8016" + +Write-Host "HTTP Proxy: $env:http_proxy" +Write-Host "HTTPS Proxy: $env:https_proxy" + + +# $OutputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 + + +$client = new-object System.Net.WebClient +$client.DownloadFile("https://www.7-zip.org/a/7z2409-x64.exe", "7z2409-x64.exe") + + + +$newPath = "C:\Program Files\7-Zip" +# 检查PATH中是否已存在该路径 +if (-not ($env:PATH.Contains($newPath))) +{ + # $env:PATH = $env:PATH + ";" + $newPath + # Write-Host "--------------------" +} +$originalPath = $env:PATH +$newPath = "C:\Program Files\7-Zip" +$env:PATH = "$newPath;$env:PATH" +Write-Output $env:PATH +# $env:PATH = $originalPath + + +cd $__PROJECT__\var\runtime\ + +# (Test-Path -Path .\php-8.4.1-nts-Win32-vs17-x64) -and (Remove-Item -Path .\php-8.4.1-nts-Win32-vs17-x64 -Recurse) +# (Test-Path -Path .\php-8.4.1-nts-Win32-vs17-x64.zip) -and ( 7z x o php-8.4.1-nts-Win32-vs17-x64 .\php-8.4.1-nts-Win32-vs17-x64.zip) + +cd $__PROJECT__ + + +set-PSDebug -Off