fplutil
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
Linux 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 Linux example build script.
17 
18 Builds a tiny example using cmake.
19 
20 Run 'build.py --help' for options.
21 """
22 
23 import argparse
24 import os
25 import sys
26 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
27  os.pardir))
28 import buildutil.common
29 import buildutil.linux
30 
31 
32 def main():
33  parser = argparse.ArgumentParser()
34  buildutil.linux.BuildEnvironment.add_arguments(parser)
35  args = parser.parse_args()
36 
37  retval = -1
38 
39  env = buildutil.linux.BuildEnvironment(args)
40 
41  # Add cmake flags specific to our test build.
42  env.cmake_flags = '-DMESSAGE="Hello, World!"'
43 
44  try:
45  env.git_clean()
46  env.run_cmake()
47  env.run_make()
48  env.make_archive(['Hello'], 'output.zip')
49 
50  retval = 0
51 
52  except buildutil.common.Error as e:
53  print >> sys.stderr, 'Caught buildutil error: %s' % e.error_message
54  retval = e.error_code
55 
56  except IOError as e:
57  print >> sys.stderr, 'Caught IOError for file %s: %s' % (e.filename,
58  e.strerror)
59  retval = -1
60 
61  return retval
62 
63 if __name__ == '__main__':
64  sys.exit(main())