Skip to content

Commit

Permalink
Merge pull request #206 from nerdcash/addAndroidArm64
Browse files Browse the repository at this point in the history
Add more native targets
  • Loading branch information
AArnott authored Mar 3, 2024
2 parents d996e74 + 2dfdb0e commit 763e3c7
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 49 deletions.
1 change: 0 additions & 1 deletion azure-pipelines/Get-RustTargets.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
if ($IsLinux) {
# ,'aarch64-unknown-linux-gnu'
,'x86_64-unknown-linux-gnu'
}
elseif ($IsMacOS) {
Expand Down
10 changes: 7 additions & 3 deletions azure-pipelines/artifacts/rust.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
if (!(Test-Path "$PSScriptRoot/../../obj/src/nerdbank-zcash-rust/")) { return }
$root = "$PSScriptRoot\..\..\src\nerdbank-zcash-rust\target"
if (!(Test-Path $root)) { return }

$root = "$PSScriptRoot/../../obj/src/nerdbank-zcash-rust/"
$files = @()
Get-ChildItem $root\*-*-* -Directory |% {
$files += Get-ChildItem "$($_.FullName)\*\*nerdbank_zcash_rust*"
}

@{
$root = Get-ChildItem $root -Recurse
$root = $files
}
21 changes: 13 additions & 8 deletions azure-pipelines/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ parameters:
type: object
default:
vmImage: windows-2022
- name: includeMacOS
type: boolean
default: true
- name: RunTests
type: boolean
default: true
Expand Down Expand Up @@ -55,8 +52,19 @@ jobs:
displayName: 💅 Verify formatted code
enabled: false # TODO: enable this once we've solved the issue with uniffi C# emitted code formatting

- job: cross
displayName: cross-targeting
pool:
vmImage: Ubuntu 20.04
steps:
- checkout: self
fetchDepth: 1
clean: true
submodules: true

- template: cross.yml

- job: macOS
condition: ${{ parameters.includeMacOS }}
pool:
vmImage: macOS-12
steps:
Expand All @@ -80,6 +88,7 @@ jobs:
- Windows
- Linux
- macOS
- cross
pool:
vmImage: Ubuntu 20.04
variables:
Expand Down Expand Up @@ -109,9 +118,5 @@ jobs:
parameters:
initArgs: -NoRestore
- template: publish-symbols.yml
parameters:
includeMacOS: ${{ parameters.includeMacOS }}
- ${{ if parameters.RunTests }}:
- template: publish-codecoverage.yml
parameters:
includeMacOS: ${{ parameters.includeMacOS }}
20 changes: 20 additions & 0 deletions azure-pipelines/cross.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
steps:
- pwsh: cargo install cross --git https://github.com/cross-rs/cross --rev c87a52a60dbcde069714a8d2ed51570e7fc23cf9
displayName: 🛠️ install cross

- pwsh: cross build -r --target=aarch64-linux-android
displayName: 🛠️ build android-arm64
workingDirectory: src/nerdbank-zcash-rust

- pwsh: cross build -r --target=x86_64-linux-android
displayName: 🛠️ build android-x64
workingDirectory: src/nerdbank-zcash-rust

- pwsh: cross build -r --target=aarch64-unknown-linux-gnu
displayName: 🛠️ build linux-arm64
workingDirectory: src/nerdbank-zcash-rust

- powershell: azure-pipelines/artifacts/_pipelines.ps1 -ArtifactNameSuffix "-$(Agent.JobName)" -Verbose
failOnStderr: true
displayName: 📢 Publish artifacts
condition: succeededOrFailed()
18 changes: 12 additions & 6 deletions azure-pipelines/pack.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
steps:
- task: DownloadPipelineArtifact@2
displayName: 🔻 Download Windows code coverage results
displayName: 🔻 Download Windows binaries
inputs:
buildType: current
targetPath: obj/src/nerdbank-zcash-rust
targetPath: src/nerdbank-zcash-rust/target
artifactName: rust-Windows
- task: DownloadPipelineArtifact@2
displayName: 🔻 Download Linux code coverage results
displayName: 🔻 Download Linux binaries
inputs:
buildType: current
targetPath: obj/src/nerdbank-zcash-rust
targetPath: src/nerdbank-zcash-rust/target
artifactName: rust-Linux
- task: DownloadPipelineArtifact@2
displayName: 🔻 Download macOS code coverage results
displayName: 🔻 Download cross-targeting binaries
inputs:
buildType: current
targetPath: obj/src/nerdbank-zcash-rust
targetPath: src/nerdbank-zcash-rust/target
artifactName: rust-cross-targeting
- task: DownloadPipelineArtifact@2
displayName: 🔻 Download macOS binaries
inputs:
buildType: current
targetPath: src/nerdbank-zcash-rust/target
artifactName: rust-macOS

- pwsh: src/nerdbank-zcash-rust/Generate-3rdPartyNotices.ps1
Expand Down
4 changes: 0 additions & 4 deletions azure-pipelines/publish-codecoverage.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
parameters:
includeMacOS:

steps:
- download: current
artifact: coverageResults-Windows
Expand All @@ -14,7 +11,6 @@ steps:
artifact: coverageResults-macOS
displayName: 🔻 Download macOS code coverage results
continueOnError: true
condition: and(succeeded(), ${{ parameters.includeMacOS }})
- powershell: azure-pipelines/Merge-CodeCoverage.ps1 -Path '$(Pipeline.Workspace)' -OutputFile coveragereport/merged.cobertura.xml -Format Cobertura -Verbose
displayName: ⚙ Merge coverage
- task: PublishCodeCoverageResults@1
Expand Down
5 changes: 0 additions & 5 deletions azure-pipelines/publish-symbols.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
parameters:
includeMacOS:

steps:
- task: DownloadPipelineArtifact@2
inputs:
Expand All @@ -20,7 +17,6 @@ steps:
path: $(Pipeline.Workspace)/symbols/macOS
displayName: 🔻 Download macOS symbols
continueOnError: true
condition: ${{ parameters.includeMacOS }}

- task: DownloadPipelineArtifact@2
inputs:
Expand All @@ -40,7 +36,6 @@ steps:
path: $(Pipeline.Workspace)/test_symbols/macOS
displayName: 🔻 Download macOS test symbols
continueOnError: true
condition: ${{ parameters.includeMacOS }}

- task: PublishSymbols@2
inputs:
Expand Down
37 changes: 23 additions & 14 deletions src/Nerdbank.Zcash/NativeBindings.targets
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
<Project>
<PropertyGroup>
<RustOutputDirBase>$(RepoRootPath)obj/src/nerdbank-zcash-rust/</RustOutputDirBase>
<RustOutputDir>$(RustOutputDirBase)$(Configuration.ToLower())/</RustOutputDir>
<RustIntermediateDirBase>$(RepoRootPath)obj/src/nerdbank-zcash-rust/</RustIntermediateDirBase>
<RustOutputDirBase>$(RepoRootPath)src/nerdbank-zcash-rust/target/</RustOutputDirBase>
<RustConfiguration>$(Configuration.ToLower())</RustConfiguration>
</PropertyGroup>
<!-- This file is imported both by the packaging project and by the test project.
In the case of the packaging project, which targets AnyCPU, we want all native files included.
But in the case of the test project, we only want the one that matches the platform. -->
<ItemGroup>
<!-- Windows -->
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='arm64' and $([MSBuild]::IsOsPlatform('Windows')))" Include="$(RustOutputDir)aarch64-pc-windows-msvc/nerdbank_zcash_rust.dll">
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='arm64' and $([MSBuild]::IsOsPlatform('Windows')))" Include="$(RustOutputDirBase)aarch64-pc-windows-msvc/$(RustConfiguration)/nerdbank_zcash_rust.dll">
<PackagePath>runtimes/win-arm64/native/</PackagePath>
</RustBinary>
<RustSymbol Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='arm64' and $([MSBuild]::IsOsPlatform('Windows')))" Include="$(RustOutputDir)aarch64-pc-windows-msvc/nerdbank_zcash_rust.pdb">
<RustSymbol Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='arm64' and $([MSBuild]::IsOsPlatform('Windows')))" Include="$(RustOutputDirBase)aarch64-pc-windows-msvc/$(RustConfiguration)/nerdbank_zcash_rust.pdb">
<PackagePath>runtimes/win-arm64/native/</PackagePath>
</RustSymbol>
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='x64' and $([MSBuild]::IsOsPlatform('Windows')))" Include="$(RustOutputDir)x86_64-pc-windows-msvc/nerdbank_zcash_rust.dll">
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='x64' and $([MSBuild]::IsOsPlatform('Windows')))" Include="$(RustOutputDirBase)x86_64-pc-windows-msvc/$(RustConfiguration)/nerdbank_zcash_rust.dll">
<PackagePath>runtimes/win-x64/native/</PackagePath>
</RustBinary>
<RustSymbol Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='x64' and $([MSBuild]::IsOsPlatform('Windows')))" Include="$(RustOutputDir)x86_64-pc-windows-msvc/nerdbank_zcash_rust.pdb">
<RustSymbol Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='x64' and $([MSBuild]::IsOsPlatform('Windows')))" Include="$(RustOutputDirBase)x86_64-pc-windows-msvc/$(RustConfiguration)/nerdbank_zcash_rust.pdb">
<PackagePath>runtimes/win-x64/native/</PackagePath>
</RustSymbol>

