8000 Migrate to vcpkg ecosystem and fix x86 build issues by loonghao · Pull Request #9 · loonghao/EACopy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Migrate to vcpkg ecosystem and fix x86 build issues #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions .github/scripts/update-vcpkg-registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ if [[ "$DRY_RUN" == "true" ]]; then
fi

# Check if registry files exist
PORTFILE_PATH="ports/eacopy/portfile.cmake"
VCPKG_JSON_PATH="ports/eacopy/vcpkg.json"
VERSION_JSON_PATH="versions/e-/eacopy.json"
BASELINE_JSON_PATH="versions/baseline.json"
PORTFILE_PATH="vcpkg-registry/ports/eacopy/portfile.cmake"
VCPKG_JSON_PATH="vcpkg-registry/ports/eacopy/vcpkg.json"
VERSION_JSON_PATH="vcpkg-registry/versions/e-/eacopy.json"
BASELINE_JSON_PATH="vcpkg-registry/versions/baseline.json"

if [[ ! -f "$PORTFILE_PATH" ]]; then
echo "Error: portfile.cmake not found at $PORTFILE_PATH"
Expand All @@ -76,24 +76,36 @@ if [[ ! -f "$BASELINE_JSON_PATH" ]]; then
exit 1
fi

# Get current git commit hash for git-tree
GIT_TREE=$(git rev-parse HEAD)
echo "Current git-tree: $GIT_TREE"
# Calculate git-tree after all file updates
if [[ "$DRY_RUN" == "false" ]]; then
echo "Calculating git-tree after file updates..."

# Stage the changes to get the correct git-tree
git add vcpkg-registry/

# Calculate git-tree for the ports/eacopy directory
GIT_TREE=$(git write-tree --prefix=vcpkg-registry/ports/eacopy/)
echo "Git-tree hash: $GIT_TREE"
else
# For dry run, use current HEAD as placeholder
GIT_TREE=$(git rev-parse HEAD)
echo "Current git-tree (dry run): $GIT_TREE"
fi

# Update portfile.cmake
if [[ "$DRY_RUN" == "false" ]]; then
echo "Updating $PORTFILE_PATH..."

# Update the REF line to point to the current commit
sed -i "s|REF [a-f0-9]*|REF $GIT_TREE|g" "$PORTFILE_PATH"

# If using pre-built binaries approach (like xdelta), update SHA512
if grep -q "SHA512" "$PORTFILE_PATH"; then
sed -i 's|SHA512 "to-be-filled-after-release"|SHA512 "'"$SHA512"'"|g' "$PORTFILE_PATH"
sed -i 's|SHA512 "[a-f0-9]*"|SHA512 "'"$SHA512"'"|g' "$PORTFILE_PATH"
echo "✅ Updated SHA512 in portfile.cmake"
fi

echo "✅ Updated REF in portfile.cmake"
else
echo "[DRY RUN] Would update REF in $PORTFILE_PATH to: $GIT_TREE"
Expand Down
78 changes: 51 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
strategy:
matrix:
config: [Debug, Release]
arch: [x64, x86]

steps:
- uses: actions/checkout@v4
Expand All @@ -25,41 +26,58 @@ jobs:
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgGitCommitId: 'f26ec398c25c4980f33a50391f00a75f7ad62ef7'

- name: Configure CMake
run: |
mkdir build_${{ matrix.config }}
cd build_${{ matrix.config }}
# Set VCPKG_ROOT for this step
$env:VCPKG_ROOT = "${{ github.workspace }}/vcpkg"
# Configure with vcpkg toolchain
cmake .. -DEACOPY_BUILD_TESTS:BOOL=ON -DCMAKE_CXX_FLAGS="/DMSG_WAITALL=0x8" -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"

- name: Build
run: |
cd build_${{ matrix.config }}
cmake --build . --config ${{ matrix.config }}

- name: Run Unit Tests
- name: Build with unified script
env:
VCPKG_ROOT: '${{ github.workspace }}/vcpkg'
CI: 'true'
run: |
cd build_${{ matrix.config }}/test
ctest -C ${{ matrix.config }} -V
# Use the unified build script with specific configuration
scripts\build.bat --arch ${{ matrix.arch }} --config ${{ matrix.config }} --clean --build-dir build_${{ matrix.arch }}_${{ matrix.config }}

- name: Verify Executable Functionality
run: |
# Test if EACopy executable works with help flag
cd build_${{ matrix.config }}
./${{ matrix.config }}/EACopy.exe --help || ./${{ matrix.config }}/EACopy.exe /? || (echo "EACopy executable failed to run with help flag" && exit 1)
$BuildDir = "build_${{ matrix.arch }}_${{ matrix.config }}"
$ExePath = "$BuildDir\${{ matrix.config }}\EACopy.exe"
$ServicePath = "$BuildDir\${{ matrix.config }}\EACopyService.exe"

