Skip to content

Commit 0bf80fe

Browse files
author
libm
committed
Build script updates picked from v0.9
1 parent e817a5f commit 0bf80fe

File tree

5 files changed

+171
-76
lines changed

5 files changed

+171
-76
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ Michael Morrison <mmorrison@wootalyzer.com>
2020
William Towe <willbur1984@gmail.com>
2121
Toni Lähdekorpi <toni@lygon.net>
2222
Youngwook Kim <youngwook.kim@gmail.com>
23+
Lithare Emileit <litharemilit@gmail.com>

nw.gypi

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -540,43 +540,25 @@
540540
],
541541
},
542542
{
543-
'target_name': 'strip',
544-
'type': 'none',
545-
'actions': [
546-
{
547-
'action_name': 'strip_nw_binaries',
548-
'inputs': [
549-
'<(PRODUCT_DIR)/nw',
550-
],
551-
'outputs': [
552-
'<(PRODUCT_DIR)/strip_nw.stamp',
553-
],
554-
'action': ['strip',
555-
'<@(_inputs)'],
556-
'message': 'Stripping release executable',
557-
},
558-
],
559-
'dependencies': [
560-
'nw',
561-
],
562-
},
563-
{
564-
'target_name': 'nw_symbols',
543+
'target_name': 'nw_strip_symbol',
565544
'type': 'none',
566545
'conditions': [
567546
['OS=="linux"', {
547+
'variables': {
548+
'linux_strip_binary': 1,
549+
},
568550
'actions': [
569551
{
570-
'action_name': 'dump_symbols',
552+
'action_name': 'dump_symbol_and_strip',
571553
'inputs': [
572-
'<(DEPTH)/build/linux/dump_app_syms',
554+
'<(DEPTH)/content/nw/tools/dump_app_syms',
573555
'<(PRODUCT_DIR)/dump_syms',
574556
'<(PRODUCT_DIR)/nw',
575557
],
576558
'outputs': [
577559
'<(PRODUCT_DIR)/nw.breakpad.<(target_arch)',
578560
],
579-
'action': ['<(DEPTH)/build/linux/dump_app_syms',
561+
'action': ['<(DEPTH)/content/nw/tools/dump_app_syms',
580562
'<(PRODUCT_DIR)/dump_syms',
581563
'<(linux_strip_binary)',
582564
'<(PRODUCT_DIR)/nw',
@@ -592,6 +574,33 @@
592574
}],
593575
],
594576
},
577+
{
578+
'target_name': 'strip_binaries',
579+
'type': 'none',
580+
'conditions': [
581+
['OS=="linux"', {
582+
'actions': [
583+
{
584+
'action_name': 'strip_nw_binaries',
585+
'inputs': [
586+
'<(PRODUCT_DIR)/nwsnapshot',
587+
'<(PRODUCT_DIR)/chromedriver2_server',
588+
],
589+
'outputs': [
590+
'<(PRODUCT_DIR)/strip_binaries.stamp',
591+
],
592+
'action': ['strip',
593+
'<@(_inputs)'],
594+
'message': 'Stripping release binaries',
595+
},
596+
],
597+
'dependencies': [
598+
'<(DEPTH)/v8/tools/gyp/v8.gyp:nwsnapshot',
599+
'<(DEPTH)/chrome/chrome.gyp:chromedriver2_server',
600+
],
601+
}],
602+
],
603+
},
595604
{
596605
'target_name': 'dist',
597606
'type': 'none',
@@ -612,12 +621,12 @@
612621
],
613622
'dependencies': [
614623
'<(DEPTH)/chrome/chrome.gyp:chromedriver2_server',
615-
'nw_symbols',
624+
'nw_strip_symbol',
616625
],
617626
'conditions': [
618627
['OS == "linux"', {
619628
'dependencies': [
620-
'strip',
629+
'strip_binaries',
621630
],
622631
}],
623632
],

tools/aws_uploader.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env python
2+
import argparse
3+
import boto
4+
import datetime
5+
import json
6+
import os
7+
8+
################################
9+
# Parse command line args
10+
parser = argparse.ArgumentParser(description='AWS uploader.')
11+
parser.add_argument('-p','--path', help='Optional. Where to find the binaries, normally out/Release/dist', required=False)
12+
parser.add_argument('-b','--buildername', help='Builder name, e.g. linux_32bit', required=True)
13+
parser.add_argument('-r','--revision', help='Commit revision',required=True)
14+
parser.add_argument('-n','--number', help='Build number', required=True)
15+
parser.add_argument('-t','--bucket', help='AWS bucket name', required=True)
16+
parser.add_argument('-k','--keyfile', help='Optional. JSON file containing AWS access id and key, default: ~/.awskey; ' +\
17+
'The content of the key file is like {"awsid":"ABCDEF","awskey":"123456"}', required=False)
18+
19+
args = parser.parse_args()
20+
21+
################################
22+
# Check and init variables
23+
dist_dir = args.path
24+
builder_name = args.buildername
25+
got_revision = args.revision
26+
build_number = args.number
27+
bucket_name = args.bucket
28+
keyfile = args.keyfile
29+
date = datetime.date.today().strftime('%m-%d-%Y')
30+
31+
# If the binaries location is not given, calculate it from script related dir.
32+
if dist_dir == None:
33+
dist_dir = os.path.join(os.path.dirname(__file__),
34+
os.pardir, os.pardir, os.pardir, 'out', 'Release', 'dist')
35+
36+
if not os.path.isabs(dist_dir):
37+
dist_dir = os.path.join(os.getcwd(), dist_dir)
38+
39+
if not os.path.isdir(dist_dir):
40+
print 'Invalid path: ' + dist_dir
41+
exit(-1)
42+
dist_dir = os.path.normpath(dist_dir)
43+
44+
# Check aws keyfile
45+
if keyfile == None:
46+
keyfile = os.path.join(os.path.expanduser('~'),'.awskey')
47+
print keyfile
48+
if not os.path.exists(keyfile):
49+
print "Cannot find aws key file"
50+
exit(-1)
51+
52+
json_data = open(keyfile)
53+
data = json.load(json_data)
54+
if not (data.has_key('awsid') and data.has_key('awskey')):
55+
print "Invalid key file format."
56+
exit(-1)
57+
awsid = data['awsid']
58+
awskey = data['awskey']
59+
60+
# it's for S3, so always use '/' here
61+
upload_path = ''.join(['/' + date,
62+
'/' + builder_name + '-build-' + build_number + '-' + got_revision])
63+
64+
file_list = os.listdir(dist_dir)
65+
if len(file_list) == 0:
66+
print 'Cannot find packages!'
67+
exit(-1)
68+
69+
70+
def print_progress(transmitted, total):
71+
print ' %d%% transferred of total: %d bytes.' % (transmitted*100/total, total)
72+
73+
74+
def aws_upload(upload_path, file_list):
75+
conn = boto.connect_s3(awsid, awskey)
76+
print 'Connecting to S3 ...'
77+
bucket = conn.get_bucket(bucket_name)
78+
print 'Uploading to: ' + upload_path
79+
for f in file_list:
80+
print 'Uploading "' + f + '" ...'
81+
# use '/' for s3
82+
key = bucket.new_key(upload_path + '/' + f)
83+
key.set_contents_from_filename(filename=os.path.join(dist_dir, f), cb=print_progress, num_cb=50, replace=True)
84+
85+
aws_upload(upload_path, file_list)
86+
print 'Done.'
87+
88+
89+
# vim: et:ts=4:sw=4

tools/dump_app_syms

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
#
7+
# Helper script to run dump_syms on Chrome Linux executables and strip
8+
# them if needed.
9+
10+
set -e
11+
12+
usage() {
13+
echo -n "$0 <dump_syms_exe> <strip_binary> " >&2
14+
echo "<binary_with_symbols> <symbols_output>" >&2
15+
}
16+
17+
18+
if [ $# -ne 4 ]; then
19+
usage
20+
exit 1
21+
fi
22+
23+
SCRIPTDIR="$(readlink -f "$(dirname "$0")")"
24+
DUMPSYMS="$1"
25+
STRIP_BINARY="$2"
26+
INFILE="$3"
27+
OUTFILE="$4"
28+
29+
# Dump the symbols from the given binary.
30+
if [ ! -e "$OUTFILE" -o "$INFILE" -nt "$OUTFILE" ]; then
31+
echo "bb"
32+
"$DUMPSYMS" -r "$INFILE" > "$OUTFILE"
33+
fi
34+
35+
if [ "$STRIP_BINARY" != "0" ]; then
36+
strip "$INFILE"
37+
# To avoid dumpping twice.
38+
echo "aa"
39+
touch "$OUTFILE"
40+
fi
41+
42+
43+

tools/package_binaries.py

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@
1515
parser = argparse.ArgumentParser(description='Package nw binaries.')
1616
parser.add_argument('-p','--path', help='Where to find the binaries, like out/Release', required=False)
1717
parser.add_argument('-s','--step', help='Execute specified step. (could be "nw", "chromedriver" or "symbol")', required=False)
18-
# AWS uploader args
19-
# Example: package_binaries.py -u -b linux_32bit -r 123 -n 99 -t my_bucket -i <id> -k <key>
20-
parser.add_argument('-u','--upload', help='Run aws uploader', action='store_true', required=False)
21-
parser.add_argument('-b','--buildername', help='Builder name', required=False)
22-
parser.add_argument('-r','--revision', help='Build revision',required=False)
23-
parser.add_argument('-n','--number', help='Build number', required=False)
24-
parser.add_argument('-t','--bucket', help='AWS bucket name', required=False)
25-
parser.add_argument('-i','--awsid', help='AWS_ACCESS_KEY_ID', required=False)
26-
parser.add_argument('-k','--awskey', help='AWS_SECRET_ACCESS_KEY', required=False)
27-
2818
args = parser.parse_args()
2919

3020
################################
@@ -275,44 +265,7 @@ def make_packages(targets):
275265
targets.append(generate_target_chromedriver(platform_name, arch, nw_ver))
276266
targets.append(generate_target_symbols(platform_name, arch, nw_ver))
277267

278-
if args.upload != True:
279-
print 'Creating packages...'
280-
make_packages(targets)
281-
exit(0)
282-
################################################################
283-
# aws uploader
284-
285-
from datetime import date
286-
287-
print 'Starting aws uploader...'
288-
289-
# Init variables
290-
builder_name = args.buildername
291-
got_revision = args.revision
292-
build_number = args.number
293-
bucket_name = args.bucket
294-
awsid = args.awsid
295-
awskey = args.awskey
296-
date = date.today().strftime('%m-%d-%y')
297-
298-
upload_path = ''.join(['/' + date,
299-
'/' + builder_name + '-build-' + build_number + '-' + got_revision])
300-
301-
print 'Upload path: ' + upload_path
302-
file_list = os.listdir(dist_dir)
303-
if len(file_list) == 0:
304-
print 'Cannot find packages!'
305-
exit(-1)
306-
307-
import boto
308-
conn = boto.connect_s3(awsid, awskey)
309-
bucket = conn.get_bucket(bucket_name)
310-
for f in file_list:
311-
print 'Uploading "' + f + '" ...'
312-
key = bucket.new_key(os.path.join(upload_path, f))
313-
key.set_contents_from_filename(os.path.join(dist_dir, f))
314-
315-
print 'Done.'
316-
268+
print 'Creating packages...'
269+
make_packages(targets)
317270

318271
# vim: et:ts=4:sw=4

0 commit comments

Comments
 (0)