-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
179 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
curl -s https://api.github.com/repos/cross-rs/cross/releases/latest \ | ||
| grep cross-x86_64-unknown-linux-gnu.tar.gz \ | ||
| cut -d : -f 2,3 \ | ||
| tr -d \" \ | ||
| wget -qi - | ||
|
||
tar -zxvf cross-x86_64-unknown-linux-gnu.tar.gz -C /usr/bin | ||
rm -f cross-x86_64-unknown-linux-gnu.tar.gz | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
|
||
name: Publish Releases | ||
|
||
jobs: | ||
build_publish: | ||
name: Publishing Tasks | ||
strategy: | ||
matrix: | ||
target: | ||
- x86_64-unknown-linux-gnu | ||
- x86_64-unknown-linux-musl | ||
- i686-unknown-linux-musl | ||
- aarch64-unknown-linux-gnu | ||
- armv7-unknown-linux-gnueabihf | ||
- x86_64-apple-darwin | ||
- aarch64-apple-darwin | ||
- x86_64-pc-windows-msvc | ||
- i686-pc-windows-msvc | ||
|
||
include: | ||
- target: x86_64-unknown-linux-gnu | ||
host_os: ubuntu-latest | ||
- target: x86_64-unknown-linux-musl | ||
host_os: ubuntu-latest | ||
- target: i686-unknown-linux-musl | ||
host_os: ubuntu-latest | ||
- target: aarch64-unknown-linux-gnu | ||
host_os: ubuntu-latest | ||
- target: armv7-unknown-linux-gnueabihf | ||
host_os: ubuntu-latest | ||
- target: x86_64-apple-darwin | ||
host_os: macos-latest | ||
- target: aarch64-apple-darwin | ||
host_os: macos-latest | ||
- target: x86_64-pc-windows-msvc | ||
host_os: windows-latest | ||
- target: i686-pc-windows-msvc | ||
host_os: windows-latest | ||
|
||
runs-on: ${{ matrix.host_os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Prepare | ||
shell: bash | ||
run: | | ||
mkdir mypubdir4 | ||
rustup target add ${{ matrix.target }} | ||
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then | ||
sudo .github/workflows/install-cross.sh | ||
fi | ||
- name: Build | ||
shell: bash | ||
run: | | ||
if [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then | ||
cross build --all-features --release --target ${{ matrix.target }} | ||
else | ||
cargo build --all-features --release --target ${{ matrix.target }} | ||
fi | ||
cbindgen --config cbindgen.toml -l C -o target/dns2socks-ffi.h | ||
if [[ "${{ matrix.host_os }}" == "windows-latest" ]]; then | ||
powershell -Command "(Get-Item README.md).LastWriteTime = Get-Date" | ||
powershell Compress-Archive -Path target/${{ matrix.target }}/release/dns2socks.exe, README.md, target/dns2socks-ffi.h, target/${{ matrix.target }}/release/dns2socks.dll -DestinationPath mypubdir4/dns2socks-${{ matrix.target }}.zip | ||
elif [[ "${{ matrix.host_os }}" == "macos-latest" ]]; then | ||
zip -j mypubdir4/dns2socks-${{ matrix.target }}.zip target/${{ matrix.target }}/release/dns2socks README.md target/dns2socks-ffi.h target/${{ matrix.target }}/release/libdns2socks.dylib | ||
if [[ "${{ matrix.target }}" == "x86_64-apple-darwin" ]]; then | ||
./build-apple.sh | ||
zip -r mypubdir4/dns2socks-apple-xcframework.zip ./dns2socks.xcframework/ | ||
fi | ||
elif [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then | ||
zip -j mypubdir4/dns2socks-${{ matrix.target }}.zip target/${{ matrix.target }}/release/dns2socks README.md target/dns2socks-ffi.h target/${{ matrix.target }}/release/libdns2socks.so | ||
fi | ||
- name: Publish | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
files: mypubdir4/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Push or PR | ||
|
||
on: | ||
[push, pull_request] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build_n_test: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: rustfmt | ||
run: | | ||
rustc --version | ||
cargo fmt --all -- --check | ||
- name: check | ||
run: cargo check --verbose | ||
- name: clippy | ||
run: cargo clippy --all-targets --all-features -- -D warnings | ||
- name: Build | ||
run: cargo build --verbose --tests --all-features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dns2socks.xcframework/ | ||
Cargo.lock | ||
.vscode/ | ||
.VSCodeCounter/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#! /bin/sh | ||
|
||
echo "Setting up the rust environment..." | ||
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios x86_64-apple-darwin aarch64-apple-darwin | ||
cargo install cbindgen | ||
|
||
echo "Building..." | ||
cargo build --release --target x86_64-apple-darwin | ||
cargo build --release --target aarch64-apple-darwin | ||
cargo build --release --target aarch64-apple-ios | ||
cargo build --release --target x86_64-apple-ios | ||
cargo build --release --target aarch64-apple-ios-sim | ||
|
||
echo "Generating includes..." | ||
mkdir -p target/include/ | ||
cbindgen --config cbindgen.toml -l C -o target/include/dns2socks.h | ||
cat > target/include/module.modulemap <<EOF | ||
framework module dns2socks { | ||
umbrella header "dns2socks.h" | ||
export * | ||
module * { export * } | ||
} | ||
EOF | ||
|
||
echo "lipo..." | ||
echo "Simulator" | ||
lipo -create \ | ||
target/aarch64-apple-ios-sim/release/libdns2socks.a \ | ||
target/x86_64-apple-ios/release/libdns2socks.a \ | ||
-output ./target/libdns2socks-ios-sim.a | ||
|
||
echo "MacOS" | ||
lipo -create \ | ||
target/aarch64-apple-darwin/release/libdns2socks.a \ | ||
target/x86_64-apple-darwin/release/libdns2socks.a \ | ||
-output ./target/libdns2socks-macos.a | ||
|
||
echo "Creating XCFramework" | ||
rm -rf ./dns2socks.xcframework | ||
xcodebuild -create-xcframework \ | ||
-library ./target/aarch64-apple-ios/release/libdns2socks.a -headers ./target/include/ \ | ||
-library ./target/libdns2socks-ios-sim.a -headers ./target/include/ \ | ||
-library ./target/libdns2socks-macos.a -headers ./target/include/ \ | ||
-output ./dns2socks.xcframework |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[export] | ||
include = ["dns2socks_start", "dns2socks_stop", "dns2socks_set_log_callback"] | ||
exclude = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters