summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src/build_tools/test_sdk.py
blob: bd1223a2f1c454dabe41b3d77753138317bdf5a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


import optparse
import os
import sys

import buildbot_common
import build_projects
import build_sdk
import build_version
import parse_dsc

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR)
SDK_LIBRARY_DIR = os.path.join(SDK_SRC_DIR, 'libraries')
SDK_DIR = os.path.dirname(SDK_SRC_DIR)
SRC_DIR = os.path.dirname(SDK_DIR)
OUT_DIR = os.path.join(SRC_DIR, 'out')

sys.path.append(os.path.join(SDK_SRC_DIR, 'tools'))
import getos


TEST_EXAMPLE_LIST = [
  'nacl_io_test',
]

TEST_LIBRARY_LIST = [
  'gmock',
  'gtest',
  'gtest_ppapi',
]


def BuildStepBuildExamples(pepperdir, platform):
  build_sdk.BuildStepMakeAll(pepperdir, platform, 'examples',
                             'Build Examples (Debug)',
                             deps=False, config='Debug')
  build_sdk.BuildStepMakeAll(pepperdir, platform, 'examples',
                             'Build Examples (Release)',
                             deps=False, config='Release')


def BuildStepCopyTests(pepperdir, toolchains, build_experimental, clobber):
  buildbot_common.BuildStep('Copy Tests')

  # Update test libraries and test apps
  filters = {
    'DEST': ['testlibs', 'tests']
  }
  if not build_experimental:
    filters['EXPERIMENTAL'] = False

  tree = parse_dsc.LoadProjectTree(SDK_SRC_DIR, filters=filters)
  platform = getos.GetPlatform()
  build_projects.UpdateHelpers(pepperdir, platform, clobber=clobber)
  build_projects.UpdateProjects(pepperdir, platform, tree, clobber=clobber,
                                toolchains=toolchains)



def BuildStepBuildTests(pepperdir, platform):
  build_sdk.BuildStepMakeAll(pepperdir, platform, 'testlibs',
                             'Build Test Libraries')
  build_sdk.BuildStepMakeAll(pepperdir, platform, 'tests', 'Build Tests',
                             deps=False)


def main(args):
  parser = optparse.OptionParser()
  parser.add_option('--experimental', help='build experimental tests',
                    action='store_true')

  options, args = parser.parse_args(args[1:])

  platform = getos.GetPlatform()
  pepper_ver = str(int(build_version.ChromeMajorVersion()))
  pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver)
  toolchains = ['newlib', 'glibc', 'pnacl', 'host']

  BuildStepBuildExamples(pepperdir, platform)
  BuildStepCopyTests(pepperdir, toolchains, options.experimental, True)
  BuildStepBuildTests(pepperdir, platform)

  return 0


if __name__ == '__main__':
  sys.exit(main(sys.argv))