Adam Barth 94b472ff67 Add a --no-http flag to start command
This flag builds a local FLX file and pushes that to the device instead of
using an HTTP server.
2015-10-31 12:18:03 -07:00

50 lines
1.3 KiB
Dart

// 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.
import 'dart:async';
import 'package:path/path.dart' as path;
import 'artifacts.dart';
import 'build_configuration.dart';
import 'process.dart';
class Compiler {
Compiler(this._path);
String _path;
Future<int> compile({
String mainPath,
String snapshotPath
}) {
return runCommandAndStreamOutput([
_path,
mainPath,
'--package-root=${ArtifactStore.packageRoot}',
'--snapshot=$snapshotPath'
]);
}
}
Future<String> _getCompilerPath(BuildConfiguration config) async {
if (config.type != BuildType.prebuilt)
return path.join(config.buildDir, 'clang_x64', 'sky_snapshot');
Artifact artifact = ArtifactStore.getArtifact(
type: ArtifactType.snapshot, hostPlatform: config.hostPlatform);
return await ArtifactStore.getPath(artifact);
}
class Toolchain {
Toolchain({ this.compiler });
final Compiler compiler;
static Future<Toolchain> forConfigs(List<BuildConfiguration> configs) async {
// TODO(abarth): Shouldn't we consider all the configs?
String compilerPath = await _getCompilerPath(configs.first);
return new Toolchain(compiler: new Compiler(compilerPath));
}
}