project.dart 22.3 KB
Newer Older
1 2 3 4 5
// Copyright 2018 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 'dart:async';
6

7
import 'package:meta/meta.dart';
8
import 'package:yaml/yaml.dart';
9

10
import 'android/gradle.dart' as gradle;
11
import 'base/common.dart';
12
import 'base/file_system.dart';
13
import 'build_info.dart';
14
import 'bundle.dart' as bundle;
15 16
import 'cache.dart';
import 'flutter_manifest.dart';
17 18
import 'ios/ios_workflow.dart';
import 'ios/plist_utils.dart' as plist;
19
import 'ios/xcodeproj.dart' as xcode;
20
import 'plugins.dart';
21
import 'template.dart';
22
import 'web/web_device.dart';
23 24

/// Represents the contents of a Flutter project at the specified [directory].
25
///
26 27 28 29 30 31 32
/// [FlutterManifest] information is read from `pubspec.yaml` and
/// `example/pubspec.yaml` files on construction of a [FlutterProject] instance.
/// The constructed instance carries an immutable snapshot representation of the
/// presence and content of those files. Accordingly, [FlutterProject] instances
/// should be discarded upon changes to the `pubspec.yaml` files, but can be
/// used across changes to other files, as no other file-level information is
/// cached.
33
class FlutterProject {
34
  @visibleForTesting
35
  FlutterProject(this.directory, this.manifest, this._exampleManifest)
36 37 38
    : assert(directory != null),
      assert(manifest != null),
      assert(_exampleManifest != null);
39

40 41
  /// Returns a future that completes with a [FlutterProject] view of the given directory
  /// or a ToolExit error, if `pubspec.yaml` or `example/pubspec.yaml` is invalid.
42
  static Future<FlutterProject> fromDirectory(Directory directory) async {
43 44
    assert(directory != null);
    final FlutterManifest manifest = await _readManifest(
45 46
      directory.childFile(bundle.defaultManifestPath).path,
    );
47 48
    final FlutterManifest exampleManifest = await _readManifest(
      _exampleDirectory(directory).childFile(bundle.defaultManifestPath).path,
49
    );
50
    return FlutterProject(directory, manifest, exampleManifest);
51
  }
52

53 54
  /// Returns a future that completes with a [FlutterProject] view of the current directory.
  /// or a ToolExit error, if `pubspec.yaml` or `example/pubspec.yaml` is invalid.
55 56
  static Future<FlutterProject> current() => fromDirectory(fs.currentDirectory);

57 58
  /// Returns a future that completes with a [FlutterProject] view of the given directory.
  /// or a ToolExit error, if `pubspec.yaml` or `example/pubspec.yaml` is invalid.
59
  static Future<FlutterProject> fromPath(String path) => fromDirectory(fs.directory(path));
60 61 62 63

  /// The location of this project.
  final Directory directory;

64
  /// The manifest of this project.
65 66
  final FlutterManifest manifest;

67
  /// The manifest of the example sub-project of this project.
68
  final FlutterManifest _exampleManifest;
69

70
  /// The set of organization names found in this project as
71 72
  /// part of iOS product bundle identifier, Android application ID, or
  /// Gradle group ID.
73 74 75 76 77 78 79 80
  Set<String> get organizationNames {
    final List<String> candidates = <String>[
      ios.productBundleIdentifier,
      android.applicationId,
      android.group,
      example.android.applicationId,
      example.ios.productBundleIdentifier,
    ];
81
    return Set<String>.from(candidates
82
        .map<String>(_organizationNameFromPackageName)
83
        .where((String name) => name != null));
84 85 86 87 88 89 90 91 92 93
  }

  String _organizationNameFromPackageName(String packageName) {
    if (packageName != null && 0 <= packageName.lastIndexOf('.'))
      return packageName.substring(0, packageName.lastIndexOf('.'));
    else
      return null;
  }

  /// The iOS sub project of this project.
94
  IosProject get ios => IosProject.fromFlutter(this);
95 96

  /// The Android sub project of this project.
97
  AndroidProject get android => AndroidProject._(this);
98

99 100 101
  /// The web sub project of this project.
  WebProject get web => WebProject._(this);

102 103 104 105 106 107 108 109 110
  /// The macos sub project of this project.
  MacOSProject get macos => MacOSProject._(this);

  /// The linux sub project of this project.
  LinuxProject get linux => LinuxProject._(this);

