Skip to content

Commit

Permalink
Fixed leveldb on release
Browse files Browse the repository at this point in the history
  • Loading branch information
cschuchardt88 committed Jan 9, 2025
1 parent 86c526e commit 9e52cbb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 86 deletions.
86 changes: 0 additions & 86 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,67 +13,6 @@ env:
OUTPUT_PATH: /tmp/out

jobs:
build-leveldb:
name: Build leveldb win-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
arch: [x64, arm64]

steps:
# Step to lookup cache for the LevelDB build distribution
- name: Lookup Cache Distribution
id: cache-leveldb
uses: actions/cache@v4
with:
path: ./leveldb/build/Release/*
key: leveldb-${{ matrix.os }}-${{ matrix.arch }}
enableCrossOsArchive: true
lookup-only: true

# Conditionally checkout LevelDB repository if cache is not found
- if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }}
name: Checkout Repository Code (leveldb)
uses: actions/checkout@v4
with:
repository: google/leveldb
path: leveldb
submodules: true
fetch-depth: 0

# Conditionally setup MSBuild if cache is not found
- if: ${{ matrix.os == 'windows-latest' && steps.cache-leveldb.outputs.cache-hit != 'true' }}
name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

# Conditionally setup LevelDB build directory if cache is not found
- if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }}
name: Setup LevelDb
working-directory: ./leveldb
run: mkdir -p ./build/Release

# Conditionally create build files for LevelDB if cache is not found
- if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }}
name: Create Build Files (win-${{ matrix.arch }})
working-directory: ./leveldb/build
run: cmake -DBUILD_SHARED_LIBS=ON -A ${{ matrix.arch }} ..

# Conditionally build LevelDB using MSBuild if cache is not found
- if: ${{ matrix.os == 'windows-latest' && steps.cache-leveldb.outputs.cache-hit != 'true' }}
name: Build (MSBuild)
working-directory: ./leveldb/build
run: msbuild ./leveldb.sln /p:Configuration=Release

# Conditionally cache the LevelDB distribution if it was built
- if: ${{ steps.cache-leveldb.outputs.cache-hit != 'true' }}
name: Cache Distribution
uses: actions/cache/save@v4
with:
path: ./leveldb/build/Release/*
key: leveldb-${{ matrix.os }}-${{ matrix.arch }}
enableCrossOsArchive: true

build-neo-cli:
needs: [build-leveldb]
name: ${{ matrix.runtime }}
Expand Down Expand Up @@ -147,31 +86,6 @@ jobs:
working-directory: ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}
run: rm -v *.xml

# Get cached LevelDB distribution for Windows x64 if applicable
- if: ${{ startsWith(matrix.runtime, 'win-x64') }}
name: Get Distribution Caches (win-x64)
uses: actions/cache@v4
with:
path: ./leveldb/build/Release/*
key: leveldb-windows-latest-x64
enableCrossOsArchive: true
fail-on-cache-miss: true

# Get cached LevelDB distribution for Windows arm64 if applicable
- if: ${{ startsWith(matrix.runtime, 'win-arm64') }}
name: Get Distribution Caches (win-arm64)
uses: actions/cache@v4
with:
path: ./leveldb/build/Release/*
key: leveldb-windows-latest-arm64
enableCrossOsArchive: true
fail-on-cache-miss: true

# Copy LevelDB files to the output directory for Windows
- if: ${{ startsWith(matrix.runtime, 'win') }}
name: Copy Files (leveldb) (win)
run: cp -v ./leveldb/build/Release/leveldb.dll ${{ env.OUTPUT_PATH }}/${{ matrix.runtime }}/libleveldb.dll

# Create the distribution directory
- name: Create Distribution Directory
run: mkdir -p ${{ env.DIST_PATH }}
Expand Down
21 changes: 21 additions & 0 deletions src/Neo.CLI/Neo.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,25 @@
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
</ItemGroup>

<Target Name="DownloadNativeLibs" BeforeTargets="PreBuildEvent">
<DownloadFile Condition="!Exists('runtimes/%(NativeLib.RuntimeId)/native/%(NativeLib.Lib)')" SourceUrl="https://github.com/neo-ngd/leveldb/releases/download/v1.23/libleveldb-%(NativeLib.RuntimeId).zip" DestinationFolder="$(BaseIntermediateOutputPath)" />
<Unzip Condition="Exists('$(BaseIntermediateOutputPath)libleveldb-%(NativeLib.RuntimeId).zip') And !Exists('runtimes/%(NativeLib.RuntimeId)/native/%(NativeLib.Lib)')" SourceFiles="$(BaseIntermediateOutputPath)libleveldb-%(NativeLib.RuntimeId).zip" DestinationFolder="$(BaseIntermediateOutputPath)" />
<Move SourceFiles="$(BaseIntermediateOutputPath)libleveldb-%(NativeLib.RuntimeId)/%(NativeLib.Lib)" DestinationFolder="$(BaseIntermediateOutputPath)libleveldb-%(NativeLib.RuntimeId)/runtimes/%(NativeLib.RuntimeId)/native/" />
</Target>

<ItemGroup>
<NativeLib Include="%(RuntimeId)-%(Lib)" RuntimeId="win-x64" Lib="libleveldb.dll" />
<NativeLib Include="%(RuntimeId)-%(Lib)" RuntimeId="win-arm64" Lib="libleveldb.dll" />
<NativeLib Include="%(RuntimeId)-%(Lib)" RuntimeId="linux-x64" Lib="libleveldb.so" />
<!-- <NativeLib Include="%(RuntimeId)-%(Lib)" RuntimeId="linux-arm64" Lib="libleveldb.so" /> -->
<NativeLib Include="%(RuntimeId)-%(Lib)" RuntimeId="osx-x64" Lib="libleveldb.dylib" />
<NativeLib Include="%(RuntimeId)-%(Lib)" RuntimeId="osx-arm64" Lib="libleveldb.dylib" />

<Content Include="@(NativeLib -> '$(BaseIntermediateOutputPath)libleveldb-%(RuntimeId)/runtimes/%(RuntimeId)/native/%(Lib)')" PackagePath="runtimes/%(RuntimeId)/native/%(Lib)" Link="runtimes/%(RuntimeId)/native/%(Lib)">
<Pack>true</Pack>
<Visible>false</Visible>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>

0 comments on commit 9e52cbb

Please sign in to comment.