build_configuration.dart 1.58 KB
Newer Older
1 2 3 4
// Copyright 2015 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.

5 6
import 'dart:io';

7 8
import 'package:path/path.dart' as path;

9
import 'base/context.dart';
10

11 12 13 14 15 16
enum BuildType {
  prebuilt,
  release,
  debug,
}

17 18 19 20 21 22
enum HostPlatform {
  mac,
  linux,
}

enum TargetPlatform {
23 24 25
  android,
  iOS,
  iOSSimulator,
Ian Hickson's avatar
Ian Hickson committed
26
  mac,
27 28 29
  linux,
}

30 31 32 33 34
HostPlatform getCurrentHostPlatform() {
  if (Platform.isMacOS)
    return HostPlatform.mac;
  if (Platform.isLinux)
    return HostPlatform.linux;
35
  printError('Unsupported host platform, defaulting to Linux');
36 37 38
  return HostPlatform.linux;
}

Ian Hickson's avatar
Ian Hickson committed
39 40 41 42 43
TargetPlatform getCurrentHostPlatformAsTarget() {
  if (Platform.isMacOS)
    return TargetPlatform.mac;
  if (Platform.isLinux)
    return TargetPlatform.linux;
44
  printError('Unsupported host platform, defaulting to Linux');
Ian Hickson's avatar
Ian Hickson committed
45 46 47
  return TargetPlatform.linux;
}

48
class BuildConfiguration {
49 50 51
  BuildConfiguration.prebuilt({
    this.hostPlatform,
    this.targetPlatform,
52 53 54
    this.deviceId,
    this.testable: false
  }) : type = BuildType.prebuilt, buildDir = null;
55 56 57

  BuildConfiguration.local({
    this.type,
58 59
    this.hostPlatform,
    this.targetPlatform,
60
    String enginePath,
61
    String buildPath,
Ian Hickson's avatar
Ian Hickson committed
62 63
    this.deviceId,
    this.testable: false
64 65 66 67 68
  }) : buildDir = path.normalize(path.join(enginePath, buildPath)) {
    assert(type == BuildType.debug || type == BuildType.release);
  }

  final BuildType type;
69 70
  final HostPlatform hostPlatform;
  final TargetPlatform targetPlatform;
71
  final String buildDir;
72
  final String deviceId;
Ian Hickson's avatar
Ian Hickson committed
73
  final bool testable;
74
}