[fuchsia] Fix build. Build packages/ output. Add Directory::Exists().

The build was broken by the addition of OS::MaxRSS, which I've added
unimplemented. I need the packages/ output to get the Dart language
tests going. I've added Directory::Exists() so that we can give
the right error message on a missing package: import instead of
crashing.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2259613002 .
This commit is contained in:
Zachary Anderson 2016-08-18 09:21:14 -07:00
parent c21891ec6a
commit 1b303e64fe
5 changed files with 82 additions and 9 deletions

33
pkg/BUILD.gn Normal file
View file

@ -0,0 +1,33 @@
# Copyright (c) 2016, 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.
action("pkg") {
# TODO(zra): Add third_party/pkg, third_party/pkg_tested, and
# third_party/observatory_pub_packages/packages/charted/lib.
list_script = "../tools/list_pkg_directories.py"
pkg_list = exec_script(list_script, [rebase_path(".")], "list lines")
runtime_list = exec_script(
list_script, [rebase_path("../runtime")], "list lines")
inputs = pkg_list +
runtime_list +
[rebase_path("../sdk/lib/_internal/js_runtime/lib"),
rebase_path("../sdk/lib/_internal/sdk_library_metadata/lib"),]
timestamp_file = "$target_gen_dir/packages.stamp"
outputs = [
timestamp_file,
]
script = "../tools/make_links.py"
args = [
"--quiet",
"--timestamp_file",
rebase_path(timestamp_file),
rebase_path("$root_out_dir/packages"),] +
inputs +
# Pub imports dart2js as compiler_unsupported so it can work outside
# the SDK. Map that to the compiler package.
[rebase_path("compiler/lib") + ":compiler_unsupported",]
}

View file

@ -467,6 +467,7 @@ if (defined(is_fuchsia) && is_fuchsia) {
"../vm:libdart_platform",
"..:libdart",
":dart_snapshot_cc",
"../../pkg:pkg", # Pull this out to top-level for a real SDK build.
"//third_party/zlib",
]

View file

@ -10,8 +10,14 @@
#include <errno.h> // NOLINT
#include <stdlib.h> // NOLINT
#include <string.h> // NOLINT
#include <sys/stat.h> // NOLINT
#include <unistd.h> // NOLINT
#include "bin/dartutils.h"
#include "bin/file.h"
#include "bin/platform.h"
#include "platform/signal_blocker.h"
namespace dart {
namespace bin {
@ -94,8 +100,31 @@ void DirectoryListingEntry::ResetLink() {
Directory::ExistsResult Directory::Exists(const char* dir_name) {
UNIMPLEMENTED();
return UNKNOWN;
struct stat entry_info;
int success = NO_RETRY_EXPECTED(stat(dir_name, &entry_info));
if (success == 0) {
if (S_ISDIR(entry_info.st_mode)) {
return EXISTS;
} else {
return DOES_NOT_EXIST;
}
} else {
if ((errno == EACCES) ||
(errno == EBADF) ||
(errno == EFAULT) ||
(errno == ENOMEM) ||
(errno == EOVERFLOW)) {
// Search permissions denied for one of the directories in the
// path or a low level error occured. We do not know if the
// directory exists.
return UNKNOWN;
}
ASSERT((errno == ELOOP) ||
(errno == ENAMETOOLONG) ||
(errno == ENOENT) ||
(errno == ENOTDIR));
return DOES_NOT_EXIST;
}
}

0
tools/list_pkg_directories.py Normal file → Executable file
View file

24
tools/make_links.py Normal file → Executable file
View file

@ -38,26 +38,35 @@ def get_options():
result.add_option("--timestamp_file", "",
help='Create a timestamp file when done creating the links.',
default='')
result.add_option("-q", "--quiet",
help="Don't print any messages",
action="store_true",
dest="quiet",
default=False)
return result.parse_args()
def make_link(source, target, orig_source):
def make_link(quiet, source, target, orig_source):
if os.path.islink(target):
print 'Removing %s' % target
if not quiet:
print 'Removing %s' % target
sys.stdout.flush()
os.unlink(target)
if os.path.isdir(target):
print 'Removing %s' % target
if not quiet:
print 'Removing %s' % target
sys.stdout.flush()
os.rmdir(target)
if os.path.isfile(orig_source):
print 'Copying file from %s to %s' % (orig_source, target)
if not quiet:
print 'Copying file from %s to %s' % (orig_source, target)
sys.stdout.flush()
shutil.copyfile(orig_source, target)
return 0
else:
print 'Creating link from %s to %s' % (source, target)
if not quiet:
print 'Creating link from %s to %s' % (source, target)
sys.stdout.flush()
if utils.GuessOS() == 'win32':
@ -90,7 +99,7 @@ def main(argv):
os.remove(full_link)
else:
os.makedirs(target)
linked_names = {};
linked_names = {};
for source in args[1:]:
# Assume the source directory is named ".../NAME/lib".
split = source.split(':')
@ -117,7 +126,8 @@ def main(argv):
source = os.path.relpath(source)
else:
source = os.path.relpath(source, start=target)
exit_code = make_link(source, os.path.join(target, name), orig_source)
exit_code = make_link(
options.quiet, source, os.path.join(target, name), orig_source)
if exit_code != 0:
return exit_code
create_timestamp_file(options)