Write-Host "Testing EACopy executable at: $ExePath"
if (Test-Path $ExePath) {
& $ExePath --help
if ($LASTEXITCODE -ne 0) {
& $ExePath /?
if ($LASTEXITCODE -ne 0) {
Write-Host "EACopy executable failed to run with help flag"
exit 1
}
}
Write-Host "EACopy executable test passed"
} else {
Write-Host "EACopy executable not found at: $ExePath"
exit 1
}

# Test if EACopyService executable works with help flag (Windows only)
./${{ matrix.config }}/EACopyService.exe /? || (echo "EACopyService executable failed to run with help flag" && exit 1)
Write-Host "Testing EACopyService executable at: $ServicePath"
if (Test-Path $ServicePath) {
& $ServicePath /?
if ($LASTEXITCODE -ne 0) {
Write-Host "EACopyService executable failed to run with help flag"
exit 1
}
Write-Host "EACopyService executable test passed"
} else {
Write-Host "EACopyService executable not found at: $ServicePath"
exit 1
}

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: EACopy-${{ matrix.config }}
name: EACopy-${{ matrix.arch }}-${{ matrix.config }}
path: |
build_${{ matrix.config }}/${{ matrix.config }}/*.exe
build_${{ matrix.config }}/${{ matrix.config }}/*.dll
build_${{ matrix.arch }}_${{ matrix.config }}/${{ matrix.config }}/*.exe
build_${{ matrix.arch }}_${{ matrix.config }}/${{ matrix.config }}/*.dll
build_${{ matrix.arch }}_${{ matrix.config }}/${{ matrix.config }}/*.lib
if-no-files-found: error

performance-test:
Expand All @@ -81,7 +99,7 @@ jobs:
- name: Download Release Build
uses: actions/download-artifact@v4
with:
name: EACopy-Release
name: EACopy-x64-Release
path: ./Release

- name: Download Previous Performance History
Expand Down Expand Up @@ -128,9 +146,15 @@ jobs:
$ExecutablesToFind = @("EACopy", "EACopyService")

$PossiblePaths = @(
# CI environment paths (most likely)
# CI environment paths (most likely) - updated for new build structure
"./Release/{0}.exe",
# Build paths
"./Release/Release/{0}.exe",
# New unified build script paths
"./build_x64_Release/Release/{0}.exe",
"./build_x86_Release/Release/{0}.exe",
"./build_x64_Debug/Debug/{0}.exe",
"./build_x86_Debug/Debug/{0}.exe",
# Legacy build paths for compatibility
"./build/Release/{0}.exe",
"./build_Release/Release/{0}.exe",
"./build/Debug/{0}.exe",
Expand Down
35 changes: 33 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,26 +125,57 @@ jobs:
run: |
export VCPKG_ROOT="${{ github.workspace }}/vcpkg"

echo "Building for triplet: ${{ matrix.triplet }}, config: ${{ matrix.config }}"
echo "VCPKG_ROOT: $VCPKG_ROOT"

# Create build directory
mkdir -p build-${{ matrix.triplet }}-${{ matrix.config }}
cd build-${{ matrix.triplet }}-${{ matrix.config }}

# Set architecture for Visual Studio
if [[ "${{ matrix.triplet }}" == "x64-windows" ]]; then
ARCH="x64"
else
ARCH="Win32"
fi

echo "Using Visual Studio architecture: $ARCH"

# Configure CMake
cmake .. \
-G "Visual Studio 17 2022" \
-A ${{ matrix.triplet == 'x64-windows' && 'x64' || 'Win32' }} \
-A "$ARCH" \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \
-DEACOPY_BUILD_TESTS=OFF \
-DEACOPY_BUILD_AS_LIBRARY=ON \
-DEACOPY_INSTALL=ON

if [ $? -ne 0 ]; then
echo "CMake configuration failed"
exit 1
fi

# Build
echo "Starting build..."
cmake --build . --config ${{ matrix.config }} --verbose

if [ $? -ne 0 ]; then
echo "Build failed"
exit 1
fi

# Install to staging directory
echo "Installing to staging directory..."
cmake --install . --config ${{ matrix.config }} --prefix ../install-${{ matrix.triplet }}-${{ matrix.config }}

if [ $? -ne 0 ]; then
echo "Install failed"
exit 1
fi

echo "Build completed successfully"

- name: Package binaries
shell: bash
run: |
Expand Down Expand Up @@ -318,7 +349,7 @@ jobs:
- Updated baseline.json

This commit was created automatically by the release workflow.
file_pattern: 'ports/ versions/'
file_pattern: 'vcpkg-registry/'
commit_user_name: 'GitHub Actions'
commit_user_email: 'actions@github.com'
commit_author: 'GitHub Actions <actions@github.com>'
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

Loading
Loading
0