aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Northrop <cnorthrop@google.com>2016-03-29 10:06:49 -0600
committerCody Northrop <cnorthrop@google.com>2016-03-30 09:13:19 -0600
commit9b0a513981f05fb6240095d548ef7eadaedd70f8 (patch)
tree9c36a727eb6f3e40255e2c6fc0c0783f174dd039
parentbbea4bdeb35d547d14e05874dd46c5ba727e073f (diff)
downloadusermoji-9b0a513981f05fb6240095d548ef7eadaedd70f8.tar.xz
toolchain: Add Android specific update scripts
Pulls in shaderc dependency automatically.
-rw-r--r--buildAndroid/shaderc_revision1
-rwxr-xr-xbuildAndroid/update_external_sources_android.bat238
-rwxr-xr-xbuildAndroid/update_external_sources_android.sh106
3 files changed, 345 insertions, 0 deletions
diff --git a/buildAndroid/shaderc_revision b/buildAndroid/shaderc_revision
new file mode 100644
index 00000000..04b23248
--- /dev/null
+++ b/buildAndroid/shaderc_revision
@@ -0,0 +1 @@
+53cf6692879c6dcd5f4ccdffb8c10bb17b5e9d55
diff --git a/buildAndroid/update_external_sources_android.bat b/buildAndroid/update_external_sources_android.bat
new file mode 100755
index 00000000..dac5f2b9
--- /dev/null
+++ b/buildAndroid/update_external_sources_android.bat
@@ -0,0 +1,238 @@
+@echo off
+REM Update source for glslang, spirv-tools, and shaderc
+
+REM
+REM Copyright 2016 The Android Open Source Project
+REM Copyright (C) 2015 Valve Corporation
+REM
+REM Licensed under the Apache License, Version 2.0 (the "License");
+REM you may not use this file except in compliance with the License.
+REM You may obtain a copy of the License at
+REM
+REM http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM Unless required by applicable law or agreed to in writing, software
+REM distributed under the License is distributed on an "AS IS" BASIS,
+REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM See the License for the specific language governing permissions and
+REM limitations under the License.
+REM
+
+setlocal EnableDelayedExpansion
+set errorCode=0
+set ANDROID_BUILD_DIR=%~dp0
+set BUILD_DIR=%ANDROID_BUILD_DIR%..
+set BASE_DIR=%BUILD_DIR%\..
+set GLSLANG_DIR=%BASE_DIR%\glslang
+set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools
+set SHADERC_DIR=%BASE_DIR%\shaderc
+
+for %%X in (where.exe) do (set FOUND=%%~$PATH:X)
+if not defined FOUND (
+ echo Dependency check failed:
+ echo where.exe not found
+ echo This script requires Windows Vista or later, which includes where.exe.
+ set errorCode=1
+)
+
+where /q git.exe
+if %ERRORLEVEL% equ 1 (
+ echo Dependency check failed:
+ echo git.exe not found
+ echo Git for Windows can be downloaded here: https://git-scm.com/download/win
+ echo Install and ensure git.exe makes it into your PATH
+ set errorCode=1
+)
+
+where /q ndk-build.cmd
+if %ERRORLEVEL% equ 1 (
+ echo Dependency check failed:
+ echo ndk-build.cmd not found
+ echo Android NDK can be downloaded here: http://developer.android.com/ndk/guides/setup.html
+ echo Install and ensure ndk-build.cmd makes it into your PATH
+ set errorCode=1
+)
+
+REM ensure where is working with below false test
+REM where /q foo
+REM if %ERRORLEVEL% equ 1 (
+REM echo foo
+REM )
+
+:main
+
+if %errorCode% neq 0 (goto:error)
+
+REM Read the target versions from external file, which is shared with Linux script
+
+if not exist %BUILD_DIR%\glslang_revision (
+ echo.
+ echo Missing glslang_revision file. Place it in %BUILD_DIR%
+ goto:error
+)
+
+if not exist %BUILD_DIR%\spirv-tools_revision (
+ echo.
+ echo Missing spirv-tools_revision file. Place it in %BUILD_DIR%
+ set errorCode=1
+ goto:error
+)
+
+if not exist %ANDROID_BUILD_DIR%\shaderc_revision (
+ echo.
+ echo Missing shaderc_revision file. Place it in %BUILD_DIR%
+ set errorCode=1
+ goto:error
+)
+
+set /p GLSLANG_REVISION= < glslang_revision
+set /p SPIRV_TOOLS_REVISION= < spirv-tools_revision
+set /p SHADERC_REVISION= < shaderc_revision
+echo GLSLANG_REVISION=%GLSLANG_REVISION%
+echo SPIRV_TOOLS_REVISION=%SPIRV_TOOLS_REVISION%
+echo SHADERC_REVISION=%SHADERC_REVISION%
+
+
+echo Creating and/or updating glslang, spirv-tools, shaderc in %BASE_DIR%
+
+set sync-glslang=1
+set sync-spirv-tools=1
+set sync-shaderc=1
+set build-shaderc=1
+
+if %sync-glslang% equ 1 (
+ if exist %GLSLANG_DIR% (
+ rd /S /Q %GLSLANG_DIR%
+ )
+ if not exist %GLSLANG_DIR% (
+ call:create_glslang
+ )
+ if %errorCode% neq 0 (goto:error)
+ call:update_glslang
+ if %errorCode% neq 0 (goto:error)
+)
+
+if %sync-spirv-tools% equ 1 (
+ if exist %SPIRV_TOOLS_DIR% (
+ rd /S /Q %SPIRV_TOOLS_DIR%
+ )
+ if %errorlevel% neq 0 (goto:error)
+ if not exist %SPIRV_TOOLS_DIR% (
+ call:create_spirv-tools
+ )
+ if %errorCode% neq 0 (goto:error)
+ call:update_spirv-tools
+ if %errorCode% neq 0 (goto:error)
+)
+
+if %sync-shaderc% equ 1 (
+ if exist %SHADERC_DIR% (
+ rd /S /Q %SHADERC_DIR%
+ )
+ if not exist %SHADERC_DIR% (
+ call:create_shaderc
+ )
+ if %errorCode% neq 0 (goto:error)
+ call:update_shaderc
+ if %errorCode% neq 0 (goto:error)
+)
+
+if %build-shaderc% equ 1 (
+ call:build_shaderc
+ if %errorCode% neq 0 (goto:error)
+)
+
+echo.
+echo Exiting
+goto:finish
+
+:error
+echo.
+echo Halting due to error
+goto:finish
+
+:finish
+if not "%cd%\" == "%BUILD_DIR%" ( cd %BUILD_DIR% )
+endlocal
+goto:eof
+
+
+
+REM // ======== Functions ======== //
+
+:create_glslang
+ echo.
+ echo Creating local glslang repository %GLSLANG_DIR%)
+ mkdir %GLSLANG_DIR%
+ cd %GLSLANG_DIR%
+ git clone https://github.com/KhronosGroup/glslang.git .
+ git checkout %GLSLANG_REVISION%
+ if not exist %GLSLANG_DIR%\SPIRV (
+ echo glslang source download failed!
+ set errorCode=1
+ )
+goto:eof
+
+:update_glslang
+ echo.
+ echo Updating %GLSLANG_DIR%
+ cd %GLSLANG_DIR%
+ git fetch --all
+ git checkout %GLSLANG_REVISION%
+goto:eof
+
+:create_spirv-tools
+ echo.
+ echo Creating local spirv-tools repository %SPIRV_TOOLS_DIR%)
+ mkdir %SPIRV_TOOLS_DIR%
+ cd %SPIRV_TOOLS_DIR%
+ git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
+ git checkout %SPIRV_TOOLS_REVISION%
+ if not exist %SPIRV_TOOLS_DIR%\source (
+ echo spirv-tools source download failed!
+ set errorCode=1
+ )
+goto:eof
+
+:update_spirv-tools
+ echo.
+ echo Updating %SPIRV_TOOLS_DIR%
+ cd %SPIRV_TOOLS_DIR%
+ git fetch --all
+ git checkout %SPIRV_TOOLS_REVISION%
+goto:eof
+
+:create_shaderc
+ echo.
+ echo Creating local shaderc repository %SHADERC_DIR%)
+ mkdir %SHADERC_DIR%
+ cd %SHADERC_DIR%
+ git clone git@github.com:google/shaderc.git .
+ git checkout %SHADERC_REVISION%
+ if not exist %SHADERC_DIR%\libshaderc (
+ echo shaderc source download failed!
+ set errorCode=1
+ )
+goto:eof
+
+:update_shaderc
+ echo.
+ echo Updating %SHADERC_DIR%
+ cd %SHADERC_DIR%
+ git fetch --all
+ git checkout %SHADERC_REVISION%
+goto:eof
+
+:build_shaderc
+ echo.
+ echo Building %SHADERC_DIR%
+ cd %SHADERC_DIR%\android_test
+ echo Building shaderc with Android NDK
+ call ndk-build THIRD_PARTY_PATH=../.. -j 4
+ REM Check for existence of one lib, even though we should check for all results
+ if not exist %SHADERC_DIR%\android_test\obj\local\x86\libshaderc.a (
+ echo.
+ echo shaderc build failed!
+ set errorCode=1
+ )
+goto:eof
diff --git a/buildAndroid/update_external_sources_android.sh b/buildAndroid/update_external_sources_android.sh
new file mode 100755
index 00000000..0e788220
--- /dev/null
+++ b/buildAndroid/update_external_sources_android.sh
@@ -0,0 +1,106 @@
+#!/bin/bash
+# Update source for glslang, spirv-tools, shaderc
+
+# Copyright 2016 The Android Open Source Project
+# Copyright (C) 2015 Valve Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+ANDROIDBUILDDIR=$PWD
+BUILDDIR=$ANDROIDBUILDDIR/..
+BASEDIR=$BUILDDIR/..
+
+GLSLANG_REVISION=$(cat $BUILDDIR/glslang_revision)
+SPIRV_TOOLS_REVISION=$(cat $BUILDDIR/spirv-tools_revision)
+SHADERC_REVISION=$(cat $ANDROIDBUILDDIR/shaderc_revision)
+
+echo "GLSLANG_REVISION=$GLSLANG_REVISION"
+echo "SPIRV_TOOLS_REVISION=$SPIRV_TOOLS_REVISION"
+echo "SHADERC_REVISION=$SHADERC_REVISION"
+
+function create_glslang () {
+ rm -rf $BASEDIR/glslang
+ echo "Creating local glslang repository ($BASEDIR/glslang)."
+ mkdir -p $BASEDIR/glslang
+ cd $BASEDIR/glslang
+ git clone https://github.com/KhronosGroup/glslang.git .
+ git checkout $GLSLANG_REVISION
+}
+
+function update_glslang () {
+ echo "Updating $BASEDIR/glslang"
+ cd $BASEDIR/glslang
+ git fetch --all
+ git checkout $GLSLANG_REVISION
+}
+
+function create_spirv-tools () {
+ rm -rf $BASEDIR/spirv-tools
+ echo "Creating local spirv-tools repository ($BASEDIR/spirv-tools)."
+ mkdir -p $BASEDIR/spirv-tools
+ cd $BASEDIR/spirv-tools
+ git clone https://github.com/KhronosGroup/SPIRV-Tools.git .
+ git checkout $SPIRV_TOOLS_REVISION
+}
+
+function update_spirv-tools () {
+ echo "Updating $BASEDIR/spirv-tools"
+ cd $BASEDIR/spirv-tools
+ git fetch --all
+ git checkout $SPIRV_TOOLS_REVISION
+}
+
+function create_shaderc () {
+ rm -rf $BASEDIR/shaderc
+ echo "Creating local shaderc repository ($BASEDIR/shaderc)."
+ cd $BASEDIR
+ git clone git@github.com:google/shaderc.git
+ cd shaderc
+ git checkout $SHADERC_REVISION
+}
+
+function update_shaderc () {
+ echo "Updating $BASEDIR/shaderc"
+ cd $BASEDIR/shaderc
+ git fetch --all
+ git checkout $SHADERC_REVISION
+}
+
+function build_shaderc () {
+ echo "Building $BASEDIR/shaderc"
+ cd $BASEDIR/shaderc/android_test
+ ndk-build THIRD_PARTY_PATH=../.. -j 4
+}
+
+if [ ! -d "$BASEDIR/glslang" -o ! -d "$BASEDIR/glslang/.git" -o -d "$BASEDIR/glslang/.svn" ]; then
+ create_glslang
+fi
+ update_glslang
+
+
+if [ ! -d "$BASEDIR/spirv-tools" -o ! -d "$BASEDIR/spirv-tools/.git" ]; then
+ create_spirv-tools
+fi
+update_spirv-tools
+
+if [ ! -d "$BASEDIR/shaderc" -o ! -d "$BASEDIR/shaderc/.git" ]; then
+ create_shaderc
+fi
+update_shaderc
+build_shaderc
+
+echo ""
+echo "${0##*/} finished."
+