Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
2710e0f4
Commit
2710e0f4
authored
Nov 07, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Teach flutter init how to depend on flutter using a relative path
parent
c9a79bfe
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
11 deletions
+38
-11
.gitignore
bin/cache/.gitignore
+1
-0
flutter
bin/flutter
+1
-1
artifacts.dart
packages/flutter_tools/lib/src/artifacts.dart
+9
-3
flutter_command_runner.dart
...lutter_tools/lib/src/commands/flutter_command_runner.dart
+3
-0
init.dart
packages/flutter_tools/lib/src/commands/init.dart
+22
-7
init_test.dart
packages/flutter_tools/test/init_test.dart
+2
-0
No files found.
bin/cache/.gitignore
View file @
2710e0f4
*.snapshot
*.stamp
artifacts
bin/flutter
View file @
2710e0f4
...
...
@@ -3,7 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
FLUTTER_ROOT
=
$(
dirname
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
))
export
FLUTTER_ROOT
=
$(
dirname
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
))
FLUTTER_TOOLS_DIR
=
"
$FLUTTER_ROOT
/packages/flutter_tools"
SNAPSHOT_PATH
=
"
$FLUTTER_ROOT
/bin/cache/flutter_tools.snapshot"
STAMP_PATH
=
"
$FLUTTER_ROOT
/bin/cache/flutter_tools.stamp"
...
...
packages/flutter_tools/lib/src/artifacts.dart
View file @
2710e0f4
...
...
@@ -10,6 +10,7 @@ import 'package:path/path.dart' as path;
import
'build_configuration.dart'
;
import
'os_utils.dart'
;
import
'process.dart'
;
final
Logger
_logging
=
new
Logger
(
'sky_tools.artifacts'
);
...
...
@@ -155,7 +156,10 @@ class ArtifactStore {
return
null
;
}
// These values are initialized by FlutterCommandRunner on startup.
static
String
flutterRoot
;
static
String
packageRoot
;
static
String
_engineRevision
;
static
String
get
engineRevision
{
...
...
@@ -190,7 +194,11 @@ class ArtifactStore {
}
static
Directory
_getBaseCacheDir
()
{
Directory
cacheDir
=
new
Directory
(
path
.
join
(
packageRoot
,
'sky_tools'
,
'cache'
));
if
(
flutterRoot
==
null
)
{
_logging
.
severe
(
'FLUTTER_ROOT not specified. Cannot find artifact cache.'
);
throw
new
ProcessExit
(
2
);
}
Directory
cacheDir
=
new
Directory
(
path
.
join
(
flutterRoot
,
'bin'
,
'cache'
,
'artifacts'
));
if
(!
cacheDir
.
existsSync
())
cacheDir
.
createSync
(
recursive:
true
);
return
cacheDir
;
...
...
@@ -198,8 +206,6 @@ class ArtifactStore {
static
Directory
_getCacheDirForArtifact
(
Artifact
artifact
)
{
Directory
baseDir
=
_getBaseCacheDir
();
// For now, all downloaded artifacts are release mode host binaries so use
// a path that mirrors a local release build.
// TODO(jamesr): Add support for more configurations.
String
config
=
'Release'
;
Directory
artifactSpecificDir
=
new
Directory
(
path
.
join
(
...
...
packages/flutter_tools/lib/src/commands/flutter_command_runner.dart
View file @
2710e0f4
...
...
@@ -29,6 +29,8 @@ class FlutterCommandRunner extends CommandRunner {
'shell commands executed.'
);
argParser
.
addOption
(
'package-root'
,
help:
'Path to your packages directory.'
,
defaultsTo:
'packages'
);
argParser
.
addOption
(
'flutter-root'
,
help:
'The root directory of the Flutter repository.'
);
argParser
.
addOption
(
'android-device-id'
,
help:
'Serial number of the target Android device.'
);
...
...
@@ -105,6 +107,7 @@ class FlutterCommandRunner extends CommandRunner {
Logger
.
root
.
level
=
Level
.
FINE
;
_globalResults
=
globalResults
;
ArtifactStore
.
flutterRoot
=
globalResults
[
'flutter-root'
]
??
Platform
.
environment
[
'FLUTTER_ROOT'
];
ArtifactStore
.
packageRoot
=
globalResults
[
'package-root'
];
return
super
.
runCommand
(
globalResults
);
...
...
packages/flutter_tools/lib/src/commands/init.dart
View file @
2710e0f4
...
...
@@ -9,6 +9,7 @@ import 'package:args/command_runner.dart';
import
'package:mustache4dart/mustache4dart.dart'
as
mustache
;
import
'package:path/path.dart'
as
p
;
import
'../artifacts.dart'
;
import
'../process.dart'
;
class
InitCommand
extends
Command
{
...
...
@@ -30,17 +31,30 @@ class InitCommand extends Command {
return
2
;
}
if
(
ArtifactStore
.
flutterRoot
==
null
)
{
stderr
.
writeln
(
'Neither the --flutter-root command line flag nor the FLUTTER_ROOT environment'
);
stderr
.
writeln
(
'variable was specified. Unable to find package:flutter.'
);
return
2
;
}
String
flutterRoot
=
p
.
absolute
(
ArtifactStore
.
flutterRoot
);
String
flutterPackagePath
=
p
.
join
(
flutterRoot
,
'packages'
,
'flutter'
);
if
(!
FileSystemEntity
.
isFileSync
(
p
.
join
(
flutterPackagePath
,
'pubspec.yaml'
)))
{
print
(
'Unable to find package:flutter in
${flutterPackagePath}
'
);
return
2
;
}
// TODO: Confirm overwrite of an existing directory with the user.
Directory
out
=
new
Directory
(
argResults
[
'out'
]);
new
FlutterSimpleTemplate
().
generateInto
(
out
);
new
FlutterSimpleTemplate
().
generateInto
(
out
,
flutterPackagePath
);
print
(
''
);
String
message
=
'''All done! To run your application:
\$
cd
${out.path}
\$
flutter start
--checked
\$
flutter start
'''
;
if
(
argResults
[
'pub'
])
{
...
...
@@ -66,14 +80,16 @@ abstract class Template {
Template
(
this
.
name
,
this
.
description
);
void
generateInto
(
Directory
dir
)
{
void
generateInto
(
Directory
dir
,
String
flutterPackagePath
)
{
String
dirPath
=
p
.
normalize
(
dir
.
absolute
.
path
);
String
projectName
=
_normalizeProjectName
(
p
.
basename
(
dirPath
));
print
(
'Creating
${p.basename(projectName)}
...'
);
dir
.
createSync
(
recursive:
true
);
String
relativeFlutterPackagePath
=
p
.
relative
(
flutterPackagePath
,
from:
dirPath
);
files
.
forEach
((
String
path
,
String
contents
)
{
Map
m
=
{
'projectName'
:
projectName
,
'description'
:
description
};
Map
m
=
{
'projectName'
:
projectName
,
'description'
:
description
,
'flutterPackagePath'
:
relativeFlutterPackagePath
};
contents
=
mustache
.
render
(
contents
,
m
);
path
=
path
.
replaceAll
(
'/'
,
Platform
.
pathSeparator
);
File
file
=
new
File
(
p
.
join
(
dir
.
path
,
path
));
...
...
@@ -129,9 +145,8 @@ const String _pubspec = r'''
name: {{projectName}}
description: {{description}}
dependencies:
flutter: ">=0.0.2 <0.1.0"
dev_dependencies:
sky_tools: any
flutter:
path: {{flutterPackagePath}}
'''
;
const
String
_flutterYaml
=
r''
'
...
...
packages/flutter_tools/test/init_test.dart
View file @
2710e0f4
...
...
@@ -6,6 +6,7 @@ import 'dart:io';
import
'package:args/command_runner.dart'
;
import
'package:path/path.dart'
as
p
;
import
'package:sky_tools/src/artifacts.dart'
;
import
'package:sky_tools/src/commands/init.dart'
;
import
'package:sky_tools/src/process.dart'
;
import
'package:test/test.dart'
;
...
...
@@ -29,6 +30,7 @@ defineTests() {
if
(!
Platform
.
isWindows
)
{
// Verify that we create a project that is well-formed.
test
(
'flutter-simple'
,
()
async
{
ArtifactStore
.
flutterRoot
=
'../..'
;
InitCommand
command
=
new
InitCommand
();
CommandRunner
runner
=
new
CommandRunner
(
'test_flutter'
,
''
)
..
addCommand
(
command
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment