Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: runtime/bin/gen_snapshot.cc

Issue 2087723002: Fix canonicalization of relative paths, Dart_DefaultCanonicalizeUrl expects the base)url to end wit… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Generate a snapshot file after loading all the scripts specified on the 5 // Generate a snapshot file after loading all the scripts specified on the
6 // command line. 6 // command line.
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 free(result_string); 448 free(result_string);
449 } 449 }
450 return result; 450 return result;
451 } 451 }
452 452
453 453
454 static Dart_Handle LoadSnapshotCreationScript(const char* script_name) { 454 static Dart_Handle LoadSnapshotCreationScript(const char* script_name) {
455 // First resolve the specified script uri with respect to the original 455 // First resolve the specified script uri with respect to the original
456 // working directory. 456 // working directory.
457 Dart_Handle resolved_uri = Dart_DefaultCanonicalizeUrl( 457 Dart_Handle resolved_uri = Dart_DefaultCanonicalizeUrl(
458 Dart_NewStringFromCString(DartUtils::original_working_directory), 458 DartUtils::GetCanonicalizableWorkingDirectory(),
459 Dart_NewStringFromCString(script_name)); 459 Dart_NewStringFromCString(script_name));
460 if (Dart_IsError(resolved_uri)) { 460 if (Dart_IsError(resolved_uri)) {
461 return resolved_uri; 461 return resolved_uri;
462 } 462 }
463 // Now load the contents of the specified uri. 463 // Now load the contents of the specified uri.
464 const char* resolved_uri_string = DartUtils::GetStringValue(resolved_uri); 464 const char* resolved_uri_string = DartUtils::GetStringValue(resolved_uri);
465 Dart_Handle source = LoadUrlContents(resolved_uri_string); 465 Dart_Handle source = LoadUrlContents(resolved_uri_string);
466 if (Dart_IsError(source)) { 466 if (Dart_IsError(source)) {
467 return source; 467 return source;
468 } 468 }
(...skipping 24 matching lines...) Expand all
493 } 493 }
494 Dart_Handle library_url = Dart_LibraryUrl(library); 494 Dart_Handle library_url = Dart_LibraryUrl(library);
495 if (Dart_IsError(library_url)) { 495 if (Dart_IsError(library_url)) {
496 return Dart_NewApiError("accessing library url failed"); 496 return Dart_NewApiError("accessing library url failed");
497 } 497 }
498 const char* library_url_string = DartUtils::GetStringValue(library_url); 498 const char* library_url_string = DartUtils::GetStringValue(library_url);
499 const char* mapped_library_url_string = DartUtils::MapLibraryUrl( 499 const char* mapped_library_url_string = DartUtils::MapLibraryUrl(
500 library_url_string); 500 library_url_string);
501 if (mapped_library_url_string != NULL) { 501 if (mapped_library_url_string != NULL) {
502 library_url = Dart_DefaultCanonicalizeUrl( 502 library_url = Dart_DefaultCanonicalizeUrl(
503 Dart_NewStringFromCString(DartUtils::original_working_directory), 503 DartUtils::GetCanonicalizableWorkingDirectory(),
504 Dart_NewStringFromCString(mapped_library_url_string)); 504 Dart_NewStringFromCString(mapped_library_url_string));
505 library_url_string = DartUtils::GetStringValue(library_url); 505 library_url_string = DartUtils::GetStringValue(library_url);
506 } 506 }
507 507
508 if (!Dart_IsString(url)) { 508 if (!Dart_IsString(url)) {
509 return Dart_NewApiError("url is not a string"); 509 return Dart_NewApiError("url is not a string");
510 } 510 }
511 const char* url_string = DartUtils::GetStringValue(url); 511 const char* url_string = DartUtils::GetStringValue(url);
512 const char* mapped_url_string = DartUtils::MapLibraryUrl(url_string); 512 const char* mapped_url_string = DartUtils::MapLibraryUrl(url_string);
513 513
(...skipping 26 matching lines...) Expand all
540 Builtin::PartSource(libraryBuiltinId, url_string), 0, 0); 540 Builtin::PartSource(libraryBuiltinId, url_string), 0, 0);
541 } 541 }
542 ASSERT(tag == Dart_kImportTag); 542 ASSERT(tag == Dart_kImportTag);
543 return DartUtils::NewError("Unable to import '%s' ", url_string); 543 return DartUtils::NewError("Unable to import '%s' ", url_string);
544 } 544 }
545 545
546 Dart_Handle resolved_url = url; 546 Dart_Handle resolved_url = url;
547 if (mapped_url_string != NULL) { 547 if (mapped_url_string != NULL) {
548 // Mapped urls are relative to working directory. 548 // Mapped urls are relative to working directory.
549 resolved_url = Dart_DefaultCanonicalizeUrl( 549 resolved_url = Dart_DefaultCanonicalizeUrl(
550 Dart_NewStringFromCString(DartUtils::original_working_directory), 550 DartUtils::GetCanonicalizableWorkingDirectory(),
551 Dart_NewStringFromCString(mapped_url_string)); 551 Dart_NewStringFromCString(mapped_url_string));
552 if (Dart_IsError(resolved_url)) { 552 if (Dart_IsError(resolved_url)) {
553 return resolved_url; 553 return resolved_url;
554 } 554 }
555 } 555 }
556 const char* resolved_uri_string = DartUtils::GetStringValue(resolved_url); 556 const char* resolved_uri_string = DartUtils::GetStringValue(resolved_url);
557 Dart_Handle source = LoadUrlContents(resolved_uri_string); 557 Dart_Handle source = LoadUrlContents(resolved_uri_string);
558 if (Dart_IsError(source)) { 558 if (Dart_IsError(source)) {
559 return source; 559 return source;
560 } 560 }
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 EventHandler::Stop(); 1330 EventHandler::Stop();
1331 return 0; 1331 return 0;
1332 } 1332 }
1333 1333
1334 } // namespace bin 1334 } // namespace bin
1335 } // namespace dart 1335 } // namespace dart
1336 1336
1337 int main(int argc, char** argv) { 1337 int main(int argc, char** argv) {
1338 return dart::bin::main(argc, argv); 1338 return dart::bin::main(argc, argv);
1339 } 1339 }
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698