<!-- Linux -->
<!-- <RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='arm64' and $([MSBuild]::IsOsPlatform('Linux')))" Include="$(RustOutputDir)aarch64-unknown-linux-gnu/libnerdbank_zcash_rust.so">
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='arm64' and $([MSBuild]::IsOsPlatform('Linux')))" Include="$(RustOutputDirBase)aarch64-unknown-linux-gnu/$(RustConfiguration)/libnerdbank_zcash_rust.so">
<PackagePath>runtimes/linux-arm64/native/</PackagePath>
</RustBinary> -->
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='x64' and $([MSBuild]::IsOsPlatform('Linux')))" Include="$(RustOutputDir)x86_64-unknown-linux-gnu/libnerdbank_zcash_rust.so">
</RustBinary>
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='x64' and $([MSBuild]::IsOsPlatform('Linux')))" Include="$(RustOutputDirBase)x86_64-unknown-linux-gnu/$(RustConfiguration)/libnerdbank_zcash_rust.so">
<PackagePath>runtimes/linux-x64/native/</PackagePath>
</RustBinary>

<!-- Android -->
<RustBinary Condition="'$(Platform)'=='AnyCPU'" Include="$(RustOutputDirBase)aarch64-linux-android/$(RustConfiguration)/libnerdbank_zcash_rust.so">
<PackagePath>runtimes/android-arm64/native/</PackagePath>
</RustBinary>
<RustBinary Condition="'$(Platform)'=='AnyCPU'" Include="$(RustOutputDirBase)x86_64-linux-android/$(RustConfiguration)/libnerdbank_zcash_rust.so">
<PackagePath>runtimes/android-x64/native/</PackagePath>
</RustBinary>