  /// The windows sub project of this project.
  WindowsProject get windows => WindowsProject._(this);

111 112 113 114 115 116 117
  /// The `pubspec.yaml` file of this project.
  File get pubspecFile => directory.childFile('pubspec.yaml');

  /// The `.packages` file of this project.
  File get packagesFile => directory.childFile('.packages');

  /// The `.flutter-plugins` file of this project.
118 119
  File get flutterPluginsFile => directory.childFile('.flutter-plugins');

120 121 122
  /// The `.dart-tool` directory of this project.
  Directory get dartTool => directory.childDirectory('.dart_tool');

123 124
  /// The directory containing the generated code for this project.
  Directory get generated => directory
125
    .absolute
126 127 128 129 130
    .childDirectory('.dart_tool')
    .childDirectory('build')
    .childDirectory('generated')
    .childDirectory(manifest.appName);

131
  /// The example sub-project of this project.
132
  FlutterProject get example => FlutterProject(
133 134 135 136 137
    _exampleDirectory(directory),
    _exampleManifest,
    FlutterManifest.empty(),
  );

138 139
  /// True if this project is a Flutter module project.
  bool get isModule => manifest.isModule;
140

141
  /// True if this project has an example application.
142
  bool get hasExampleApp => _exampleDirectory(directory).existsSync();
143 144

  /// The directory that will contain the example if an example exists.
145
  static Directory _exampleDirectory(Directory directory) => directory.childDirectory('example');
146

147 148 149 150 151 152 153 154 155 156 157 158
  /// Reads and validates the `pubspec.yaml` file at [path], asynchronously
  /// returning a [FlutterManifest] representation of the contents.
  ///
  /// Completes with an empty [FlutterManifest], if the file does not exist.
  /// Completes with a ToolExit on validation error.
  static Future<FlutterManifest> _readManifest(String path) async {
    final FlutterManifest manifest = await FlutterManifest.createFromPath(path);
    if (manifest == null)
      throwToolExit('Please correct the pubspec.yaml file at $path');
    return manifest;
  }

159
  /// Generates project files necessary to make Gradle builds work on Android
160
  /// and CocoaPods+Xcode work on iOS, for app and module projects only.
161 162
  Future<void> ensureReadyForPlatformSpecificTooling({bool checkProjects = false}) async {
    if (!directory.existsSync() || hasExampleApp) {
163
      return;
164
    }
165
    refreshPluginsList(this);
166 167 168 169 170 171
    if ((android.existsSync() && checkProjects) || !checkProjects) {
      await android.ensureReadyForPlatformSpecificTooling();
    }
    if ((ios.existsSync() && checkProjects) || !checkProjects) {
      await ios.ensureReadyForPlatformSpecificTooling();
    }
172 173 174
    if (flutterWebEnabled) {
      await web.ensureReadyForPlatformSpecificTooling();
    }
175
    await injectPlugins(this, checkProjects: checkProjects);
176
  }
177 178

  /// Return the set of builders used by this package.
179 180 181 182 183
  YamlMap get builders {
    if (!pubspecFile.existsSync()) {
      return null;
    }
    final YamlMap pubspec = loadYaml(pubspecFile.readAsStringSync());
184
    return pubspec['builders'];
185
  }
186 187

  /// Whether there are any builders used by this package.
188 189
  bool get hasBuilders {
    final YamlMap result = builders;
190 191
    return result != null && result.isNotEmpty;
  }
192 193
}

194 195 196
/// Represents the iOS sub-project of a Flutter project.
///
/// Instances will reflect the contents of the `ios/` sub-folder of
197
/// Flutter applications and the `.ios/` sub-folder of Flutter module projects.
198
class IosProject {
199
  IosProject.fromFlutter(this.parent);
200 201 202 203

  /// The parent of this project.
  final FlutterProject parent;

204
  static final RegExp _productBundleIdPattern = RegExp(r'''^\s*PRODUCT_BUNDLE_IDENTIFIER\s*=\s*(["']?)(.*?)\1;\s*$''');
205 206 207
  static const String _productBundleIdVariable = r'$(PRODUCT_BUNDLE_IDENTIFIER)';
  static const String _hostAppBundleName = 'Runner';

208 209 210
  Directory get _ephemeralDirectory => parent.directory.childDirectory('.ios');
  Directory get _editableDirectory => parent.directory.childDirectory('ios');

211 212
  bool existsSync() => parent.isModule || _editableDirectory.existsSync();

213 214
  /// This parent folder of `Runner.xcodeproj`.
  Directory get hostAppRoot {
215
    if (!isModule || _editableDirectory.existsSync())
216 217 218 219 220 221 222 223 224
      return _editableDirectory;
    return _ephemeralDirectory;
  }

  /// The root directory of the iOS wrapping of Flutter and plugins. This is the
  /// parent of the `Flutter/` folder into which Flutter artifacts are written
  /// during build.
  ///
  /// This is the same as [hostAppRoot] except when the project is
225 226
  /// a Flutter module with an editable host app.
  Directory get _flutterLibRoot => isModule ? _ephemeralDirectory : _editableDirectory;
227

228
  /// The bundle name of the host app, `Runner.app`.
229 230
  String get hostAppBundleName => '$_hostAppBundleName.app';

231 232
  /// True, if the parent Flutter project is a module project.
  bool get isModule => parent.isModule;
233

234 235 236
  /// Whether the flutter application has an iOS project.
  bool get exists => hostAppRoot.existsSync();

237
  /// The xcode config file for [mode].
238
  File xcodeConfigFor(String mode) => _flutterLibRoot.childDirectory('Flutter').childFile('$mode.xcconfig');
239 240

  /// The 'Podfile'.
241
  File get podfile => hostAppRoot.childFile('Podfile');
242 243

  /// The 'Podfile.lock'.
244
  File get podfileLock => hostAppRoot.childFile('Podfile.lock');
245 246

  /// The 'Manifest.lock'.
247
  File get podManifestLock => hostAppRoot.childDirectory('Pods').childFile('Manifest.lock');
248

249
  /// The 'Info.plist' file of the host app.
250
  File get hostInfoPlist => hostAppRoot.childDirectory(_hostAppBundleName).childFile('Info.plist');
251

252
  /// '.xcodeproj' folder of the host app.
253
  Directory get xcodeProject => hostAppRoot.childDirectory('$_hostAppBundleName.xcodeproj');
254 255 256 257

  /// The '.pbxproj' file of the host app.
  File get xcodeProjectInfoFile => xcodeProject.childFile('project.pbxproj');

258
  /// Xcode workspace directory of the host app.
259
  Directory get xcodeWorkspace => hostAppRoot.childDirectory('$_hostAppBundleName.xcworkspace');
260 261 262 263 264 265 266

  /// Xcode workspace shared data directory for the host app.
  Directory get xcodeWorkspaceSharedData => xcodeWorkspace.childDirectory('xcshareddata');

  /// Xcode workspace shared workspace settings file for the host app.
  File get xcodeWorkspaceSharedSettings => xcodeWorkspaceSharedData.childFile('WorkspaceSettings.xcsettings');

267 268
  /// The product bundle identifier of the host app, or null if not set or if
  /// iOS tooling needed to read it is not installed.
269
  String get productBundleIdentifier {
270 271 272 273 274 275 276 277
    final String fromPlist = iosWorkflow.getPlistValueFromFile(
      hostInfoPlist.path,
      plist.kCFBundleIdentifierKey,
    );
    if (fromPlist != null && !fromPlist.contains('\$')) {
      // Info.plist has no build variables in product bundle ID.
      return fromPlist;
    }
278
    final String fromPbxproj = _firstMatchInFile(xcodeProjectInfoFile, _productBundleIdPattern)?.group(2);
279 280 281 282 283 284 285 286 287
    if (fromPbxproj != null && (fromPlist == null || fromPlist == _productBundleIdVariable)) {
      // Common case. Avoids parsing build settings.
      return fromPbxproj;
    }
    if (fromPlist != null && xcode.xcodeProjectInterpreter.isInstalled) {
      // General case: perform variable substitution using build settings.
      return xcode.substituteXcodeVariables(fromPlist, buildSettings);
    }
    return null;
288 289 290 291 292 293
  }

  /// True, if the host app project is using Swift.
  bool get isSwift => buildSettings?.containsKey('SWIFT_VERSION');

