Skip to content

Commit 4e1359b

Browse files
Merge pull request #149 from leti367/dev/addsupportforosxandlinux
Update azure-pipelines.ym to be able to build for osx-arm64 and linux-arm64
2 parents 36cfc6d + 3289c18 commit 4e1359b

File tree

9 files changed

+229
-17
lines changed

9 files changed

+229
-17
lines changed

azure-pipelines.yml

Lines changed: 90 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ trigger:
33

44
variables:
55
windowsDllName: "blingfiretokdll.dll"
6-
macDllName: "libblingfiretokdll.dylib"
6+
osxDllName: "libblingfiretokdll.dylib"
77
linuxDllName: "libblingfiretokdll.so"
88
win_X64_Artifact: "DllForWinX64"
99
win_Arm64_Artifact: "DllForWinArm64"
10-
mac_X64_Artifact: "DllForMacX64"
10+
osx_X64_Artifact: "DllForOsxX64"
11+
osx_arm64_Artifact: "DllForOsxArm64"
1112
linux_X64_Artifact: "DllForLinuxX64"
13+
linux_Arm64_Artifact: "DllForLinuxArm64"
1214

1315
jobs:
1416
- job: Build_Dll_For_Win_X64
@@ -104,7 +106,7 @@ jobs:
104106
PathtoPublish: '$(Build.ArtifactStagingDirectory)/native'
105107
ArtifactName: $(win_ARM64_Artifact)
106108

107-
- job: Build_Dll_For_Mac_X64
109+
- job: Build_Dll_For_Osx_X64
108110
pool:
109111
vmImage: macOS-latest
110112

@@ -135,7 +137,7 @@ jobs:
135137
make
136138
137139
- task: CmdLine@2
138-
displayName: 'Validate binaries for macos-x64'
140+
displayName: 'Validate binaries for osx-x64'
139141
inputs:
140142
script: |
141143
cd ./nuget/test/
@@ -144,19 +146,19 @@ jobs:
144146
dotnet ./bin/Debug/net6.0/BlingUtilsTest.dll
145147
146148
- task: CopyFiles@2
147-
displayName: 'Copy $(macDllName) to: $(Build.ArtifactStagingDirectory)'
149+
displayName: 'Copy $(osxDllName) to: $(Build.ArtifactStagingDirectory)'
148150
inputs:
149151
SourceFolder: 'Release'
150-
Contents: $(macDllName)
152+
Contents: $(osxDllName)
151153
TargetFolder: '$(build.artifactstagingdirectory)/native'
152154

153155
- task: PublishBuildArtifacts@1
154-
displayName: 'Publish Artifact: $(macDllName)'
156+
displayName: 'Publish Artifact: $(osxDllName)'
155157
inputs:
156158
PathtoPublish: '$(Build.ArtifactStagingDirectory)/native'
157-
ArtifactName: $(mac_X64_Artifact)
159+
ArtifactName: $(osx_X64_Artifact)
158160

159-
- job: Build_Dll_For_Mac_ARM64
161+
- job: Build_Dll_For_Osx_ARM64
160162
pool:
161163
vmImage: macOS-latest
162164

@@ -177,7 +179,7 @@ jobs:
177179
displayName: 'CMake'
178180
inputs:
179181
workingDirectory: 'Release'
180-
cmakeArgs: '-D CMAKE_OSX_ARCHITECTURES=arm64 ..'
182+
cmakeArgs: '-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_BUILD_TYPE=Release ..'
181183

182184
- task: CmdLine@2
183185
displayName: build project
@@ -187,17 +189,17 @@ jobs:
187189
make
188190
189191
- task: CopyFiles@2
190-
displayName: 'Copy $(macDllName) to: $(Build.ArtifactStagingDirectory)'
192+
displayName: 'Copy $(osxDllName) to: $(Build.ArtifactStagingDirectory)'
191193
inputs:
192194
SourceFolder: 'Release'
193-
Contents: $(macDllName)
195+
Contents: $(osxDllName)
194196
TargetFolder: '$(build.artifactstagingdirectory)/native'
195197