<!-- Mac -->
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='arm64' and $([MSBuild]::IsOsPlatform('OSX')))" Include="$(RustOutputDir)aarch64-apple-darwin/libnerdbank_zcash_rust.dylib">
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='arm64' and $([MSBuild]::IsOsPlatform('OSX')))" Include="$(RustOutputDirBase)aarch64-apple-darwin/$(RustConfiguration)/libnerdbank_zcash_rust.dylib">
<PackagePath>runtimes/osx-arm64/native/</PackagePath>
</RustBinary>
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='x64' and $([MSBuild]::IsOsPlatform('OSX')))" Include="$(RustOutputDir)x86_64-apple-darwin/libnerdbank_zcash_rust.dylib">
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='x64' and $([MSBuild]::IsOsPlatform('OSX')))" Include="$(RustOutputDirBase)x86_64-apple-darwin/$(RustConfiguration)/libnerdbank_zcash_rust.dylib">
<PackagePath>runtimes/osx-x64/native/</PackagePath>
</RustBinary>
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='arm64' and $([MSBuild]::IsOsPlatform('OSX')))" Include="$(RustOutputDir)aarch64-apple-darwin/libnerdbank_zcash_rust.dylib">
<RustBinary Condition="'$(Platform)'=='AnyCPU' or ('$(Platform)'=='arm64' and $([MSBuild]::IsOsPlatform('OSX')))" Include="$(RustOutputDirBase)aarch64-apple-darwin/$(RustConfiguration)/libnerdbank_zcash_rust.dylib">
<PackagePath>runtimes/ios-arm64/native/</PackagePath>
</RustBinary>
</ItemGroup>
Expand All @@ -55,8 +64,8 @@
</ItemGroup>
<ItemGroup>
<Rust3rdPartyNotices Include="
$(RustOutputDirBase)THIRD_PARTY_DEPENDENCIES.txt;
$(RustOutputDirBase)THIRD_PARTY_LICENSES.yml;
$(RustIntermediateDirBase)THIRD_PARTY_DEPENDENCIES.txt;
$(RustIntermediateDirBase)THIRD_PARTY_LICENSES.yml;
">
<PackagePath></PackagePath>
</Rust3rdPartyNotices>
Expand Down
3 changes: 3 additions & 0 deletions src/nerdbank-zcash-rust/Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build.env]
volumes = ["__LIB12_DEP=../../external"]

1 change: 1 addition & 0 deletions src/nerdbank-zcash-rust/Generate-3rdPartyNotices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Push-Location $PSScriptRoot

cargo install cargo-bundle-licenses

New-Item -Type Directory -Path $PSScriptRoot/../../obj/src/nerdbank-zcash-rust | Out-Null
cargo tree -f "{p} {l}" -e normal | Out-File -Encoding UTF8 -FilePath "$PSScriptRoot/../../obj/src/nerdbank-zcash-rust/THIRD_PARTY_DEPENDENCIES.txt"
cargo bundle-licenses --format yaml --output "$PSScriptRoot/../../obj/src/nerdbank-zcash-rust/THIRD_PARTY_LICENSES.yml"

Expand Down
7 changes: 0 additions & 7 deletions src/nerdbank-zcash-rust/build_all.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,4 @@ if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}

$configPathSegment = 'debug'
if ($Release) { $configPathSegment = 'release' }
$rustTargets | % {
New-Item -ItemType Directory -Path "..\..\obj\src\nerdbank-zcash-rust\$configPathSegment\$_" -Force | Out-Null
Copy-Item "target/$_/$configPathSegment/*nerdbank_zcash_rust*" "..\..\obj\src\nerdbank-zcash-rust\$configPathSegment\$_"
}

Pop-Location
2 changes: 1 addition & 1 deletion src/nerdbank-zcash-rust/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ async fn watch_mempool(client: &mut CompactTxStreamerClient<Channel>) -> Result<
Ok(())
}

pub fn get_transactions(
pub(crate) fn get_transactions(
db: &mut Db,
conn: &mut rusqlite::Connection,
network: &Network,
Expand Down

0 comments on commit 763e3c7

Please sign in to comment.