  /// The build settings for the host app of this project, as a detached map.
294 295
  ///
  /// Returns null, if iOS tooling is unavailable.
296
  Map<String, String> get buildSettings {
297 298
    if (!xcode.xcodeProjectInterpreter.isInstalled)
      return null;
299
    return xcode.xcodeProjectInterpreter.getBuildSettings(xcodeProject.path, _hostAppBundleName);
300
  }
301

302
  Future<void> ensureReadyForPlatformSpecificTooling() async {
303
    _regenerateFromTemplateIfNeeded();
304
    if (!_flutterLibRoot.existsSync())
305
      return;
306 307 308 309
    await _updateGeneratedXcodeConfigIfNeeded();
  }

  Future<void> _updateGeneratedXcodeConfigIfNeeded() async {
310
    if (Cache.instance.isOlderThanToolsStamp(generatedXcodePropertiesFile)) {
311 312 313 314 315 316
      await xcode.updateGeneratedXcodeProperties(
        project: parent,
        buildInfo: BuildInfo.debug,
        targetOverride: bundle.defaultMainPath,
      );
    }
317 318
  }

319
  void _regenerateFromTemplateIfNeeded() {
320
    if (!isModule)
321
      return;
322 323
    final bool pubspecChanged = isOlderThanReference(entity: _ephemeralDirectory, referenceFile: parent.pubspecFile);
    final bool toolingChanged = Cache.instance.isOlderThanToolsStamp(_ephemeralDirectory);
324 325
    if (!pubspecChanged && !toolingChanged)
      return;
326
    _deleteIfExistsSync(_ephemeralDirectory);
327
    _overwriteFromTemplate(fs.path.join('module', 'ios', 'library'), _ephemeralDirectory);
328 329
    // Add ephemeral host app, if a editable host app does not already exist.
    if (!_editableDirectory.existsSync()) {
330
      _overwriteFromTemplate(fs.path.join('module', 'ios', 'host_app_ephemeral'), _ephemeralDirectory);
331
      if (hasPlugins(parent)) {
332
        _overwriteFromTemplate(fs.path.join('module', 'ios', 'host_app_ephemeral_cocoapods'), _ephemeralDirectory);
333
      }
334
    }
335 336
  }

337
  Future<void> makeHostAppEditable() async {
338
    assert(isModule);
339 340 341
    if (_editableDirectory.existsSync())
      throwToolExit('iOS host app is already editable. To start fresh, delete the ios/ folder.');
    _deleteIfExistsSync(_ephemeralDirectory);
342 343 344 345
    _overwriteFromTemplate(fs.path.join('module', 'ios', 'library'), _ephemeralDirectory);
    _overwriteFromTemplate(fs.path.join('module', 'ios', 'host_app_ephemeral'), _editableDirectory);
    _overwriteFromTemplate(fs.path.join('module', 'ios', 'host_app_ephemeral_cocoapods'), _editableDirectory);
    _overwriteFromTemplate(fs.path.join('module', 'ios', 'host_app_editable_cocoapods'), _editableDirectory);
346 347
    await _updateGeneratedXcodeConfigIfNeeded();
    await injectPlugins(parent);
348
  }
349

350
  File get generatedXcodePropertiesFile => _flutterLibRoot.childDirectory('Flutter').childFile('Generated.xcconfig');
351 352

  Directory get pluginRegistrantHost {
353
    return isModule
354 355
        ? _flutterLibRoot.childDirectory('Flutter').childDirectory('FlutterPluginRegistrant')
        : hostAppRoot.childDirectory(_hostAppBundleName);
356 357 358
  }

  void _overwriteFromTemplate(String path, Directory target) {
359
    final Template template = Template.fromName(path);
360 361 362 363
    template.render(
      target,
      <String, dynamic>{
        'projectName': parent.manifest.appName,
364
        'iosIdentifier': parent.manifest.iosBundleIdentifier,
365 366 367 368
      },
      printStatusWhenWriting: false,
      overwriteExisting: true,
    );
369
  }
370 371
}

372 373 374
/// Represents the Android sub-project of a Flutter project.
///
/// Instances will reflect the contents of the `android/` sub-folder of
375
/// Flutter applications and the `.android/` sub-folder of Flutter module projects.
376
class AndroidProject {
377 378 379 380 381
  AndroidProject._(this.parent);

