Skip to content

Commit 23c2577

Browse files
authored
Merge v0.3.0-dev into master (#29)
* bump v0.3.0
1 parent 383f383 commit 23c2577

1,146 files changed

Lines changed: 206020 additions & 17363 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
[build]
22
jobs=8
33

4-
[net]
5-
retry = 3
6-
git-fetch-with-cli = true
74

85
[target.x86_64-pc-windows-gnu]
96
rustflags = [
107
"-C", "link-arg=-s",
8+
"-C", "link-arg=-Wl,--gc-sections",
119
]
1210

13-
[target.i686-pc-windows-gnu]
11+
[target.x86_64-pc-windows-msvc]
1412
rustflags = [
15-
"-C", "link-arg=-s",
13+
"-C","link-arg=/DEBUG:NONE",
14+
"-C", "target-feature=+crt-static",
1615
]
1716

18-
[target.x86_64-pc-windows-msvc]
17+
[target.i686-pc-windows-msvc]
1918
rustflags = [
20-
"-C", "link-arg=/DEBUG:NONE",
19+
"-C", "link-args=/SUBSYSTEM:CONSOLE,5.01",
2120
]
2221

2322
[target.'cfg(target_os = "macos")']
2423
rustflags = [
2524
"-C", "link-arg=-dead_strip"
2625
]
2726

28-
[target.'cfg(not(target_os = "macos"))']
27+
[target.'cfg(target_os = "linux")']
2928
rustflags = [
3029
"-C", "link-arg=-Wl,--gc-sections",
3130
"-C", "link-arg=-Wl,--strip-all",
32-
"-C", "link-arg=-Wl,--allow-multiple-definition",
33-
]
31+
]
32+
33+
# [target.'cfg(target_os = "windows")']
34+
# rustflags = [
35+
# "-C", "target-feature=+crt-static",
36+
# ]
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: bundle-full-source
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_name:
7+
description: 'Release tag to bundle'
8+
required: true
9+
default: 'v0.0.1'
10+
resource_asset_name:
11+
description: 'Existing release asset name to merge into resources/'
12+
required: true
13+
default: 'resources.zip'
14+
merge_strategy:
15+
description: 'How to handle duplicate files under resources/'
16+
required: true
17+
type: choice
18+
default: 'fail'
19+
options:
20+
- fail
21+
- overwrite
22+
bundle_asset_name:
23+
description: 'Optional override for the uploaded bundle asset name'
24+
required: false
25+
default: ''
26+
27+
permissions:
28+
contents: write
29+
30+
jobs:
31+
bundle-full-source:
32+
runs-on: ubuntu-22.04
33+
env:
34+
TAG_NAME: ${{ inputs.tag_name }}
35+
RESOURCE_ASSET_NAME: ${{ inputs.resource_asset_name }}
36+
MERGE_STRATEGY: ${{ inputs.merge_strategy }}
37+
steps:
38+
- name: Checkout tagged source
39+
uses: actions/checkout@v4
40+
with:
41+
ref: ${{ inputs.tag_name }}
42+
submodules: recursive
43+
fetch-depth: 0
44+
45+
- name: Install Rust toolchain for cargo vendor
46+
uses: dtolnay/rust-toolchain@nightly
47+
48+
- name: Resolve bundle names
49+
id: bundle_names
50+
shell: bash
51+
run: |
52+
version="${TAG_NAME}"
53+
root_dir="malefic-community-${version}-full-source"
54+
bundle_name="${{ inputs.bundle_asset_name }}"
55+
56+
if [[ -z "$bundle_name" ]]; then
57+
bundle_name="${root_dir}.zip"
58+
fi
59+
60+
echo "ROOT_DIR=$root_dir" >> "$GITHUB_OUTPUT"
61+
echo "BUNDLE_NAME=$bundle_name" >> "$GITHUB_OUTPUT"
62+
63+
- name: Download resource archive from release
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
shell: bash
67+
run: |
68+
mkdir -p .release-assets
69+
gh release download "$TAG_NAME" \
70+
--repo "${GITHUB_REPOSITORY}" \
71+
--pattern "$RESOURCE_ASSET_NAME" \
72+
--dir .release-assets \
73+
--clobber
74+
75+
test -f ".release-assets/$RESOURCE_ASSET_NAME"
76+
77+
- name: Merge resource archive into resources/
78+
shell: bash
79+
run: |
80+
mkdir -p resources .bundle-work/resources-unpacked
81+
unzip -q ".release-assets/$RESOURCE_ASSET_NAME" -d .bundle-work/resources-unpacked
82+
83+
shopt -s dotglob nullglob
84+
extracted=(.bundle-work/resources-unpacked/*)
85+
merge_root=".bundle-work/resources-unpacked"
86+
87+
if [[ ${#extracted[@]} -eq 1 && -d "${extracted[0]}" && "$(basename "${extracted[0]}")" == "resources" ]]; then
88+
merge_root="${extracted[0]}"
89+
fi
90+
91+
if [[ "$MERGE_STRATEGY" == "fail" ]]; then
92+
conflicts=()
93+
94+
while IFS= read -r -d '' file; do
95+
rel_path="${file#${merge_root}/}"
96+
if [[ -e "resources/${rel_path}" ]]; then
97+
conflicts+=("${rel_path}")
98+
fi
99+
done < <(find "$merge_root" -type f -print0)
100+
101+
if [[ ${#conflicts[@]} -gt 0 ]]; then
102+
echo "::error::Detected conflicting resource files:"
103+
printf ' - %s\n' "${conflicts[@]:0:20}"
104+
if [[ ${#conflicts[@]} -gt 20 ]]; then
105+
echo " - ... and $(( ${#conflicts[@]} - 20 )) more"
106+
fi
107+
exit 1
108+
fi
109+
fi
110+
111+
rsync -a "${merge_root}/" resources/
112+
113+
- name: Vendor Rust dependencies
114+
shell: bash
115+
run: |
116+
mkdir -p .bundle-work .cargo
117+
118+
cargo vendor --locked --versioned-dirs vendor \
119+
--sync examples/ffi/rust/Cargo.toml \
120+
--sync examples/starship/Cargo.toml \
121+
--sync lib/rage/Cargo.toml \
122+
--sync malefic-3rd-template/Cargo.toml \
123+
--sync malefic-proxydll/Cargo.toml \
124+
--sync malefic-starship/Cargo.toml \
125+
> .bundle-work/cargo-vendor-config.toml
126+
127+
if [[ -f .cargo/config.toml ]]; then
128+
cp .cargo/config.toml .bundle-work/base-config.toml
129+
printf '\n' >> .bundle-work/base-config.toml
130+
cat .bundle-work/base-config.toml .bundle-work/cargo-vendor-config.toml > .cargo/config.toml
131+
else
132+
cp .bundle-work/cargo-vendor-config.toml .cargo/config.toml
133+
fi
134+
135+
- name: Build complete source archive
136+
shell: bash
137+
run: |
138+
root_dir="${{ steps.bundle_names.outputs.ROOT_DIR }}"
139+
bundle_name="${{ steps.bundle_names.outputs.BUNDLE_NAME }}"
140+
stage_dir="dist/${root_dir}"
141+
142+
mkdir -p "$stage_dir"
143+
rsync -a ./ "$stage_dir"/ \
144+
--exclude '.git' \
145+
--exclude '.bundle-work' \
146+
--exclude '.release-assets' \
147+
--exclude 'dist' \
148+
--exclude 'target' \
149+
--exclude '.DS_Store'
150+
151+
(
152+
cd dist
153+
zip -qry -y "$bundle_name" "$root_dir"
154+
)
155+
156+
- name: Upload complete source archive
157+
env:
158+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159+
shell: bash
160+
run: |
161+
bundle_name="${{ steps.bundle_names.outputs.BUNDLE_NAME }}"
162+
gh release upload "$TAG_NAME" \
163+
"dist/${bundle_name}" \
164+
--repo "${GITHUB_REPOSITORY}" \
165+
--clobber

.github/workflows/check.yaml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: check
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
workflow_dispatch:
9+
inputs:
10+
target:
11+
description: '指定 target(留空跑全部)'
12+
required: false
13+
default: ''
14+
phase:
15+
description: 'check / feature / test / mutant / profile / all'
16+
required: false
17+
default: 'all'
18+
toolchain:
19+
description: 'Rust toolchain (e.g. nightly-2024-09-18)'
20+
required: false
21+
default: 'nightly-2024-09-18'
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
check-linux:
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
target:
33+
- x86_64-unknown-linux-musl
34+
- x86_64-pc-windows-gnu
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
with:
39+
submodules: recursive
40+
token: ${{ secrets.GH_PAT }}
41+
42+
- name: Detect legacy check scripts
43+
id: legacy_check
44+
shell: bash
45+
run: |
46+
if [[ -f scripts/check/check.sh && -f scripts/check/profile.sh ]]; then
47+
echo "exists=true" >> "$GITHUB_OUTPUT"
48+
else
49+
echo "exists=false" >> "$GITHUB_OUTPUT"
50+
echo "Legacy scripts/check not found, skip legacy check steps."
51+
fi
52+
53+
- name: Install Rust toolchain
54+
if: steps.legacy_check.outputs.exists == 'true'
55+
uses: dtolnay/rust-toolchain@master
56+
with:
57+
toolchain: ${{ github.event.inputs.toolchain || 'nightly-2024-09-18' }}
58+
targets: ${{ matrix.target }}
59+
60+
- name: Install cross-compilation tools
61+
if: steps.legacy_check.outputs.exists == 'true'
62+
run: |
63+
sudo apt-get update
64+
sudo apt-get install -y gcc-mingw-w64-x86-64 musl-tools protobuf-compiler
65+
sudo ln -sf /usr/bin/musl-gcc /usr/local/bin/x86_64-linux-musl-gcc
66+
67+
- name: Rust cache
68+
if: steps.legacy_check.outputs.exists == 'true'
69+
uses: Swatinem/rust-cache@v2
70+
with:
71+
shared-key: "check-${{ matrix.target }}"
72+
cache-targets: true
73+
cache-all-crates: true
74+
save-if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
75+
76+
- name: Fix line endings
77+
if: steps.legacy_check.outputs.exists == 'true'
78+
run: |
79+
sudo apt-get install -y dos2unix 2>/dev/null || true
80+
find scripts/check -name '*.sh' -exec dos2unix {} + 2>/dev/null || \
81+
find scripts/check -name '*.sh' -exec sed -i 's/\r$//' {} +
82+
83+
- name: Determine phase
84+
id: phase
85+
if: steps.legacy_check.outputs.exists == 'true'
86+
run: |
87+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
88+
echo "value=${{ github.event.inputs.phase || 'all' }}" >> $GITHUB_OUTPUT
89+
else
90+
echo "value=test" >> $GITHUB_OUTPUT
91+
fi
92+
93+
- name: Run checks
94+
if: steps.legacy_check.outputs.exists == 'true'
95+
run: |
96+
chmod +x scripts/check/check.sh scripts/check/profile.sh
97+
./scripts/check/check.sh --target ${{ matrix.target }} --phase ${{ steps.phase.outputs.value }} --ci
98+
99+
check-darwin:
100+
runs-on: macos-latest
101+
steps:
102+
- name: Checkout
103+
uses: actions/checkout@v4
104+
with:
105+
submodules: recursive
106+
token: ${{ secrets.GH_PAT }}
107+
108+
- name: Detect legacy check scripts
109+
id: legacy_check
110+
shell: bash
111+
run: |
112+
if [[ -f scripts/check/check.sh && -f scripts/check/profile.sh ]]; then
113+
echo "exists=true" >> "$GITHUB_OUTPUT"
114+
else
115+
echo "exists=false" >> "$GITHUB_OUTPUT"
116+
echo "Legacy scripts/check not found, skip legacy check steps."
117+
fi
118+
119+
- name: Install protobuf
120+
if: steps.legacy_check.outputs.exists == 'true'
121+
run: brew install protobuf
122+
123+
- name: Install Rust toolchain
124+
if: steps.legacy_check.outputs.exists == 'true'
125+
uses: dtolnay/rust-toolchain@master
126+
with:
127+
toolchain: ${{ github.event.inputs.toolchain || 'nightly-2024-09-18' }}
128+
129+
- name: Rust cache
130+
if: steps.legacy_check.outputs.exists == 'true'
131+
uses: Swatinem/rust-cache@v2
132+
with:
133+
shared-key: "check-aarch64-apple-darwin"
134+
cache-targets: true
135+
cache-all-crates: true
136+
save-if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
137+
138+
- name: Fix line endings
139+
if: steps.legacy_check.outputs.exists == 'true'
140+
run: |
141+
find scripts/check -name '*.sh' -exec sed -i '' 's/\r$//' {} +
142+
143+
- name: Determine phase
144+
id: phase
145+
if: steps.legacy_check.outputs.exists == 'true'
146+
run: |
147+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
148+
echo "value=${{ github.event.inputs.phase || 'all' }}" >> $GITHUB_OUTPUT
149+
else
150+
echo "value=test" >> $GITHUB_OUTPUT
151+
fi
152+
153+
- name: Run checks
154+
if: steps.legacy_check.outputs.exists == 'true'
155+
run: |
156+
chmod +x scripts/check/check.sh scripts/check/profile.sh
157+
./scripts/check/check.sh --target aarch64-apple-darwin --phase ${{ steps.phase.outputs.value }} --ci

0 commit comments

Comments
 (0)