196198
- task: PublishBuildArtifacts@1
197-
displayName: 'Publish Artifact: $(macDllName)'
199+
displayName: 'Publish Artifact: $(osxDllName)'
198200
inputs:
199201
PathtoPublish: '$(Build.ArtifactStagingDirectory)/native'
200-
ArtifactName: $(mac_X64_Artifact)
202+
ArtifactName: $(osx_arm64_Artifact)
201203

202204
- job: Build_Dll_For_Linux_X64
203205
pool:
@@ -251,28 +253,99 @@ jobs:
251253
PathtoPublish: '$(Build.ArtifactStagingDirectory)/native'
252254
ArtifactName: $(linux_X64_Artifact)
253255

256+
- job: Build_Dll_For_Linux_ARM64
257+
pool:
258+
vmImage: ubuntu-latest
259+
260+
steps:
261+
- task: CmdLine@2
262+
displayName: Create release folder
263+
inputs:
264+
script: |
265+
mkdir Release
266+
267+
- task: CmdLine@2
268+
displayName: Install cross-compile tools
269+
inputs:
270+
script: |
271+
sudo apt-get update
272+
sudo apt-get install -y gcc-aarch64-linux-gnu
273+
sudo apt-get install -y g++-aarch64-linux-gnu
274+
275+
- task: CMake@1
276+
displayName: 'CMake'
277+
inputs:
278+
workingDirectory: 'Release'
279+
cmakeArgs: '-DCMAKE_TOOLCHAIN_FILE=../buildTools/linux-arm64-cross.cmake -DCMAKE_BUILD_TYPE=Release ..'
280+
281+
- task: CmdLine@2
282+
displayName: build project
283+
inputs:
284+
script: |
285+
cd ./Release
286+
make
287+
288+
- task: CopyFiles@2
289+
displayName: 'Copy $(linuxDllName) to: $(Build.ArtifactStagingDirectory)'
290+
inputs:
291+
SourceFolder: 'Release'
292+
Contents: $(linuxDllName)
293+
TargetFolder: '$(build.artifactstagingdirectory)/native'
294+
295+
- task: PublishBuildArtifacts@1
296+
displayName: 'Publish Artifact: $(linuxDllName)'
297+
inputs:
298+
PathtoPublish: '$(Build.ArtifactStagingDirectory)/native'
299+
ArtifactName: $(linux_Arm64_Artifact)
300+
254301
- job: buildNugetPackage
255302
dependsOn:
256303
- Build_Dll_For_Win_X64
257304
- Build_Dll_For_Win_ARM64
258-
- Build_Dll_For_Mac_X64
305+
- Build_Dll_For_Osx_X64
306+
- Build_Dll_For_Osx_ARM64
259307
- Build_Dll_For_Linux_X64
308+
- Build_Dll_For_Linux_ARM64
260309
condition: succeeded()
261310

262311
pool:
263312
vmImage: windows-latest
264313
steps:
265314
- task: DownloadBuildArtifacts@0
266-
displayName: 'Download Build Artifacts'
315+
displayName: 'Download Build Artifacts for windows x64'
267316
inputs:
268317
artifactName: $(win_X64_Artifact)
269318
downloadPath: 'nuget/lib/runtimes/win-x64/native'
270319

271320
- task: DownloadBuildArtifacts@0
272-
displayName: 'Download Build Artifacts'
321+
displayName: 'Download Build Artifacts for windows arm64'
273322
inputs:
274323
artifactName: $(win_Arm64_Artifact)
275324
downloadPath: 'nuget/lib/runtimes/win-arm64/native'
325+
326+
- task: DownloadBuildArtifacts@0
327+
displayName: 'Download Build Artifacts for osx x64'
328+
inputs:
329+
artifactName: $(osx_X64_Artifact)
330+
downloadPath: 'nuget/lib/runtimes/osx-x64/native'
331+
332+
- task: DownloadBuildArtifacts@0
333+
displayName: 'Download Build Artifacts for osx arm64'
334+
inputs:
335+
artifactName: $(osx_Arm64_Artifact)
336+
downloadPath: 'nuget/lib/runtimes/osx-arm64/native'
337+
338+
- task: DownloadBuildArtifacts@0
339+
displayName: 'Download Build Artifacts for linux x64'
340+
inputs:
341+
artifactName: $(linux_X64_Artifact)
342+
downloadPath: 'nuget/lib/runtimes/linux-x64/native'
343+
344+
- task: DownloadBuildArtifacts@0
345+
displayName: 'Download Build Artifacts for linux Arm64'
346+
inputs:
347+
artifactName: $(linux_Arm64_Artifact)
348+
downloadPath: 'nuget/lib/runtimes/linux-arm64/native'
276349

277350
- task: DotNetCoreCLI@2
278351
inputs:

buildTools/linux-arm64-cross.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set(CMAKE_SYSTEM_NAME Linux)
2+
set(CMAKE_SYSTEM_PROCESSOR aarch64)
3+
4+
# which C and C++ complier to use
5+
set(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-gcc-9")
6+
set(CMAKE_CXX_COMPILER "/usr/bin/aarch64-linux-gnu-g++-9")
7+
8+
# Where to look for the target environment. (More paths can be added here)
9+
set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)
10+
11+
# Adjust the default behavior of the FIND_XXX() commands:
12+
# search programs in the host environment only.
13+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
14+
15+
# Search headers and libraries in the target environment only.
16+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
17+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
18+
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

images/artifacts.png

137 KB
Loading

images/buildResults.png

79.4 KB
Loading

images/cpparm64buildtools.png

261 KB
Loading

nuget/lib/BlingFireNuget.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@
4242
<ItemGroup>
4343
<None Include="runtimes\osx-x64\native\*" Pack="true" PackagePath="runtimes\osx-x64\native" PackageCopyToOutput="true" />
4444
</ItemGroup>
45+
<ItemGroup>
46+
<None Include="runtimes\osx-arm64\native\*" Pack="true" PackagePath="runtimes\osx-arm64\native" PackageCopyToOutput="true" />
47+
</ItemGroup>
4548
<ItemGroup>
4649
<None Include="runtimes\linux-x64\native\*" Pack="true" PackagePath="runtimes\linux-x64\native" PackageCopyToOutput="true" />
4750
</ItemGroup>
51+
<ItemGroup>
52+
<None Include="runtimes\linux-arm64\native\*" Pack="true" PackagePath="runtimes\linux-arm64\native" PackageCopyToOutput="true" />
53+
</ItemGroup>
4854
<ItemGroup>
4955
<None Include="*.bin" Pack="true" PackagePath="$(ContentTargetFolders)\cs\any" PackageCopyToOutput="true" />
5056
</ItemGroup>
1.46 MB
Binary file not shown.
1.39 MB
Binary file not shown.

