cbindgen issues

This commit is contained in:
ssrlive 2024-11-16 23:52:17 +08:00
parent 7314906841
commit ee4df8f97b
6 changed files with 12 additions and 8 deletions

View file

@ -90,13 +90,13 @@ jobs:
cargo build --all-features --release --target ${{ matrix.target }} cargo build --all-features --release --target ${{ matrix.target }}
fi fi
fi fi
cbindgen --config cbindgen.toml -l C --cpp-compat -o target/tun2proxy-ffi.h cbindgen --config cbindgen.toml -o target/tun2proxy.h
if [[ "${{ matrix.host_os }}" == "windows-latest" ]]; then if [[ "${{ matrix.host_os }}" == "windows-latest" ]]; then
powershell -Command "(Get-Item README.md).LastWriteTime = Get-Date" powershell -Command "(Get-Item README.md).LastWriteTime = Get-Date"
powershell -Command "(Get-Item target/${{ matrix.target }}/release/wintun.dll).LastWriteTime = Get-Date" powershell -Command "(Get-Item target/${{ matrix.target }}/release/wintun.dll).LastWriteTime = Get-Date"
powershell Compress-Archive -Path target/${{ matrix.target }}/release/tun2proxy-bin.exe, target/${{ matrix.target }}/release/udpgw-server.exe, README.md, target/tun2proxy-ffi.h, target/${{ matrix.target }}/release/tun2proxy.dll, target/${{ matrix.target }}/release/wintun.dll -DestinationPath mypubdir4/tun2proxy-${{ matrix.target }}.zip powershell Compress-Archive -Path target/${{ matrix.target }}/release/tun2proxy-bin.exe, target/${{ matrix.target }}/release/udpgw-server.exe, README.md, target/tun2proxy.h, target/${{ matrix.target }}/release/tun2proxy.dll, target/${{ matrix.target }}/release/wintun.dll -DestinationPath mypubdir4/tun2proxy-${{ matrix.target }}.zip
elif [[ "${{ matrix.host_os }}" == "macos-latest" ]]; then elif [[ "${{ matrix.host_os }}" == "macos-latest" ]]; then
zip -j mypubdir4/tun2proxy-${{ matrix.target }}.zip target/${{ matrix.target }}/release/tun2proxy-bin target/${{ matrix.target }}/release/udpgw-server README.md target/tun2proxy-ffi.h target/${{ matrix.target }}/release/libtun2proxy.dylib zip -j mypubdir4/tun2proxy-${{ matrix.target }}.zip target/${{ matrix.target }}/release/tun2proxy-bin target/${{ matrix.target }}/release/udpgw-server README.md target/tun2proxy.h target/${{ matrix.target }}/release/libtun2proxy.dylib
if [[ "${{ matrix.target }}" == "x86_64-apple-darwin" ]]; then if [[ "${{ matrix.target }}" == "x86_64-apple-darwin" ]]; then
./build-aarch64-apple-ios.sh ./build-aarch64-apple-ios.sh
zip -r mypubdir4/tun2proxy-aarch64-apple-ios-xcframework.zip ./tun2proxy.xcframework/ zip -r mypubdir4/tun2proxy-aarch64-apple-ios-xcframework.zip ./tun2proxy.xcframework/
@ -104,7 +104,7 @@ jobs:
zip -r mypubdir4/tun2proxy-apple-xcframework.zip ./tun2proxy.xcframework/ zip -r mypubdir4/tun2proxy-apple-xcframework.zip ./tun2proxy.xcframework/
fi fi
elif [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then elif [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
zip -j mypubdir4/tun2proxy-${{ matrix.target }}.zip target/${{ matrix.target }}/release/tun2proxy-bin target/${{ matrix.target }}/release/udpgw-server README.md target/tun2proxy-ffi.h target/${{ matrix.target }}/release/libtun2proxy.so zip -j mypubdir4/tun2proxy-${{ matrix.target }}.zip target/${{ matrix.target }}/release/tun2proxy-bin target/${{ matrix.target }}/release/udpgw-server README.md target/tun2proxy.h target/${{ matrix.target }}/release/libtun2proxy.so
if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-gnu" ]]; then if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-gnu" ]]; then
./build-android.sh ./build-android.sh
cp ./tun2proxy-android-libs.zip ./mypubdir4/ cp ./tun2proxy-android-libs.zip ./mypubdir4/

View file

@ -10,7 +10,7 @@ cargo build --target aarch64-apple-ios --features mimalloc
echo "Generating includes..." echo "Generating includes..."
mkdir -p target/include/ mkdir -p target/include/
rm -rf target/include/* rm -rf target/include/*
cbindgen --config cbindgen.toml -l C --cpp-compat -o target/include/tun2proxy.h cbindgen --config cbindgen.toml -o target/include/tun2proxy.h
cat > target/include/tun2proxy.modulemap <<EOF cat > target/include/tun2proxy.modulemap <<EOF
framework module tun2proxy { framework module tun2proxy {
umbrella header "tun2proxy.h" umbrella header "tun2proxy.h"

View file

@ -10,7 +10,7 @@ cargo build --release --target aarch64-apple-ios --features mimalloc
echo "Generating includes..." echo "Generating includes..."
mkdir -p target/include/ mkdir -p target/include/
rm -rf target/include/* rm -rf target/include/*
cbindgen --config cbindgen.toml -l C --cpp-compat -o target/include/tun2proxy.h cbindgen --config cbindgen.toml -o target/include/tun2proxy.h
cat > target/include/tun2proxy.modulemap <<EOF cat > target/include/tun2proxy.modulemap <<EOF
framework module tun2proxy { framework module tun2proxy {
umbrella header "tun2proxy.h" umbrella header "tun2proxy.h"

View file

@ -108,7 +108,7 @@ function build_android() {
cp $BASE/target/$target/${mode2}/lib${name}.a $android_libs/${target_dir}/lib${name}.a cp $BASE/target/$target/${mode2}/lib${name}.a $android_libs/${target_dir}/lib${name}.a
done done
cbindgen -c $BASE/cbindgen.toml -l C --cpp-compat -o $android_libs/$name.h cbindgen -c $BASE/cbindgen.toml -o $android_libs/$name.h
} }
function main() { function main() {

View file

@ -24,7 +24,7 @@ cargo build --release --target aarch64-apple-ios-sim
echo "Generating includes..." echo "Generating includes..."
mkdir -p target/include/ mkdir -p target/include/
rm -rf target/include/* rm -rf target/include/*
cbindgen --config cbindgen.toml -l C --cpp-compat -o target/include/tun2proxy.h cbindgen --config cbindgen.toml -o target/include/tun2proxy.h
cat > target/include/tun2proxy.modulemap <<EOF cat > target/include/tun2proxy.modulemap <<EOF
framework module tun2proxy { framework module tun2proxy {
umbrella header "tun2proxy.h" umbrella header "tun2proxy.h"

View file

@ -1,3 +1,6 @@
language = "C"
cpp_compat = true
[export] [export]
include = [ include = [
"tun2proxy_with_fd_run", "tun2proxy_with_fd_run",
@ -10,6 +13,7 @@ include = [
exclude = [ exclude = [
"Java_com_github_shadowsocks_bg_Tun2proxy_run", "Java_com_github_shadowsocks_bg_Tun2proxy_run",
"Java_com_github_shadowsocks_bg_Tun2proxy_stop", "Java_com_github_shadowsocks_bg_Tun2proxy_stop",
"UdpFlag",
] ]
[export.rename] [export.rename]