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

Unified Diff: tools/make_links.py

Issue 1746743002: Use checked-in .package file for building and testing (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Stop creating [build_dir]/packages Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: tools/make_links.py
diff --git a/tools/make_links.py b/tools/make_links.py
index d49af30c70081582146fbda069926a7258ff1438..6b58713e5fbedf490b00365ba3a75d7ff920c3a8 100755
--- a/tools/make_links.py
+++ b/tools/make_links.py
@@ -26,6 +26,8 @@ import os
import shutil
import subprocess
import sys
+import urllib
+import urlparse
import utils
# Useful messages when we find orphaned checkouts.
@@ -43,6 +45,15 @@ def get_options():
action="store_true",
dest="quiet",
default=False)
+ result.add_option("--create-links",
+ help='Create links to the package lib directories in "packages/".',
+ action='store_false',
+ default=True)
+ result.add_option("--create-package-file",
+ help='Create a ".packages" file pointing to the packages.',
+ action='store_false',
+ default=True)
+
return result.parse_args()
def make_link(quiet, source, target, orig_source):
@@ -81,25 +92,28 @@ def create_timestamp_file(options):
os.mkdir(dir_name)
open(options.timestamp_file, 'w').close()
-
def main(argv):
(options, args) = get_options()
- target = os.path.relpath(args[0])
- if os.path.exists(target):
- # If the packages directory already exists, delete the current links inside
- # it. This is necessary, otherwise we can end up having links in there
- # pointing to directories which no longer exist (on incremental builds).
- for link in os.listdir(target):
- full_link = os.path.join(target, link)
- if os.path.isdir(full_link) and utils.IsWindows():
- # It seems like python on Windows is treating pseudo symlinks to
- # directories as directories.
- os.rmdir(full_link)
- else:
- os.remove(full_link)
- else:
- os.makedirs(target)
+ target_dir = os.path.relpath(args[0])
+ if options.create_links:
+ target = os.path.join(target_dir, 'packages')
+ if os.path.exists(target):
+ # If the packages directory already exists, delete the current links in
+ # it. This is necessary, otherwise we can end up having links in there
+ # pointing to directories which no longer exist (on incremental builds).
+ for link in os.listdir(target):
+ full_link = os.path.join(target, link)
+ if os.path.isdir(full_link) and utils.IsWindows():
+ # It seems like python on Windows is treating pseudo symlinks to
+ # directories as directories.
+ os.rmdir(full_link)
+ else:
+ os.remove(full_link)
+ else:
+ os.makedirs(target)
+
linked_names = {};
+ package_file_contents = '# .package file created by tools/make_links.py\n'
for source in args[1:]:
# Assume the source directory is named ".../NAME/lib".
split = source.split(':')
@@ -122,14 +136,21 @@ def main(argv):
return 1
linked_names[name] = path
orig_source = source
- if utils.GuessOS() == 'win32':
- source = os.path.relpath(source)
- else:
- source = os.path.relpath(source, start=target)
- exit_code = make_link(
- options.quiet, source, os.path.join(target, name), orig_source)
- if exit_code != 0:
- return exit_code
+ if options.create_links:
+ if utils.GuessOS() == 'win32':
+ source = os.path.relpath(source)
+ else:
+ source = os.path.relpath(source, start=target)
+ exit_code = make_link(options.quiet,
+ source, os.path.join(target, name), orig_source)
+ if exit_code != 0:
+ return exit_code
+ abs_source = os.path.abspath(orig_source)
+ source_url = urlparse.urljoin('file:', urllib.pathname2url(abs_source))
+ package_file_contents += '%s:%s\n' % (name, source_url)
+ if options.create_package_file:
+ with open(os.path.join(target_dir, '.packages'), 'w') as package_file:
+ package_file.write(package_file_contents)
create_timestamp_file(options)
return 0

Powered by Google App Engine
This is Rietveld 408576698