Esempio n. 1
0
  def test_build_dir_android(self):
    # Android is a special case where we always want to see the CPU
    # type, but only the platform name when it's not the default.
    tmp_file = tempfile.NamedTemporaryFile(mode='w')
    tmp_file.write('target_os = ["android", "chromeos", "linux"]')
    tmp_file.flush()
    environ = env.Env(os.getcwd(), tmp_file.name)
    environ.build_platform = 'linux'
    opts = options.Options(environ, models.Configuration())
    exp = variable_expander.VariableExpander(opts)
    opts.buildopts.target_os = 'android'

    # Default CPU type should be None so no cpu appended to dir.
    self.assertEqual(os.path.basename(exp.get_value('Build_dir')),
                     'Debug')

    opts.buildopts.target_cpu = 'arm'
    self.assertEqual(os.path.basename(exp.get_value('Build_dir')),
                     'Debug-arm')

    opts.buildopts.target_cpu = 'x86'
    self.assertEqual(os.path.basename(exp.get_value('Build_dir')),
                     'Debug-x86')

    # Now as the non-default platform.
    tmp_file = tempfile.NamedTemporaryFile(mode='w')
    tmp_file.write('target_os = ["chromeos", "android", "linux"]')
    tmp_file.flush()
    environ = env.Env(os.getcwd(), tmp_file.name)
    environ.build_platform = 'linux'
    opts = options.Options(environ, models.Configuration())
    exp = variable_expander.VariableExpander(opts)
    opts.buildopts.target_os = 'android'

    # Default CPU type should be None.
    self.assertEqual(os.path.basename(exp.get_value('Build_dir')),
                     'Debug-android')

    opts.buildopts.target_cpu = 'arm'
    self.assertEqual(os.path.basename(exp.get_value('Build_dir')),
                     'Debug-android-arm')

    opts.buildopts.target_cpu = 'x86'
    self.assertEqual(os.path.basename(exp.get_value('Build_dir')),
                     'Debug-android-x86')
Esempio n. 2
0
 def _create_options(self, target_os='linux'):
   environ = env.Env(os.getcwd(),
                     GetAbsPathRelativeToThisFilesDir('gclient.txt'))
   environ.android_devices = {
       'phonyarm': adb.DeviceInfo('phonyarm', 28,
                                  'arm64-v8a',
                                  ['com.android.webview'])}
   opts = options.Options(environ, models.Configuration())
   opts.buildopts.target_os = target_os
   return opts
Esempio n. 3
0
    def test_default_target_os(self):
        opts = TestOptions._create_opts()
        opts.parse(['all'])
        # The default target OS is the first one in the gclient file.
        self.assertEqual('linux', opts.buildopts.target_os)

        tmp_file = tempfile.NamedTemporaryFile(mode='w')
        tmp_file.write('target_os = ["android", "chromeos", "linux"]')
        tmp_file.flush()
        opts = options.Options(TestOptions._create_env(tmp_file.name),
                               models.Configuration())
        opts.parse(['--cpu=arm64', 'all'])
        self.assertEqual('android', opts.buildopts.target_os)
Esempio n. 4
0
  def test_get_target_with_reference(self):
    parent_target = models.Target('parent-name')
    child_target = models.Target('child-name')

    parent_target.add_upstream_target(models.TargetReference(child_target,
                                                             None,
                                                             False))
    parent_target.reference_self = False

    config = models.Configuration()
    config.add_target(child_target)
    config.add_target(parent_target)

    targets = config.get_build_targets(['parent-name'], self._create_options())
    self.assertSetEqual(targets, set(('child-name',)),
                        'Unexpected target sets')
Esempio n. 5
0
 def _create_opts(self, build_platform='linux'):
   environ = env.Env(os.getcwd(),
                     GetAbsPathRelativeToThisFileDir('gclient.txt'))
   environ.build_platform = build_platform
   return options.Options(environ, models.Configuration())
Esempio n. 6
0
 def _create_opts():
     return options.Options(TestOptions._create_env(),
                            models.Configuration())