forked from iotaledger/iota-sdk-native-bindings
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflows, opt. patches and updated Cargo file
- Loading branch information
Showing
7 changed files
with
236 additions
and
4 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,21 @@ | ||
name: Set Up Clang/LLVM | ||
description: "This composite action installs Clang/LLVM to the runner's temporary directory and sets LIBCLANG_PATH for the following steps, which is required for bindgen to work on Windows. See: https://github.com/rust-lang/rust-bindgen/issues/1797." | ||
inputs: | ||
version: | ||
description: The version of Clang/LLVM to install. | ||
type: string | ||
required: false | ||
default: '13' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install Clang/LLVM | ||
uses: KyleMayes/install-llvm-action@v1 | ||
with: | ||
version: ${{ inputs.version }} | ||
directory: ${{ runner.temp }}/llvm/ | ||
|
||
- name: Set LIBCLANG_PATH | ||
shell: pwsh | ||
run: Add-Content -Path "$Env:GITHUB_ENV" -Value "LIBCLANG_PATH=$Env:LLVM_PATH\bin" |
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,54 @@ | ||
name: Set Up Rust | ||
description: Install the Rust toolchain, components, and set up the cache. | ||
inputs: | ||
toolchain: | ||
description: Type of toolchain to install. | ||
required: false | ||
default: stable | ||
targets: | ||
description: Targets triple of the toolchain. | ||
required: false | ||
components: | ||
description: Additional components to install. | ||
required: false | ||
install: | ||
description: Additional tool to install via `cargo install`. | ||
required: false | ||
cache: | ||
description: Whether to set up cache or not. | ||
required: false | ||
default: "true" | ||
cache-root: | ||
description: The root of cargo crate. | ||
required: false | ||
default: "." | ||
additional-cache-dirs: | ||
description: A newline-separated list of additional cache directories. | ||
required: false | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- run: rustup set auto-self-update disable | ||
if: contains(runner.os, 'windows') | ||
shell: bash | ||
|
||
- id: install | ||
name: Install Rust Toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: ${{ inputs.toolchain }} | ||
targets: ${{ inputs.targets }} | ||
components: ${{ inputs.components }} | ||
|
||
- name: Cache dependencies | ||
if: ${{ inputs.cache == 'true' }} | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
workspaces: "${{ inputs.cache-root }} -> target" | ||
cache-directories: ${{ inputs.additional-cache-dirs }} | ||
|
||
- name: Install ${{ inputs.install }} | ||
if: ${{ inputs.install != '' }} | ||
shell: bash | ||
run: cargo install ${{ inputs.install }} |
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,107 @@ | ||
name: Native prebuilt publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
env: | ||
CARGO_INCREMENTAL: 0 | ||
|
||
jobs: | ||
native-binding-prebuilt: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [macos-13, ubuntu-20.04, windows-2022] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: List files in the repository | ||
run: | | ||
ls ${{ github.workspace }} | ||
- name: Select Xcode | ||
uses: maxim-lobanov/setup-xcode@v1 | ||
if: matrix.os == 'macos-13' | ||
with: | ||
xcode-version: '14.3' | ||
|
||
- name: Install Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
|
||
- name: Install LLVM and Clang (Windows) # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797 | ||
uses: KyleMayes/install-llvm-action@32c4866ebb71e0949e8833eb49beeebed48532bd | ||
if: matrix.os == 'windows-2022' | ||
with: | ||
version: "11.0" | ||
directory: ${{ runner.temp }}/llvm | ||
|
||
- name: Set LIBCLANG_PATH (Windows) | ||
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV | ||
if: matrix.os == 'windows-2022' | ||
|
||
- name: Set deployment target (macOS) | ||
run: echo "MACOSX_DEPLOYMENT_TARGET=10.14" >> $GITHUB_ENV | ||
if: matrix.os == 'macos-13' | ||
|
||
- name: Get current date | ||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | ||
if: matrix.os == 'macos-13' || ${{ startsWith(matrix.os, 'ubuntu') }} | ||
|
||
- name: Get current date | ||
if: matrix.os == 'windows-2022' | ||
run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | ||
|
||
- name: Install required packages (Ubuntu) | ||
if: ${{ startsWith(matrix.os, 'ubuntu') }} | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install libudev-dev libusb-1.0-0-dev | ||
- name: Cache cargo registry | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cargo/registry | ||
# Add date to the cache to keep it up to date | ||
key: ${{ matrix.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }}-${{ env.CURRENT_DATE }} | ||
# Restore from outdated cache for speed | ||
restore-keys: | | ||
${{ matrix.os }}-stable-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | ||
${{ matrix.os }}-stable-cargo-registry- | ||
- name: Cache cargo index | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cargo/git | ||
# Add date to the cache to keep it up to date | ||
key: ${{ matrix.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }}-${{ env.CURRENT_DATE }} | ||
# Restore from outdated cache for speed | ||
restore-keys: | | ||
${{ matrix.os }}-stable-cargo-index-${{ hashFiles('**/Cargo.lock') }} | ||
${{ matrix.os }}-stable-cargo-index- | ||
# This step is required to support macOS 10.13 | ||
- name: Patch librocksdb-sys (macOS) | ||
if: matrix.os == 'macos-latest123' | ||
run: | | ||
cargo install cargo-patch | ||
cp ${{ github.workspace }}/.patches/rocksdb_faligned_allocation.patch . | ||
git apply --ignore-space-change --ignore-whitespace ${{ github.workspace }}/.patches/macos_cargo_toml.patch | ||
cat Cargo.toml | ||
cargo patch | ||
- name: Cargo build | ||
run: cargo build --release | ||
|
||
- name: Upload package to Github release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
files: | | ||
target/release/libiota_sdk.so | ||
target/release/iota_sdk.dll | ||
target/release/libiota_sdk.dylib | ||
fail_on_unmatched_files: false | ||
tag_name: ${{ steps.prepare_release.outputs.tag_name }} |
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,21 @@ | ||
name: Cancel jobs from merged/closed pull request | ||
|
||
on: | ||
pull_request_target: | ||
types: [closed] | ||
# workflow_run: | ||
# workflows: ["*"] | ||
# types: [requested] | ||
|
||
|
||
jobs: | ||
merge_job: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: write | ||
steps: | ||
- uses: styfle/cancel-workflow-action@0.11.0 | ||
with: | ||
ignore_sha: true | ||
access_token: ${{ secrets.GITHUB_TOKEN }} | ||
workflow_id: all |
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,17 @@ | ||
diff --git a/Cargo.toml b/Cargo.toml | ||
index e00fa5df9..209f94d6c 100644 | ||
--- a/Cargo.toml | ||
+++ b/Cargo.toml | ||
@@ -25,3 +25,12 @@ codegen-units = 1 | ||
inherits = "release" | ||
lto = true | ||
strip = "symbols" | ||
+ | ||
+[workspace.metadata.patch.librocksdb-sys] | ||
+version = "0.11.0+8.1.1" | ||
+patches = [ | ||
+ { path = "rocksdb_faligned_allocation.patch", source = "GithubPrDiff" }, | ||
+] | ||
+ | ||
+[patch.crates-io] | ||
+librocksdb-sys = { path = "./target/patch/librocksdb-sys-0.11.0+8.1.1"} |
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,12 @@ | ||
diff --git a/build.rs b/build.rs | ||
index dccaf29..582aa32 100644 | ||
--- a/build.rs | ||
+++ b/build.rs | ||
@@ -155,6 +155,7 @@ fn build_rocksdb() { | ||
config.define("OS_MACOSX", None); | ||
config.define("ROCKSDB_PLATFORM_POSIX", None); | ||
config.define("ROCKSDB_LIB_IO_POSIX", None); | ||
+ config.flag_if_supported("-faligned-allocation"); | ||
} else if target.contains("android") { | ||
config.define("OS_ANDROID", None); | ||
config.define("ROCKSDB_PLATFORM_POSIX", None); |
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