Move pub into sdk/lib/_internal.

This also converts pub to a more package-like layout, which will help in the
eventual exposing of pub internals as a library. Since pub's sources are now in
lib/src, this also makes them importable from the tests and entrypoint using
"package:" imports.

BUG=6619

Review URL: https://codereview.chromium.org//14297021

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21907 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
nweiz@google.com 2013-04-23 21:44:26 +00:00
parent 4190de5bfc
commit 24213beff5
167 changed files with 160 additions and 190 deletions

View file

@ -8,6 +8,5 @@
BIN_DIR="$(cd "${0%/*}" ; pwd -P)"
export DART_SDK="$(cd "${BIN_DIR%/*}" ; pwd -P)"
# TODO(dgrove): This doesn't work yet. It will once dartbug.com/6619 is
# fixed.
exec "$BIN_DIR"/dart "$DART_SDK"/lib/_internal/pub/pub.dart $@
exec "$BIN_DIR"/dart --package-root="$DART_SDK"/packages/ \
"$DART_SDK"/lib/_internal/pub/bin/pub.dart $@

View file

@ -1,17 +1,16 @@
@echo off
REM Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
REM for details. All rights reserved. Use of this source code is governed by a
REM BSD-style license that can be found in the LICENSE file.
:: Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
:: for details. All rights reserved. Use of this source code is governed by a
:: BSD-style license that can be found in the LICENSE file.
REM Run pub.dart on the Dart VM. This script assumes the Dart SDK's directory
REM structure.
:: Run pub.dart on the Dart VM. This script assumes the Dart SDK's directory
:: structure.
set SCRIPTPATH=%~dp0
REM Does the string have a trailing slash? If so, remove it.
:: Does the string have a trailing slash? If so, remove it.
if %SCRIPTPATH:~-1%==\ set SCRIPTPATH=%SCRIPTPATH:~0,-1%
REM Set DART_SDK so pub can find SDK packages.
set DART_SDK=%SCRIPTPATH%\..\
"%SCRIPTPATH%\dart" "%SCRIPTPATH%\..\util\pub\pub.dart" %*
:: The trailing forward slash in --package-root is required because of issue
:: 9499.
"%SCRIPTPATH%\dart.exe" --package-root="%SCRIPTPATH%\..\packages/" "%SCRIPTPATH%\..\lib\_internal\pub\bin\pub.dart" %*

View file

@ -0,0 +1,8 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import '../lib/src/pub.dart';
// TODO(nweiz): move option-parsing logic into this file.
void main() => run();

View file

@ -252,23 +252,22 @@ void createPackageSymlink(String name, String target, String symlink,
}
}
/// Resolves [target] relative to the location of pub.dart.
/// Resolves [target] relative to the root directory of pub.
String relativeToPub(String target) {
var scriptPath = new File(new Options().script).fullPathSync();
// Walk up until we hit the "util(s)" directory. This lets us figure out where
// we are if this function is called from pub.dart, or one of the tests,
// which also live under "utils", or from the SDK where pub is in "util".
var utilDir = path.dirname(scriptPath);
while (path.basename(utilDir) != 'utils' &&
path.basename(utilDir) != 'util') {
if (path.basename(utilDir) == '') {
// Walk up until we hit the "internal(s)" directory. This lets us figure out
// where we are if this function is called from pub.dart, one of the tests, or
// from the SDK.
var internalDir = path.dirname(scriptPath);
while (path.basename(internalDir) != '_internal') {
if (path.basename(internalDir) == '') {
throw new Exception('Could not find path to pub.');
}
utilDir = path.dirname(utilDir);
internalDir = path.dirname(internalDir);
}
return path.normalize(path.join(utilDir, 'pub', target));
return path.normalize(path.join(internalDir, 'pub', target));
}
/// A line-by-line stream of standard input.
@ -564,7 +563,7 @@ Future<bool> _extractTarGzWindows(Stream<List<int>> stream,
// Note: This line of code gets munged by create_sdk.py to be the correct
// relative path to 7zip in the SDK.
var pathTo7zip = '../../third_party/7zip/7za.exe';
var pathTo7zip = '../../../../third_party/7zip/7za.exe';
var command = relativeToPub(pathTo7zip);
return withTempDir((tempDir) {
@ -652,7 +651,7 @@ ByteStream createTarGz(List contents, {baseDir}) {
// Note: This line of code gets munged by create_sdk.py to be the correct
// relative path to 7zip in the SDK.
var pathTo7zip = '../../third_party/7zip/7za.exe';
var pathTo7zip = '../../../../third_party/7zip/7za.exe';
var command = relativeToPub(pathTo7zip);
// We're passing 'baseDir' both as '-w' and setting it as the working

View file

@ -76,7 +76,7 @@ ArgParser get pubArgParser {
return parser;
}
main() {
void run() {
var globalOptions;
try {
globalOptions = pubArgParser.parse(new Options().arguments);

View file

@ -28,10 +28,8 @@ String get rootDirectory {
return dir;
}
var pubDir = path.dirname(new Options().script);
dir = path.normalize(path.join(pubDir, "../../"));
log.fine("Located SDK at $dir");
return dir;
throw new Exception('DART_SDK environment variable not set, unable to find '
'the SDK.');
}
/// Gets the SDK's revision number formatted to be a semantic version.

View file

@ -2,8 +2,8 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
pub_uploader_test: Pass, Fail # Issue 9357
oauth2/with_server_rejected_credentials_authenticates_again_test: Pass, Fail # Issue 9839.
test/pub_uploader_test: Pass, Fail # Issue 9357
test/oauth2/with_server_rejected_credentials_authenticates_again_test: Pass, Fail # Issue 9839.
# Pub only runs on the VM, so just rule out all compilers.
[ $compiler == dart2js || $compiler == dart2dart ]
@ -14,5 +14,5 @@ oauth2/with_server_rejected_credentials_authenticates_again_test: Pass, Fail # I
*: Skip
[ $system == windows ]
io_test: Fail # Issue 7505
install/hosted/fail_gracefully_on_url_resolve_test: Pass, Fail # Issue 9503
test/io_test: Fail # Issue 7505
test/install/hosted/fail_gracefully_on_url_resolve_test: Pass, Fail # Issue 9503

View file

@ -9,7 +9,7 @@ import 'dart:math' as math;
import 'package:pathos/path.dart' as path;
import 'package:unittest/unittest.dart';
import '../../pub/utils.dart';
import '../lib/src/utils.dart';
/// Gets a "special" string (ANSI escape or Unicode). On Windows, returns
/// something else since those aren't supported.

View file

@ -10,7 +10,7 @@ import 'package:scheduled_test/scheduled_server.dart';
import 'package:scheduled_test/scheduled_test.dart';
import 'package:scheduled_test/descriptor.dart';
import '../../pub/utils.dart';
import '../lib/src/utils.dart';
import 'descriptor/git.dart';
import 'descriptor/tar.dart';
import 'test_pub.dart';

View file

@ -10,7 +10,7 @@ import 'package:pathos/path.dart' as path;
import 'package:scheduled_test/scheduled_test.dart';
import 'package:scheduled_test/descriptor.dart';
import '../../../pub/git.dart' as git;
import '../../lib/src/git.dart' as git;
/// Describes a Git repository and its contents.
class GitRepoDescriptor extends DirectoryDescriptor {

View file

@ -11,8 +11,8 @@ import 'package:pathos/path.dart' as path;
import 'package:scheduled_test/scheduled_test.dart';
import 'package:scheduled_test/descriptor.dart';
import '../../../pub/io.dart';
import '../../../pub/utils.dart';
import '../../lib/src/io.dart';
import '../../lib/src/utils.dart';
/// Describes a tar file and its contents.
class TarFileDescriptor extends DirectoryDescriptor {

View file

@ -6,7 +6,7 @@ library lock_file_test;
import 'package:unittest/unittest.dart';
import '../../pub/directory_tree.dart';
import '../lib/src/directory_tree.dart';
main() {
test('no files', () {

View file

@ -8,8 +8,8 @@ import 'dart:async';
import 'package:unittest/unittest.dart';
import '../../pub/error_group.dart';
import '../../pub/utils.dart';
import '../lib/src/error_group.dart';
import '../lib/src/utils.dart';
ErrorGroup errorGroup;

View file

@ -9,7 +9,7 @@ import 'dart:io';
import 'package:pathos/path.dart' as path;
import 'package:scheduled_test/scheduled_test.dart';
import '../../../../pub/io.dart';
import '../../../lib/src/io.dart';
import '../../descriptor.dart' as d;
import '../../test_pub.dart';

View file

@ -7,7 +7,7 @@ library pub_tests;
import 'package:pathos/path.dart' as path;
import 'package:scheduled_test/scheduled_test.dart';
import '../../../../pub/io.dart';
import '../../../lib/src/io.dart';
import '../../descriptor.dart' as d;
import '../../test_pub.dart';

View file

@ -6,7 +6,7 @@ library pub_tests;
import 'package:pathos/path.dart' as path;
import '../../../../pub/io.dart';
import '../../../lib/src/io.dart';
import '../../descriptor.dart' as d;
import '../../test_pub.dart';

View file

@ -9,7 +9,7 @@ import 'dart:io';
import 'package:pathos/path.dart' as path;
import 'package:scheduled_test/scheduled_test.dart';
import '../../../../pub/io.dart';
import '../../../lib/src/io.dart';
import '../../descriptor.dart' as d;
import '../../test_pub.dart';

View file

@ -5,7 +5,7 @@
import 'package:pathos/path.dart' as path;
import 'package:scheduled_test/scheduled_test.dart';
import '../../../../pub/io.dart';
import '../../../lib/src/io.dart';
import '../../descriptor.dart' as d;
import '../../test_pub.dart';

View file

@ -4,7 +4,7 @@
import 'package:pathos/path.dart' as path;
import '../../../../pub/exit_codes.dart' as exit_codes;
import '../../../lib/src/exit_codes.dart' as exit_codes;
import '../../descriptor.dart' as d;
import '../../test_pub.dart';

View file

@ -7,7 +7,7 @@ import 'dart:io';
import 'package:pathos/path.dart' as path;
import 'package:scheduled_test/scheduled_test.dart';
import '../../../../pub/exit_codes.dart' as exit_codes;
import '../../../lib/src/exit_codes.dart' as exit_codes;
import '../../descriptor.dart' as d;
import '../../test_pub.dart';

View file

@ -5,7 +5,7 @@
import 'package:pathos/path.dart' as path;
import 'package:scheduled_test/scheduled_test.dart';
import '../../../../pub/exit_codes.dart' as exit_codes;
import '../../../lib/src/exit_codes.dart' as exit_codes;
import '../../descriptor.dart' as d;
import '../../test_pub.dart';

View file

@ -4,7 +4,7 @@
import 'package:pathos/path.dart' as path;
import '../../../../pub/exit_codes.dart' as exit_codes;
import '../../../lib/src/exit_codes.dart' as exit_codes;
import '../../descriptor.dart' as d;
import '../../test_pub.dart';

View file

@ -6,7 +6,7 @@ import 'dart:io';
import 'package:pathos/path.dart' as path;
import '../../../../pub/exit_codes.dart' as exit_codes;
import '../../../lib/src/exit_codes.dart' as exit_codes;
import '../../descriptor.dart' as d;
import '../../test_pub.dart';

View file

@ -9,7 +9,7 @@ import 'dart:io';
import 'package:pathos/path.dart' as path;
import 'package:scheduled_test/scheduled_test.dart';
import '../../../pub/io.dart';
import '../../lib/src/io.dart';
import '../descriptor.dart' as d;
import '../test_pub.dart';

View file

@ -9,8 +9,8 @@ import 'dart:io';
import 'package:pathos/path.dart' as path;
import 'package:unittest/unittest.dart';
import '../../pub/io.dart';
import '../../pub/utils.dart';
import '../lib/src/io.dart';
import '../lib/src/utils.dart';
import 'test_pub.dart';
main() {

Some files were not shown because too many files have changed in this diff Show more