-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_native.ps1
112 lines (105 loc) · 3.39 KB
/
build_native.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
$AndroidNDK = "C:\Microsoft\AndroidNDK"
$AndroidNDKVersion= "android-ndk-r23c"
$AndroidCMakeToolchainFile = "$AndroidNDK\$AndroidNDKVersion\build\cmake\android.toolchain.cmake"
$WorldDir = $(Get-Location).Path + "\third_parties\World"
$AllNames = @(
"android-arm64-v8a-release",
"android-armeabi-v7a-release",
"android-x86-release",
"android-x86_64-release",
"win-x86",
"win-x64"
)
function Run-Build
{
param (
$Name,
$Project
)
$Args = @(".", "-B", ".\out\build\$Name")
if ($Name -match "^android-(.+)-(release|debug)$")
{
$AndroidABI = $Matches.1
$Args += @("-D", "CMAKE_TOOLCHAIN_FILE=$AndroidCMakeToolchainFile")
$Args += @("-D", "ANDROID_ABI=$AndroidABI", "-D", "ANDROID_NATIVE_API_LEVEL=26")
$Args += @("-G", "Ninja")
if ($Project -ne "World")
{
$Args += @(
"-D",
"WORLD_INC=$WorldDir\out\install\win-x64-release\include",
"-D",
"WORLD_LIB=$WorldDir\out\install\$Name\lib")
}
cmake $Args
if ($Project -eq "World")
{
cmake --build .\out\build\$Name --config Release --target lib/libworld.a
}
else
{
cmake --build .\out\build\$Name --config Release
}
cmake --install .\out\build\$Name --prefix .\out\install\$Name
}
else
{
if ($Name.StartsWith("win-x64"))
{
$Args += @("-A", "x64")
}
else
{
$Args += @("-A", "Win32")
}
if ($Project -ne "World")
{
$Args += @(
"-D",
"WORLD_INC=$WorldDir\out\install\$Name\include",
"-D",
"WORLD_LIB=$WorldDir\out\install\$Name\lib")
}
cmake $Args
cmake --build .\out\build\$Name --config Release
cmake --install .\out\build\$Name --prefix .\out\install\$Name
}
}
function Make-AndroidAAR
{
Remove-Item ".\out\temp.zip"
Remove-Item -Recurse ".\out\temp"
New-Item -Path ".\out\temp" -Type directory
foreach ($Name in $AllNames)
{
if ($Name -match "^android-(.+)-(release|debug)$")
{
$AndroidABI = $Matches.1
$dest = ".\out\temp\jni\$AndroidABI"
New-Item -Path $dest -Type directory
Copy-Item ".\out\install\$Name\lib\*.so" $dest
}
}
Copy-Item AndroidManifest.xml ".\out\android-release"
Compress-Archive ".\out\temp\*" .\out\temp.zip
New-Item -Path ".\out\install\android-release" -Type directory
Move-Item .\out\temp.zip ".\out\install\android-release\voice100_native.aar"
Remove-Item -Recurse ".\out\temp"
}
pushd third_parties\World
Run-Build -Name win-x64-release -Project World
Run-Build -Name win-x86-release -Project World
Run-Build -Name android-arm64-v8a-release -Project World
Run-Build -Name android-armeabi-v7a-release -Project World
Run-Build -Name android-x86-release -Project World
Run-Build -Name android-x86_64-release -Project World
popd
pushd Voice100.Native
Run-Build -Name win-x64-release -Project native
Run-Build -Name win-x86-release -Project native
Run-Build -Name android-arm64-v8a-release -Project native
Run-Build -Name android-armeabi-v7a-release -Project native
Run-Build -Name android-x86-release -Project native
Run-Build -Name android-x86_64-release -Project native
Make-AndroidAAR
popd