Skip to content

Commit

Permalink
ci: upload artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
lanthora committed Apr 6, 2024
1 parent 43f957e commit 5db4d89
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ jobs:
- name: build
shell: msys2 {0}
run: cmake -B .Release -DCMAKE_BUILD_TYPE=Release && cmake --build .Release
- name: collect
shell: msys2 {0}
run: ./winqtcollect.sh .Release/cake.exe artifacts
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: cake-windows
path: artifacts
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ pacman -Syu mingw-w64-x86_64-{cmake,ninja,gcc,libconfig,spdlog,uriparser,poco,qt
cmake -B .Release -G Ninja -DCMAKE_BUILD_TYPE=Release && cmake --build .Release
```

复制所有动态库和 Qt 依赖到 `.Release` 目录
复制 `.Release/cake.exe` 和所有依赖到 `artifacts` 目录

```bash
cd .Release
./_deps/candy-src/scripts/search-deps.sh cake.exe .
windeployqt6.exe cake.exe .
./winqtcollect.sh .Release/cake.exe artifacts
```

此时在 Windows 资源管理器找到 `.Release` 目录并执行 `cake.exe`,一切正常的话将能看界面.
此时在 Windows 资源管理器找到 `artifacts` 目录并执行 `cake.exe`,一切正常的话将能看界面.
58 changes: 58 additions & 0 deletions winqtcollect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash -e

# Define an array to store the processed dependencies
declare -a processed

# Define a function to get the whole list of dependencies recursively
recursive_search_deps () {
# Use ldd to list the dependencies and filter out the ones that are not absolute paths
local list=$(ldd "$1" | awk '/=> \// {print $3}')

# Loop through the dependencies
for dep in $list; do
# Check if the dependency has been processed before
if [[ ! " ${processed[@]} " =~ " ${dep} " ]]; then
# Check if the dependency contains /c/Windows in its path
if [[ "$dep" =~ "/c/Windows" ]]; then
# Ignore the dependency and continue the loop
continue
fi

# Copy the dependency to the specified directory
cp "$dep" "$2"
# Output the copied file path and name
echo "Copied $dep to $2"

# Add the dependency to the processed array
processed+=("$dep")

# Recursively call the function to process the dependency's dependencies
recursive_search_deps "$dep" "$2"
fi
done
}

# Check if the executable file is given as an argument
if [ -z "$2" ]; then
echo "Usage: $0 <PATH> <DESTINATION>"
exit 1
fi

# Create the directory if it does not exist
if [ ! -d "$2" ]; then
mkdir -p $2
fi

# Get the absolute path of the executable file
exe=$(readlink -f "$1")

# Copy the executable file to the target directory
cp "$exe" "$2"
exe=$2/$(basename "$exe")
exe=$(readlink -f "$exe")

# Call the function to get the whole list of dependencies recursively
recursive_search_deps "$exe" "$2"

# Add the necessary components for Windows Qt
windeployqt6 "$exe"

0 comments on commit 5db4d89

Please sign in to comment.