build_info.dart 2.31 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
import 'base/utils.dart';
8
import 'globals.dart';
9

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

16
/// The type of build - `debug`, `profile`, or `release`.
17 18
enum BuildMode {
  debug,
19
  profile,
20
  release
21 22
}

23
String getModeName(BuildMode mode) => getEnumName(mode);
24

25 26 27 28 29
// Returns true if the selected build mode uses ahead-of-time compilation.
bool isAotBuildMode(BuildMode mode) {
  return mode == BuildMode.profile || mode == BuildMode.release;
}

30 31 32
// Returns true if the given build mode can be used on emulators / simulators.
bool isEmulatorBuildMode(BuildMode mode) => mode == BuildMode.debug;

33
enum HostPlatform {
34 35 36 37 38
  darwin_x64,
  linux_x64,
}

String getNameForHostPlatform(HostPlatform platform) {
39 40
  switch (platform) {
    case HostPlatform.darwin_x64:
41
      return 'darwin-x64';
42
    case HostPlatform.linux_x64:
43
      return 'linux-x64';
44 45
  }
  assert(false);
46 47 48
}

enum TargetPlatform {
49
  android_arm,
50
  android_x64,
51
  android_x86,
52
  ios,
53 54
  darwin_x64,
  linux_x64
55 56
}

57
String getNameForTargetPlatform(TargetPlatform platform) {
58 59
  switch (platform) {
    case TargetPlatform.android_arm:
60
      return 'android-arm';
61
    case TargetPlatform.android_x64:
62
      return 'android-x64';
63
    case TargetPlatform.android_x86:
64
      return 'android-x86';
65
    case TargetPlatform.ios:
66
      return 'ios';
67
    case TargetPlatform.darwin_x64:
68
      return 'darwin-x64';
69
    case TargetPlatform.linux_x64:
70
      return 'linux-x64';
71 72
  }
  assert(false);
73 74
}

75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
TargetPlatform getTargetPlatformForName(String platform) {
  switch (platform) {
    case 'android-arm':
      return TargetPlatform.android_arm;
    case 'android-x64':
      return TargetPlatform.android_x64;
    case 'android-x86':
      return TargetPlatform.android_x86;
    case 'ios':
      return TargetPlatform.ios;
    case 'darwin-x64':
      return TargetPlatform.darwin_x64;
    case 'linux-x64':
      return TargetPlatform.linux_x64;
  }
  return null;
}

93 94
HostPlatform getCurrentHostPlatform() {
  if (Platform.isMacOS)
95
    return HostPlatform.darwin_x64;
96
  if (Platform.isLinux)
97 98
    return HostPlatform.linux_x64;

99
  printError('Unsupported host platform, defaulting to Linux');
100 101

  return HostPlatform.linux_x64;
102
}