[Android] Prepare existing code for revertable CIPD DEPS conversion.

This includes:
 - ensuring that symlinks that CIPD creates for files currently
   managed by update_third_party_deps.py get removed by that
   script.
 - changing switching to copy_ex in process_java_prebuilt s.t.
   symlinks are correctly handled by that template.

Bug: 755920
Change-Id: I1a75ae3acd96ce827401d8d58f8f1127ad09eadb
Reviewed-on: https://chromium-review.googlesource.com/701495
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: John Budorick <jbudorick@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#506821}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: c74acf2507bf54f87a72e4140e4e8e994dda84cd
This commit is contained in:
John Budorick 2017-10-05 19:27:11 +00:00 коммит произвёл Commit Bot
Родитель 2f861dd743
Коммит d0a1fc7292
4 изменённых файлов: 37 добавлений и 17 удалений

Просмотреть файл

@ -30,6 +30,14 @@ def CopyFile(f, dest, deps):
shutil.copytree(f, os.path.join(dest, os.path.basename(f)))
deps.extend(_get_all_files(f))
else:
if os.path.exists(dest):
# We remove the destination here if it already exists because,
# if the destination is a symlink, shutil.copy() will copy to
# the link target rather than replacing the link.
if os.path.isfile(dest):
os.remove(dest)
elif os.path.isfile(os.path.join(dest, os.path.basename(f))):
os.remove(os.path.join(dest, os.path.basename(f)))
shutil.copy(f, dest)
deps.append(f)

Просмотреть файл

@ -64,6 +64,14 @@ def _CheckFileList(local_path, file_list):
return abs_path_list
def _PurgeSymlinks(local_path):
for dirpath, _, filenames in os.walk(local_path):
for f in filenames:
path = os.path.join(dirpath, f)
if os.path.islink(path):
os.remove(path)
def Upload(arguments):
"""Upload files in a third_party directory to google storage"""
bucket_url, local_path = _CheckPaths(arguments.bucket_path,
@ -84,6 +92,7 @@ def Download(arguments):
"""Download files based on sha1 files in a third_party dir from gcs"""
bucket_url, local_path = _CheckPaths(arguments.bucket_path,
arguments.local_path)
_PurgeSymlinks(local_path)
download_from_google_storage.download_from_google_storage(
local_path,
bucket_url,

Просмотреть файл

@ -390,6 +390,7 @@ template("copy_ex") {
"data",
"deps",
"inputs",
"outputs",
"sources",
"testonly",
"visibility",
@ -398,28 +399,14 @@ template("copy_ex") {
sources = []
}
script = "//build/android/gyp/copy_ex.py"
depfile = "$target_gen_dir/$target_name.d"
_stamp_file = "$target_gen_dir/$target_name.stamp"
outputs = [
_stamp_file,
]
args = [
"--depfile",
rebase_path(depfile, root_build_dir),
"--stamp",
rebase_path(_stamp_file, root_build_dir),
"--dest",
rebase_path(invoker.dest, root_build_dir),
]
rebased_sources = rebase_path(sources, root_build_dir)
args += [ "--files=$rebased_sources" ]
if (defined(invoker.clear_dir) && invoker.clear_dir) {
args += [ "--clear" ]
}
if (defined(invoker.args)) {
args += invoker.args
}
@ -1335,7 +1322,11 @@ if (enable_java_templates) {
}
_output_jar_target = "${target_name}__copy"
copy(_output_jar_target) {
# This is copy_ex rather than copy to ensure that JARs (rather than
# possibly broken symlinks to them) get copied into the output
# directory.
copy_ex(_output_jar_target) {
deps = _deps
if (defined(invoker.deps)) {
deps += invoker.deps
@ -1343,6 +1334,7 @@ if (enable_java_templates) {
if (defined(invoker.public_deps)) {
public_deps = invoker.public_deps
}
dest = _output_jar_path
sources = [
_previous_output_jar,
]

Просмотреть файл

@ -69,8 +69,6 @@ template("create_native_executable_dist") {
}
copy_ex(target_name) {
clear_dir = true
inputs = [
_libraries_list,
invoker.binary,
@ -84,6 +82,7 @@ template("create_native_executable_dist") {
_rebased_libraries_list = rebase_path(_libraries_list, root_build_dir)
_rebased_binaries_list = rebase_path([ invoker.binary ], root_build_dir)
args = [
"--clear",
"--files=@FileArg($_rebased_libraries_list:lib_paths)",
"--files=$_rebased_binaries_list",
]
@ -92,6 +91,18 @@ template("create_native_executable_dist") {
args += [ "--files=$_rebased_extra_files" ]
}
_depfile = "$target_gen_dir/$target_name.d"
_stamp_file = "$target_gen_dir/$target_name.stamp"
outputs = [
_stamp_file,
]
args += [
"--depfile",
rebase_path(_depfile, root_build_dir),
"--stamp",
rebase_path(_stamp_file, root_build_dir),
]
deps = [
":$_find_deps_target_name",
]