| Index: mojo/services/network/upload_network_service.py
|
| diff --git a/mojo/services/network/upload_network_service.py b/mojo/services/network/upload_network_service.py
|
| index 510494d750b9e717e6d8ac666d902f1d26a89285..ac7b619a4624c72ffc2ef1f4f897242367271624 100755
|
| --- a/mojo/services/network/upload_network_service.py
|
| +++ b/mojo/services/network/upload_network_service.py
|
| @@ -12,6 +12,10 @@ import tempfile
|
| import time
|
| import zipfile
|
|
|
| +if not sys.platform.startswith("linux"):
|
| + print "Only support linux for now"
|
| + sys.exit(1)
|
| +
|
| root_path = os.path.realpath(
|
| os.path.join(
|
| os.path.dirname(
|
| @@ -22,13 +26,6 @@ root_path = os.path.realpath(
|
| version = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=root_path)
|
| version = version.strip()
|
|
|
| -if not sys.platform.startswith("linux"):
|
| - print "Only support linux for now"
|
| - sys.exit(1)
|
| -
|
| -platform = "linux-x64" # TODO: Parameterize
|
| -binary_dest = "gs://mojo/network/" + version + "/" + platform + ".zip"
|
| -
|
| find_depot_tools_path = os.path.join(root_path, "tools", "find_depot_tools.py")
|
| find_depot_tools = imp.load_source("find_depot_tools", find_depot_tools_path)
|
|
|
| @@ -43,30 +40,61 @@ def gsutil_cp(source, dest, dry_run):
|
| subprocess.check_call([gsutil_exe, "cp", source, dest])
|
|
|
|
|
| -def upload_binary(binary_path, dry_run):
|
| +def upload_mojoms(dry_run):
|
| + absolute_mojom_directory_path = os.path.join(
|
| + os.path.dirname(os.path.realpath(__file__)),
|
| + "public",
|
| + "interfaces")
|
| + dest = "gs://mojo/network/" + version + "/" + "mojoms.zip"
|
| + with tempfile.NamedTemporaryFile() as mojom_zip_file:
|
| + with zipfile.ZipFile(mojom_zip_file, 'w') as z:
|
| + for root, _, files in os.walk(absolute_mojom_directory_path):
|
| + for filename in files:
|
| + absolute_file_path = os.path.join(root, filename)
|
| + relative_file_path = os.path.relpath(absolute_file_path, root)
|
| + z.write(absolute_file_path, relative_file_path)
|
| + gsutil_cp(mojom_zip_file.name, dest, dry_run)
|
| +
|
| +
|
| +def upload_binary(binary_path, platform, dry_run):
|
| absolute_binary_path = os.path.join(root_path, binary_path)
|
| + binary_dest = "gs://mojo/network/" + version + "/" + platform + ".zip"
|
| with tempfile.NamedTemporaryFile() as binary_zip_file:
|
| with zipfile.ZipFile(binary_zip_file, 'w') as z:
|
| with open(absolute_binary_path) as service_binary:
|
| - zipinfo = zipfile.ZipInfo("libnetwork_service.so")
|
| + zipinfo = zipfile.ZipInfo("network_service.mojo")
|
| zipinfo.external_attr = 0o777 << 16
|
| zipinfo.compress_type = zipfile.ZIP_DEFLATED
|
| zipinfo.date_time = time.gmtime(os.path.getmtime(absolute_binary_path))
|
| z.writestr(zipinfo, service_binary.read())
|
| - gsutil_cp(binary_zip_file.name, binary_dest, dry_run)
|
| + gsutil_cp(binary_zip_file.name, binary_dest, dry_run)
|
|
|
|
|
| def main():
|
| parser = argparse.ArgumentParser(
|
| - description="Upload network service binary to Google storage")
|
| + description="Upload network service mojoms and binaries to Google " +
|
| + "storage")
|
| parser.add_argument("-n", "--dry-run", action="store_true", help="Dry run")
|
| parser.add_argument(
|
| - "binary_path",
|
| - help="Path to network service binary relative to the repo root, e.g. " +
|
| - "out/Release/libnetwork_service.so")
|
| + "--linux-x64-binary-path",
|
| + help="Path to the linux-x64 network service binary relative to the " +
|
| + "repo root, e.g. out/Release/network_service.mojo")
|
| + parser.add_argument(
|
| + "--android-arm-binary-path",
|
| + help="Path to the android-arm network service binary relative to the " +
|
| + "repo root, e.g. out/android_Release/network_service.mojo")
|
| +
|
| args = parser.parse_args()
|
| - upload_binary(args.binary_path, args.dry_run)
|
| - print "Uploaded artifacts for %s %s" % (version, "linux-x64")
|
| + upload_mojoms(args.dry_run)
|
| + if args.linux_x64_binary_path:
|
| + upload_binary(args.linux_x64_binary_path, "linux-x64", args.dry_run)
|
| + if args.android_arm_binary_path:
|
| + upload_binary(args.android_arm_binary_path, "android-arm", args.dry_run)
|
| +
|
| + if not args.dry_run:
|
| + print "Uploaded artifacts for version %s" % (version, )
|
| + else:
|
| + print "No artifacts uploaded (dry run)"
|
| return 0
|
|
|
| if __name__ == '__main__':
|
|
|