mirror of
https://github.com/dart-lang/sdk
synced 2024-09-20 04:31:31 +00:00
Split the URI library across multiple files.
Review URL: https://chromiumcodereview.appspot.com//10383103 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@7543 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
8a459c921e
commit
e3cad04c02
|
@ -4,6 +4,8 @@
|
|||
|
||||
#library('uri');
|
||||
|
||||
#source('helpers.dart');
|
||||
|
||||
/**
|
||||
* A parsed URI, inspired by Closure's [URI][] class. Implements [RFC-3986][].
|
||||
* [uri]: http://closure-library.googlecode.com/svn/docs/class_goog_Uri.html
|
||||
|
@ -188,27 +190,3 @@ class Uri {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
String merge(String base, String reference) {
|
||||
if (base == "") return "/$reference";
|
||||
return "${base.substring(0, base.lastIndexOf("/") + 1)}$reference";
|
||||
}
|
||||
|
||||
String removeDotSegments(String path) {
|
||||
List<String> output = [];
|
||||
bool appendSlash = false;
|
||||
for (String segment in path.split("/")) {
|
||||
appendSlash = false;
|
||||
if (segment == "..") {
|
||||
if (!output.isEmpty() &&
|
||||
((output.length != 1) || (output[0] != ""))) output.removeLast();
|
||||
appendSlash = true;
|
||||
} else if ("." == segment) {
|
||||
appendSlash = true;
|
||||
} else {
|
||||
output.add(segment);
|
||||
}
|
||||
}
|
||||
if (appendSlash) output.add("");
|
||||
return Strings.join(output, "/");
|
||||
}
|
||||
|
|
|
@ -111,13 +111,32 @@
|
|||
'includes': [
|
||||
'uri_sources.gypi',
|
||||
],
|
||||
'variables': {
|
||||
'uri_dart': '<(SHARED_INTERMEDIATE_DIR)/uri.dart',
|
||||
},
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'generate_uri_dart',
|
||||
'inputs': [
|
||||
'../tools/concat_library.py',
|
||||
'<@(_sources)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(uri_dart)',
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'<@(_inputs)',
|
||||
'--output', '<(uri_dart)',
|
||||
],
|
||||
'message': 'Generating ''<(uri_dart)'' file.'
|
||||
},
|
||||
{
|
||||
'action_name': 'generate_uri_cc',
|
||||
'inputs': [
|
||||
'../tools/create_string_literal.py',
|
||||
'<(builtin_in_cc_file)',
|
||||
'<@(_sources)',
|
||||
'<(uri_dart)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(uri_cc_file)',
|
||||
|
@ -129,7 +148,7 @@
|
|||
'--input_cc', '<(builtin_in_cc_file)',
|
||||
'--include', 'bin/builtin.h',
|
||||
'--var_name', 'Builtin::uri_source_',
|
||||
'<@(_sources)',
|
||||
'<(uri_dart)',
|
||||
],
|
||||
'message': 'Generating ''<(uri_cc_file)'' file.'
|
||||
},
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
{
|
||||
'sources': [
|
||||
'../../lib/uri/uri.dart',
|
||||
'../../lib/uri/helpers.dart',
|
||||
],
|
||||
}
|
||||
|
|
40
runtime/tools/concat_library.py
Normal file
40
runtime/tools/concat_library.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env python
|
||||
# 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.
|
||||
|
||||
import optparse
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
def parse_options(argv):
|
||||
parser = optparse.OptionParser(usage="Usage: %prog [options] files")
|
||||
parser.add_option("--output",
|
||||
dest="output",
|
||||
help="Write output to FILE.",
|
||||
metavar="FILE")
|
||||
(options, arguments) = parser.parse_args(argv[1:])
|
||||
if not arguments:
|
||||
parser.error("At least one input file must be provided.")
|
||||
if not options.output:
|
||||
parser.error("No --output provided.")
|
||||
return (options, arguments)
|
||||
|
||||
|
||||
def main():
|
||||
# Print the command that is being run. This is helpful when
|
||||
# debugging build errors.
|
||||
sys.stderr.write('%s\n' % ' '.join(sys.argv))
|
||||
(options, arguments) = parse_options(sys.argv)
|
||||
tmp_name = '%s.tmp' % options.output
|
||||
with open(tmp_name, 'w') as output:
|
||||
for source in arguments:
|
||||
with open(source, 'r') as inpt:
|
||||
for line in inpt:
|
||||
if line.startswith('#source'):
|
||||
line = '// %s' % line
|
||||
output.write(line)
|
||||
shutil.move(tmp_name, options.output)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in a new issue