  /// The parent of this project.
  final FlutterProject parent;

382 383 384
  static final RegExp _applicationIdPattern = RegExp('^\\s*applicationId\\s+[\'\"](.*)[\'\"]\\s*\$');
  static final RegExp _groupPattern = RegExp('^\\s*group\\s+[\'\"](.*)[\'\"]\\s*\$');

385 386 387 388
  /// The Gradle root directory of the Android host app. This is the directory
  /// containing the `app/` subdirectory and the `settings.gradle` file that
  /// includes it in the overall Gradle project.
  Directory get hostAppGradleRoot {
389
    if (!isModule || _editableHostAppDirectory.existsSync())
390
      return _editableHostAppDirectory;
391 392 393
    return _ephemeralDirectory;
  }

394 395
  bool existsSync() => parent.isModule || _flutterLibGradleRoot.existsSync();

396 397
  /// The Gradle root directory of the Android wrapping of Flutter and plugins.
  /// This is the same as [hostAppGradleRoot] except when the project is
398 399
  /// a Flutter module with an editable host app.
  Directory get _flutterLibGradleRoot => isModule ? _ephemeralDirectory : _editableHostAppDirectory;
400 401

  Directory get _ephemeralDirectory => parent.directory.childDirectory('.android');
402
  Directory get _editableHostAppDirectory => parent.directory.childDirectory('android');
403

404 405
  /// True if the parent Flutter project is a module.
  bool get isModule => parent.isModule;
406

407
  File get appManifestFile {
408
    return isUsingGradle
409 410
        ? fs.file(fs.path.join(hostAppGradleRoot.path, 'app', 'src', 'main', 'AndroidManifest.xml'))
        : hostAppGradleRoot.childFile('AndroidManifest.xml');
411 412
  }

413
  File get gradleAppOutV1File => gradleAppOutV1Directory.childFile('app-debug.apk');
414 415

  Directory get gradleAppOutV1Directory {
416
    return fs.directory(fs.path.join(hostAppGradleRoot.path, 'app', 'build', 'outputs', 'apk'));
417 418
  }

419 420 421 422
  Directory get gradleAppBundleOutV1Directory {
    return fs.directory(fs.path.join(hostAppGradleRoot.path, 'app', 'build', 'outputs', 'bundle'));
  }

423
  bool get isUsingGradle {
424
    return hostAppGradleRoot.childFile('build.gradle').existsSync();
425
  }
426

427
  String get applicationId {
428
    final File gradleFile = hostAppGradleRoot.childDirectory('app').childFile('build.gradle');
429
    return _firstMatchInFile(gradleFile, _applicationIdPattern)?.group(1);
430 431
  }

432
  String get group {
433
    final File gradleFile = hostAppGradleRoot.childFile('build.gradle');
434
    return _firstMatchInFile(gradleFile, _groupPattern)?.group(1);
435
  }
436

437
  Future<void> ensureReadyForPlatformSpecificTooling() async {
438
    if (isModule && _shouldRegenerateFromTemplate()) {
439
      _regenerateLibrary();
440 441
      // Add ephemeral host app, if an editable host app does not already exist.
      if (!_editableHostAppDirectory.existsSync()) {
442 443
        _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_common'), _ephemeralDirectory);
        _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_ephemeral'), _ephemeralDirectory);
444
      }
445
    }
446
    if (!hostAppGradleRoot.existsSync()) {
447
      return;
448 449
    }
    gradle.updateLocalProperties(project: parent, requireAndroidSdk: false);
450 451
  }

452
  bool _shouldRegenerateFromTemplate() {
453 454
    return isOlderThanReference(entity: _ephemeralDirectory, referenceFile: parent.pubspecFile)
        || Cache.instance.isOlderThanToolsStamp(_ephemeralDirectory);
455
  }
456

457
  Future<void> makeHostAppEditable() async {
458
    assert(isModule);
459 460
    if (_editableHostAppDirectory.existsSync())
      throwToolExit('Android host app is already editable. To start fresh, delete the android/ folder.');
461
    _regenerateLibrary();
462 463 464
    _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_common'), _editableHostAppDirectory);
    _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_editable'), _editableHostAppDirectory);
    _overwriteFromTemplate(fs.path.join('module', 'android', 'gradle'), _editableHostAppDirectory);
465 466
    gradle.injectGradleWrapper(_editableHostAppDirectory);
    gradle.writeLocalProperties(_editableHostAppDirectory.childFile('local.properties'));
467 468 469 470 471
    await injectPlugins(parent);
  }

  File get localPropertiesFile => _flutterLibGradleRoot.childFile('local.properties');

472
  Directory get pluginRegistrantHost => _flutterLibGradleRoot.childDirectory(isModule ? 'Flutter' : 'app');
473 474 475

  void _regenerateLibrary() {
    _deleteIfExistsSync(_ephemeralDirectory);
476 477
    _overwriteFromTemplate(fs.path.join('module', 'android', 'library'), _ephemeralDirectory);
    _overwriteFromTemplate(fs.path.join('module', 'android', 'gradle'), _ephemeralDirectory);
478 479
    gradle.injectGradleWrapper(_ephemeralDirectory);
  }
480

481
  void _overwriteFromTemplate(String path, Directory target) {
482
    final Template template = Template.fromName(path);
483 484 485 486 487 488 489 490 491 492
    template.render(
      target,
      <String, dynamic>{
        'projectName': parent.manifest.appName,
        'androidIdentifier': parent.manifest.androidPackage,
      },
      printStatusWhenWriting: false,
      overwriteExisting: true,
    );
  }
493 494
}

495 496 497 498 499 500
/// Represents the web sub-project of a Flutter project.
class WebProject {
  WebProject._(this.parent);

  final FlutterProject parent;

501 502
  bool existsSync() => parent.directory.childDirectory('web').existsSync();

503
  Future<void> ensureReadyForPlatformSpecificTooling() async {
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
    /// Generate index.html in build/web. Eventually we could support
    /// a custom html under the web sub directory.
    final Directory outputDir = fs.directory(getWebBuildDirectory());
    if (!outputDir.existsSync()) {
      outputDir.createSync(recursive: true);
    }
    final Template template = Template.fromName('web/index.html.tmpl');
    template.render(
      outputDir,
      <String, dynamic>{
        'appName': parent.manifest.appName,
      },
      printStatusWhenWriting: false,
      overwriteExisting: true,
    );
519
  }
520 521
}

522 523 524 525 526 527 528 529
/// Deletes [directory] with all content.
void _deleteIfExistsSync(Directory directory) {
  if (directory.existsSync())
    directory.deleteSync(recursive: true);
}


/// Returns the first line-based match for [regExp] in [file].
530 531
///
/// Assumes UTF8 encoding.
532 533
Match _firstMatchInFile(File file, RegExp regExp) {
  if (!file.existsSync()) {
534 535
    return null;
  }
536 537 538 539 540 541 542
  for (String line in file.readAsLinesSync()) {
    final Match match = regExp.firstMatch(line);
    if (match != null) {
      return match;
    }
  }
  return null;
543
}
544 545 546 547 548 549 550 551 552

/// The macOS sub project.
class MacOSProject {
  MacOSProject._(this.project);

  final FlutterProject project;

  bool existsSync() => project.directory.childDirectory('macos').existsSync();

553 554 555 556 557 558 559 560
  Directory get _editableDirectory => project.directory.childDirectory('macos');

  /// Contains definitions for FLUTTER_ROOT, LOCAL_ENGINE, and more flags for
  /// the Xcode build.
  File get generatedXcodePropertiesFile => _editableDirectory.childDirectory('Flutter').childFile('Generated.xcconfig');

  /// The Xcode project file.
  Directory get xcodeProjectFile => _editableDirectory.childDirectory('Runner.xcodeproj');
561 562 563

  // Note: The name script file exists as a temporary shim.
  File get nameScript => project.directory.childDirectory('macos').childFile('name_output.sh');
564 565 566 567 568 569 570 571 572 573 574 575
}

/// The Windows sub project
class WindowsProject {
  WindowsProject._(this.project);

  final FlutterProject project;

  bool existsSync() => project.directory.childDirectory('windows').existsSync();

  // Note: The build script file exists as a temporary shim.
  File get buildScript => project.directory.childDirectory('windows').childFile('build.bat');
576 577

  // Note: The name script file exists as a temporary shim.
578
  File get nameScript => project.directory.childDirectory('windows').childFile('name_output.bat');
579 580 581 582 583 584 585 586
}

/// The Linux sub project.
class LinuxProject {
  LinuxProject._(this.project);

  final FlutterProject project;

587
  Directory get editableHostAppDirectory => project.directory.childDirectory('linux');
588

589
  bool existsSync() => editableHostAppDirectory.existsSync();
590

591 592
  /// The Linux project makefile.
  File get makeFile => editableHostAppDirectory.childFile('Makefile');
593
}