Chromium Code Reviews| Index: runtime/bin/main.cc |
| diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc |
| index 014c7230f669592e22a72050b0575c85e8d7784f..d385d5e49b349bd329fa71cfd42099a645f46364 100644 |
| --- a/runtime/bin/main.cc |
| +++ b/runtime/bin/main.cc |
| @@ -46,6 +46,12 @@ static const char* generate_pprof_symbols_filename = NULL; |
| static const char* breakpoint_at = NULL; |
| +// Value of the --package-root flag. |
| +// (This pointer points into an argv buffer and does not need to be |
| +// free'd.) |
| +static const char* package_root = NULL; |
| + |
| + |
| // Global flag that is used to indicate that we want to compile all the |
| // dart functions and not run anything. |
| static bool has_compile_all = false; |
| @@ -66,6 +72,12 @@ static void ProcessBreakpointOption(const char* funcname) { |
| } |
| +static void ProcessPackageRootOption(const char* arg) { |
| + ASSERT(arg != NULL); |
| + package_root = arg; |
| +} |
| + |
| + |
| static void ProcessCompileAllOption(const char* compile_all) { |
| ASSERT(compile_all != NULL); |
| has_compile_all = true; |
| @@ -92,6 +104,7 @@ static struct { |
| { "--compile_all", ProcessCompileAllOption }, |
| { "--generate_pprof_symbols=", ProcessPprofOption }, |
| { "--import_map=", ProcessImportMapOption }, |
| + { "--package-root=", ProcessPackageRootOption }, |
| { NULL, NULL } |
| }; |
| @@ -366,7 +379,7 @@ static Dart_Handle LoadScript(Dart_Handle builtin_lib, |
| return Dart_LoadScript(script_url, source, LibraryTagHandler, import_map); |
| } |
|
siva
2012/04/27 17:07:46
Missing blank line (2 blank lines between function
mattsh
2012/04/27 17:12:06
Done.
|
| - |
| +// Returns true on success, false on failure. |
| static bool CreateIsolateAndSetup(const char* name_prefix, |
| void* data, char** error) { |
| Dart_Isolate isolate = |
| @@ -400,6 +413,24 @@ static bool CreateIsolateAndSetup(const char* name_prefix, |
| return false; |
| } |
| + if (package_root != NULL) { |
| + Dart_Handle dart_args[1]; |
| + |
| + Dart_Handle handle = Dart_NewString(package_root); |
| + if (Dart_IsError(handle)) { |
| + *error = strdup(Dart_GetError(handle)); |
| + return false; |
| + } |
| + dart_args[0] = handle; |
| + |
| + Dart_Handle result = Dart_Invoke(builtin_lib, |
| + Dart_NewString("_setPackageRoot"), 1, dart_args); |
| + if (Dart_IsError(result)) { |
| + *error = strdup(Dart_GetError(result)); |
| + return false; |
| + } |
| + } |
| + |
| // Load the specified application script into the newly created isolate. |
| library = LoadScript(builtin_lib, import_map_options); |
| if (Dart_IsError(library)) { |