windows.dart 2.3 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../../artifacts.dart';
import '../../base/file_system.dart';
7
import '../../build_info.dart';
8
import '../../globals.dart' as globals;
9 10 11
import '../build_system.dart';

/// Copies the Windows desktop embedding files to the copy directory.
12 13 14 15 16 17 18 19 20
class UnpackWindows extends Target {
  const UnpackWindows();

  @override
  String get name => 'unpack_windows';

  @override
  List<Source> get inputs => const <Source>[
    Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/windows.dart'),
21
    Source.artifact(Artifact.windowsDesktopPath, mode: BuildMode.debug),
22 23 24 25
  ];

  @override
  List<Source> get outputs => const <Source>[
26 27 28 29
    Source.pattern('{PROJECT_DIR}/windows/flutter/flutter_windows.dll'),
    Source.pattern('{PROJECT_DIR}/windows/flutter/flutter_windows.dll.exp'),
    Source.pattern('{PROJECT_DIR}/windows/flutter/flutter_windows.dll.lib'),
    Source.pattern('{PROJECT_DIR}/windows/flutter/flutter_windows.dll.pdb'),
30 31 32
    Source.pattern('{PROJECT_DIR}/windows/flutter/flutter_export.h'),
    Source.pattern('{PROJECT_DIR}/windows/flutter/flutter_messenger.h'),
    Source.pattern('{PROJECT_DIR}/windows/flutter/flutter_plugin_registrar.h'),
33
    Source.pattern('{PROJECT_DIR}/windows/flutter/flutter_windows.h'),
34
    Source.pattern('{PROJECT_DIR}/windows/flutter/icudtl.dat'),
35 36 37 38 39 40
  ];

  @override
  List<Target> get dependencies => const <Target>[];

  @override
41
  Future<void> build(Environment environment) async {
42
    // This path needs to match the prefix in the rule below.
43
    final String basePath = globals.artifacts.getArtifactPath(Artifact.windowsDesktopPath);
44
    for (final File input in globals.fs.directory(basePath)
45 46
        .listSync(recursive: true)
        .whereType<File>()) {
47
      final String outputPath = globals.fs.path.join(
48 49 50
        environment.projectDir.path,
        'windows',
        'flutter',
51
        globals.fs.path.relative(input.path, from: basePath),
52
      );
53
      final File destinationFile = globals.fs.file(outputPath);
54 55 56
      if (!destinationFile.parent.existsSync()) {
        destinationFile.parent.createSync(recursive: true);
      }
57
      globals.fs.file(input).copySync(destinationFile.path);
58 59 60
    }
  }
}