Last active
May 5, 2017 23:19
-
-
Save devhawk/b55729cb1a2dfa049e6e42812a77d0f5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| param | |
| ( | |
| [Parameter(Mandatory=$True)][string]$srcPath, | |
| [string]$dstPath = "." | |
| ) | |
| $local_path = join-path $env:LOCALAPPDATA "cppwinrt.android" | |
| if (-not (test-path $local_path)) { | |
| mkdir $local_path | out-null | |
| } | |
| function downloadFile($url, $rel_path) | |
| { | |
| $local_zip = join-path $local_path (split-path -leaf $url) | |
| if (-not (test-path $local_zip)) { | |
| Write-Host "Downloading $url" -ForegroundColor Green | |
| Invoke-WebRequest $url -OutFile $local_zip | |
| } | |
| Write-Host "Installing $(split-path -leaf $url) to $rel_path" -ForegroundColor Green | |
| $expand_path = join-path $local_path $rel_path | |
| Expand-Archive $local_zip $expand_path | |
| } | |
| $cmake_dir = join-path $local_path "cmake" | |
| if (-not (test-path $cmake_dir)) { | |
| $cmake_zip = downloadFile "https://dl.google.com/android/repository/cmake-3.6.3155560-windows-x86_64.zip" "cmake" | |
| } | |
| $ndk_dir = join-path $local_path "android-ndk-r14b" | |
| if (-not (test-path $ndk_dir)) { | |
| $ndk_zip = downloadFile "https://dl.google.com/android/repository/android-ndk-r14b-windows-x86_64.zip" "." | |
| } | |
| $cmake_path = join-path $cmake_dir "bin\cmake.exe" | |
| $ninja_path = join-path $cmake_dir "bin\ninja.exe" | |
| $toolchain_path = join-path $ndk_dir "build\cmake\android.toolchain.cmake" | |
| if (-not (test-path $dstPath)) { mkdir $dstPath | out-null } | |
| $cmake_src_path = resolve-path $srcPath | |
| $cmake_dst_path = resolve-path $dstPath | |
| write-host "running CMake" -ForegroundColor Green | |
| & $cmake_path "-H$cmake_src_path" "-B$cmake_dst_path" "-DANDROID_NDK=$ndk_dir" "-DCMAKE_TOOLCHAIN_FILE=$toolchain_path" "-DCMAKE_MAKE_PROGRAM=$ninja_path" -GNinja -DANDROID_ABI=x86 -DCMAKE_BUILD_TYPE=Debug -DANDROID_TOOLCHAIN=clang "-DANDROID_STL=c++_static" | |
| write-host "running Ninja" -ForegroundColor Green | |
| & $ninja_path -C $cmake_dst_path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment