fplutil
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
Android Buildutil Example
1 #!/usr/bin/python
2 # Copyright 2014 Google Inc. All rights reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 """@file build.py Android example build script.
17 
18 Copies an NDK sample to the current directory and builds it.
19 
20 Run 'build.py --help' for options.
21 """
22 
23 import argparse
24 import os
25 import shutil
26 import sys
27 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
28  os.pardir))
29 import buildutil.android
30 import buildutil.common
31 
32 
33 def main():
34  # Parse arguments and create the build environment.
35  parser = argparse.ArgumentParser()
36  buildutil.android.BuildEnvironment.add_arguments(parser)
37  args = parser.parse_args()
38  env = buildutil.android.BuildEnvironment(args)
39 
40  # Clean the git working copy.
41  env.git_clean()
42 
43  # Copy one of the NDK samples here and build it
44  samplename = 'native-plasma'
45  samplepath = os.path.join(env.ndk_home, 'samples', samplename)
46  shutil.rmtree(samplename, True)
47  shutil.copytree(samplepath, samplename)
48 
49  # Build the sample.
50  (rc, errmsg) = env.build_all()
51  if (rc == 0):
52  # Archive the sample built in the apks directory to output.zip.
53  env.make_archive(['apks'], 'output.zip', exclude=['objs', 'objs-debug'])
54  else:
55  print >> sys.stderr, errmsg
56 
57  return rc
58 
59 if __name__ == '__main__':
60  sys.exit(main())