Skip to content

Commit adec656

Browse files
committed
#22: % update build-cross-platform.yml 6
1 parent 650fc3d commit adec656

File tree

1 file changed

+152
-77
lines changed

1 file changed

+152
-77
lines changed

.github/workflows/build-cross-platform.yml

Lines changed: 152 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ jobs:
181181
platform: macos
182182

183183
runs-on: ${{ matrix.os }}
184+
185+
env:
186+
# Windows specific environment (only for windows)
187+
PHP_BUILD_CACHE_BASE_DIR: ${{ matrix.os == 'windows-latest' && 'C:\build-cache' || '' }}
188+
PHP_BUILD_OBJ_DIR: ${{ matrix.os == 'windows-latest' && 'C:\obj' || '' }}
189+
PHP_BUILD_CACHE_SDK_DIR: ${{ matrix.os == 'windows-latest' && 'C:\build-cache\sdk' || '' }}
190+
PHP_BUILD_SDK_BRANCH: ${{ matrix.os == 'windows-latest' && 'php-sdk-2.3.0' || '' }}
191+
PHP_BUILD_CRT: ${{ matrix.os == 'windows-latest' && 'vs17' || '' }}
192+
PLATFORM: ${{ matrix.os == 'windows-latest' && 'x64' || '' }}
193+
THREAD_SAFE: ${{ matrix.os == 'windows-latest' && '1' || '' }}
184194

185195