nuget/readme.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,118 @@ When you publish to GitHub the lib directory should contain nuget.config file wi
109109
</packageSourceCredentials>
110110
</configuration>
111111
```
112+
113+
# Build Bling Fire dlls/NuGet package with Azure DevOps build pipeline
114+
115+
Now we can use Azure DevOps to build BlingFire dlls and NuGet package.
116+
117+
Pipeline file [azure-pipelines.yml](../azure-pipelines.yml) is now updated to be able to build BlingFire dlls for windows-x64, windows-arm64, osx-x64, osx-arm-64, linux-x64, linux-arm64.
118+
119+
Here are some good documentations about how to create Azure DevOps pipelines:
120+
121+
1. [Create your first pipeline.](https://docs.microsoft.com/en-us/azure/devops/pipelines/create-first-pipeline?view=azure-devops&tabs=java%2Ctfs-2018-2%2Cbrowser)
122+
2. [Build GitHub repositories.](https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml)
123+
124+
A good thing about using Azure DevOps is: it provides [list of Microsoft-hosted agents](https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml), which include Windows, Linux and Osx, with all the popular tools pre-installed.
125+
126+
However, there are no ARM64 microsoft-hosted agents yet, so currently in [azure-pipelines.yml](../azure-pipelines.yml) all the ARM64 dlls are built with cmake cross-compiling from X64 agents.
127+
<br/><br/>
128+
129+
## Build pipeline for Github BlingFire repo
130+
A [build pipeline](https://devdiv.visualstudio.com/DevDiv/_build?definitionId=16503&_a=summary) for [Github BlingFire repo](https://github.com/microsoft/BlingFire) is created (only accessble by Microsoft interal users). It will be triggered whenerver thare's new commeits to master branch.
131+
<br/><br/>
132+
133+
## Get dlls and NuGet from Azure DevOps Build pipeline
134+
When the one instance of the build pipeline completed sucessfuly, 7 artifacts will be avaible to download from Azure DevOps.
135+
136+
We can find the artifacts by clicking the highlighted <mark>"7 published"</mark> as shows in the following image.
137+
<img title="" alt="" src="../images/buildResults.png">
138+
139+
Then we can find the artifacts:
140+
<img title="" alt="" src="../images/artifacts.png">
141+
142+
The first 6 are native dlls for each platform, the last one is the Nuget package of Bling Fire with all the latest dlls. To download, simply click on them.
143+
<br/><br/>
144+
145+
146+
# Build Bling Fire Dlls/Nuget package locally
147+
We can follow steps in [azure-pipelines.yml](../azure-pipelines.yml) to build dlls locally.
148+
149+
## windows-x64
150+
Build platform is windows-x64.
151+
Please make sure visual studio 'Desktop development with C++' is installed.
152+
steps:
153+
```
154+
1. cd BlingFire
155+
2. mkdir Release
156+
3. cd Release
157+
4. cmake ..
158+
5. MSBuild.exe /property:Configuration=Release .\BLING_FIRE.sln
159+
```
160+
161+
## windows-arm64
162+
Build platform is windows-x64.
163+
Please make sure visual studio 'Desktop development with C++' is installed.
164+
Please Install 'c++ arm64 build tools' through visual studio:
165+
<img title="" alt="" src="../images/cpparm64buildtools.png">
166+
steps:
167+
```
168+
1. cd BlingFire
169+
2. mkdir Release
170+
3. cd Release
171+
4. cmake -A ARM64 ..
172+
5. MSBuild.exe /property:Configuration=Release .\BLING_FIRE.sln
173+
```
174+
175+
## osx-x64
176+
Build platform osx-x64.
177+
please make sure 'make' and 'cmake' is installed.(xcode should have all the necessary tools)
178+
```
179+
1. cd BlingFire
180+
2. mkdir Release
181+
3. cd Release
182+
4. cmake ..
183+
5. make
184+
```
185+
## osx-arm64 (cross-compiling from osx-x64)
186+
Build platform is osx-64.
187+
Installing xcode should provide all the necessary tools for cross-compiling.
188+
```
189+
1. cd BlingFire
190+
2. mkdir Release
191+
3. cd Release
192+
4. cmake -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_BUILD_TYPE=Release ..
193+
5. make
194+
```
195+
196+
## linux-x64
197+
Build platform is linux-x64.
198+
Please make sure 'make' and 'cmake' is installed.
199+
```
200+
1. cd BlingFire
201+
2. mkdir Release
202+
3. cd Release
203+
4. cmake ..
204+
5. make
205+
```
206+
207+
## linux-arm64
208+
Build platform is linux-x64.
209+
Please make sure 'make' and 'cmake' is installed.
210+
Please run the following steps to install the aarch64 supported tools:
211+
```
212+
1. sudo apt-get update
213+
2. sudo apt-get install -y gcc-aarch64-linux-gnu
214+
3. sudo apt-get install -y g++-aarch64-linux-gnu
215+
```
216+
217+
Also, [cmake toolchain file](../buildTools/linux-arm64-cross.cmake) is used for cross-compiling.
218+
219+
```
220+
2. cd BlingFire
221+
3. mkdir Release
222+
4. cd Release
223+
5. cmake -DCMAKE_TOOLCHAIN_FILE=../buildTools/linux-arm64-cross.cmake -DCMAKE_BUILD_TYPE=Release ..
224+
6. make
225+
```
226+

0 commit comments

Comments
 (0)