summaryrefslogtreecommitdiff
path: root/sample-create
diff options
context:
space:
mode:
authorIan Ni-Lewis <ilewis@google.com>2013-09-09 17:01:04 -0700
committerIan Ni-Lewis <ilewis@google.com>2013-09-12 11:04:59 -0700
commiteb640c0bcad1cd944ffeab796c13717902dd0f9f (patch)
tree66f38ce645eaf7015565942b2823a02ec4cf74f9 /sample-create
parent2b1169e2095f5e30f118abd146a62007697cecc3 (diff)
downloadbuild-eb640c0bcad1cd944ffeab796c13717902dd0f9f.tar.gz
Move build tools into their own project.
This CL also fixes a number of path bugs that were exposed by the change in project. Change-Id: I11546d8c68d51cc53deb29267c78d2b7ffaef650
Diffstat (limited to 'sample-create')
-rwxr-xr-xsample-create43
1 files changed, 43 insertions, 0 deletions
diff --git a/sample-create b/sample-create
new file mode 100755
index 00000000..500e4688
--- /dev/null
+++ b/sample-create
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+# Copyright 2013 The Android Open Source Project
+#
+# 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.
+
+# Record the current working directory. This allows us to correctly interpret
+# relative paths
+CALLED_FROM=$( pwd -P )
+
+# Record the location of this script. The assumption is that the script is located in the
+# top-level build directory, so finding the script means finding the build directory.
+SCRIPTNAME=$(basename "$0")
+SCRIPTPATH=$( cd "$(dirname "$0")" ; pwd -P )
+GRADLE=$SCRIPTPATH/gradlew
+
+# Parameter 1 is the path from the cwd to the sample.
+SAMPLE_PATH=""
+if [ -n "$1" ]; then
+ SAMPLE_PATH=$CALLED_FROM/$1
+fi
+
+# Calculate the relative path from the sample location to the main build directory. This
+# allows us to define build dependencies as relative paths, rather than requiring the developer
+# to add them to the environment.
+BUILDPATH=$(perl -e "use File::Spec; print File::Spec->abs2rel(@ARGV)" $SCRIPTPATH $SAMPLE_PATH)
+
+# Same thing for the samples common code: calculate the relative path.
+SAMPLES_COMMON=$( cd $SCRIPTPATH/../samples/android/common ; pwd -P)
+COMMONPATH=$(perl -e "use File::Spec; print File::Spec->abs2rel(@ARGV)" $SAMPLES_COMMON $SAMPLE_PATH)
+
+# Launch a Gradle build with the SampleGen creation parameters on the command line
+$GRADLE -b $SCRIPTPATH/build.gradle --info create -Pout=$SAMPLE_PATH \
+ -PcalledFrom=$CALLED_FROM -PpathToSamplesCommon=$COMMONPATH -PpathToBuild=$BUILDPATH