186196
steps:
@@ -198,107 +208,172 @@ jobs:
198208
mkdir -p php-src/ext/async
199209
cp -r async/* php-src/ext/async/
200210
201-
# ==================== WINDOWS DEPENDENCIES ====================
202-
- name: Install build dependencies (Windows)
211+
# ==================== WINDOWS BUILD (Official PHP approach) ====================
212+
- name: git config
203213
if: matrix.os == 'windows-latest'
204-
run: |
205-
# Install php-sdk
206-
git clone https://github.com/Microsoft/php-sdk-binary-tools.git C:\php-sdk
207-
208-
# Install vcpkg and LibUV >= 1.44.0
209-
git clone https://github.com/Microsoft/vcpkg.git C:\vcpkg
210-
C:\vcpkg\bootstrap-vcpkg.bat
211-
C:\vcpkg\vcpkg.exe install libuv:x64-windows
212-
213-
# Verify LibUV version
214-
C:\vcpkg\vcpkg.exe list libuv
215-
216-
# Create deps structure for php-sdk
217-
mkdir C:\php-sdk\deps\include\libuv
218-
mkdir C:\php-sdk\deps\lib
219-
220-
# Copy LibUV files
221-
xcopy /E /I C:\vcpkg\installed\x64-windows\include C:\php-sdk\deps\include\libuv\
222-
copy C:\vcpkg\installed\x64-windows\lib\uv.lib C:\php-sdk\deps\lib\libuv.lib
223-
shell: cmd
214+
run: git config --global core.autocrlf false && git config --global core.eol lf
224215

225-
# ==================== MACOS DEPENDENCIES ====================
226-
- name: Install build dependencies (macOS)
227-
if: matrix.os == 'macos-latest'
216+
- name: Create build task (Windows)
217+
if: matrix.os == 'windows-latest'
218+
working-directory: php-src
219+
shell: cmd
228220
run: |
229-
# Install required packages (force reinstall if needed)
230-
brew install autoconf || brew reinstall autoconf
231-
brew install libuv || brew reinstall libuv
232-
brew install icu4c || brew reinstall icu4c
233-
brew install openssl@3 || brew reinstall openssl@3
234-
235-
# Verify LibUV version
236-
pkg-config --modversion libuv || echo "LibUV not found"
237-
238-
# Setup environment variables for keg-only packages
239-
echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig:$(brew --prefix icu4c)/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
240-
echo "CPPFLAGS=-I$(brew --prefix openssl@3)/include -I$(brew --prefix icu4c)/include" >> $GITHUB_ENV
241-
echo "LDFLAGS=-L$(brew --prefix openssl@3)/lib -L$(brew --prefix icu4c)/lib" >> $GITHUB_ENV
242-
243-
# Debug info
244-
echo "Autoconf version: $(autoconf --version | head -1)"
245-
echo "LibUV version: $(pkg-config --modversion libuv || echo 'N/A')"
221+
echo @echo off > buildtask.bat
222+
echo echo Building PHP with async extension... >> buildtask.bat
223+
echo. >> buildtask.bat
224+
echo REM Update dependencies >> buildtask.bat
225+
echo phpsdk_deps --update --no-backup --branch master --stability staging --deps "%PHP_BUILD_CACHE_BASE_DIR%\deps" --crt %PHP_BUILD_CRT% >> buildtask.bat
226+
echo if %%errorlevel%% neq 0 exit /b 3 >> buildtask.bat
227+
echo. >> buildtask.bat
228+
echo REM Build configure >> buildtask.bat
229+
echo buildconf.bat --force >> buildtask.bat
230+
echo if %%errorlevel%% neq 0 exit /b 3 >> buildtask.bat
231+
echo. >> buildtask.bat
232+
echo REM Configure PHP with async >> buildtask.bat
233+
echo configure.bat --enable-snapshot-build --disable-debug-pack --without-analyzer --enable-object-out-dir=%PHP_BUILD_OBJ_DIR% --with-php-build="%PHP_BUILD_CACHE_BASE_DIR%\deps" --enable-async --enable-zts >> buildtask.bat
234+
echo if %%errorlevel%% neq 0 exit /b 3 >> buildtask.bat
235+
echo. >> buildtask.bat
236+
echo REM Build >> buildtask.bat
237+
echo nmake /NOLOGO >> buildtask.bat
238+
echo if %%errorlevel%% neq 0 exit /b 3 >> buildtask.bat
246239
247-
# ==================== WINDOWS CONFIGURE & BUILD ====================
248-
- name: Configure and Build PHP (Windows)
240+
- name: Windows Build
249241
if: matrix.os == 'windows-latest'
250242
working-directory: php-src
243+
shell: cmd
251244
run: |
252-
REM Setup PHP SDK environment properly
253-
call C:\php-sdk\phpsdk-vs17-x64.bat
245+
REM Create build directories
246+
if not exist "%PHP_BUILD_CACHE_BASE_DIR%" mkdir "%PHP_BUILD_CACHE_BASE_DIR%"
247+
if not exist "%PHP_BUILD_OBJ_DIR%" mkdir "%PHP_BUILD_OBJ_DIR%"
254248
255-
REM Set UTF-8 encoding
256-
chcp 65001
249+
REM Setup SDK
250+
set SDK_REMOTE=https://github.com/php/php-sdk-binary-tools.git
251+
set SDK_BRANCH=%PHP_BUILD_SDK_BRANCH%
252+
set SDK_RUNNER=%PHP_BUILD_CACHE_SDK_DIR%\phpsdk-%PHP_BUILD_CRT%-%PLATFORM%.bat
257253
258-
REM Clean previous build
259-
nmake clean
254+
REM Clone SDK if needed
255+
if not exist "%PHP_BUILD_CACHE_SDK_DIR%" (
256+
echo Cloning PHP SDK...
257+
git clone --branch %SDK_BRANCH% %SDK_REMOTE% --depth 1 "%PHP_BUILD_CACHE_SDK_DIR%"
258+
)
260259
261-
REM Check if async extension exists
262-
dir ext\async
260+
REM Check SDK runner exists
261+
if not exist "%SDK_RUNNER%" (
262+
echo SDK runner not found: %SDK_RUNNER%
263+
dir "%PHP_BUILD_CACHE_SDK_DIR%"
264+
exit /b 1
265+
)
263266
264-
REM Build configuration files
265-
call buildconf.bat
267+
REM Run PHP SDK and build
268+
echo Running SDK: %SDK_RUNNER%
269+
call "%SDK_RUNNER%" -t buildtask.bat
270+
271+
# ==================== MACOS DEPENDENCIES (Official PHP approach) ====================
272+
- name: Install build dependencies (macOS)
273+
if: matrix.os == 'macos-latest'
274+
run: |
275+
set -x
266276
267-
REM Configure with your working options (without debug-pack)
268-
call configure.bat --enable-phpdbg --enable-async --enable-pdo --with-pdo-mysql --enable-sockets --with-sqlite3 --with-curl --enable-ftp
277+
# Patch brew to overwrite always (from official PHP workflow)
278+
formula_installer="$(brew --repo)"/Library/Homebrew/formula_installer.rb
279+
code=" keg.link\(verbose: verbose\?"
280+
sudo sed -Ei '' "s/$code.*/$code, overwrite: true\)/" "$formula_installer"
269281
270-
REM Build
271-
nmake
272-
shell: cmd
282+
# Install core dependencies (official PHP list + libuv for async)
283+
brew reinstall autoconf webp tidy-html5 libzip libsodium icu4c curl
284+
brew install \
285+
bison \
286+
re2c \
287+
libuv
288+
brew install \
289+
bzip2 \
290+
enchant \
291+
libffi \
292+
intltool \
293+
libiconv \
294+
t1lib \
295+
libxml2 \
296+
libjpeg \
297+
libxslt
298+
299+
# Verify LibUV version
300+
pkg-config --modversion libuv || echo "LibUV not found"
273301
274302
# ==================== MACOS CONFIGURE & BUILD ====================
275303
- name: Configure PHP (macOS)
276304
if: matrix.os == 'macos-latest'
277305
working-directory: php-src
278306
run: |
279-
# Debug environment
280-
echo "PATH: $PATH"
281-
echo "PKG_CONFIG_PATH: $PKG_CONFIG_PATH"
282-
which autoconf || echo "autoconf not found"
283-
autoconf --version || echo "autoconf version failed"
307+
set -x
284308
285-
# Check async extension
286-
ls -la ext/async/ || echo "async directory not found"
309+
# Setup environment (official PHP approach)
310+
BREW_OPT="$(brew --prefix)"/opt
311+
export PATH="$BREW_OPT/bison/bin:$PATH"
312+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/[email protected]/lib/pkgconfig"
313+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/curl/lib/pkgconfig"
314+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/libffi/lib/pkgconfig"
315+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/libxml2/lib/pkgconfig"
316+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/libxslt/lib/pkgconfig"
317+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/zlib/lib/pkgconfig"
318+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/icu4c/lib/pkgconfig"
287319
288-
# Build configure
289-
echo "Running buildconf..."
290-
./buildconf -f || { echo "buildconf failed"; exit 1; }
320+
# Fix curl pkg-config (official PHP approach)
321+
sed -i -e 's/Requires.private:.*//g' "$BREW_OPT/curl/lib/pkgconfig/libcurl.pc"
291322
292-
# Test simple configure first
293-
echo "Testing minimal configure..."
294-
./configure --help | head -20
323+
# Check async extension exists
324+
ls -la ext/async/
295325
296-
# Configure with absolute minimal options
297-
echo "Running configure..."
326+
# Build configure
327+
./buildconf --force
328+
329+
# Configure with official PHP options + async
298330
./configure \
299-
--disable-all \
300-
--enable-cli \
301-
--enable-async || { echo "configure failed"; cat config.log | tail -50; exit 1; }
331+
--enable-option-checking=fatal \
332+
--prefix=/usr/local \
333+
--enable-fpm \
334+
--with-pdo-mysql=mysqlnd \
335+
--with-mysqli=mysqlnd \
336+
--with-pdo-sqlite \
337+
--without-pear \
338+
--enable-gd \
339+
--with-jpeg \
340+
--with-webp \
341+
--with-freetype \
342+
--enable-exif \
343+
--with-zip \
344+
--with-zlib \
345+
--enable-soap \
346+
--enable-xmlreader \
347+
--with-xsl \
348+
--with-tidy="$BREW_OPT"/tidy-html5 \
349+
--with-libxml \
350+
--enable-sysvsem \
351+
--enable-sysvshm \
352+
--enable-shmop \
353+
--enable-pcntl \
354+
--with-readline="$BREW_OPT"/readline \
355+
--enable-mbstring \
356+
--with-curl \
357+
--with-gettext="$BREW_OPT"/gettext \
358+
--enable-sockets \
359+
--with-bz2="$BREW_OPT"/bzip2 \
360+
--with-openssl \
361+
--with-gmp="$BREW_OPT"/gmp \
362+
--with-iconv="$BREW_OPT"/libiconv \
363+
--enable-bcmath \
364+
--enable-calendar \
365+
--enable-ftp \
366+
--enable-sysvmsg \
367+
--with-ffi \
368+
--enable-zend-test \
369+
--enable-dl-test=shared \
370+
--enable-intl \
371+
--with-mhash \
372+
--with-sodium \
373+
--enable-dba \
374+
--with-config-file-path=/etc \
375+
--with-config-file-scan-dir=/etc/php.d \
376+
--enable-async
302377
303378
- name: Build PHP (macOS)
304379
if: matrix.os == 'macos-latest'

0 commit comments

Comments
 (0)