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

Side by Side Diff: native_client_sdk/src/build_tools/build_sdk.py

Issue 11074004: [NaCl SDK] Generate NOTICE file automatically. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Entry point for both build and try bots 6 """Entry point for both build and try bots
7 7
8 This script is invoked from XXX, usually without arguments 8 This script is invoked from XXX, usually without arguments
9 to package an SDK. It automatically determines whether 9 to package an SDK. It automatically determines whether
10 this SDK is for mac, win, linux. 10 this SDK is for mac, win, linux.
11 11
12 The script inspects the following environment variables: 12 The script inspects the following environment variables:
13 13
14 BUILDBOT_BUILDERNAME to determine whether the script is run locally 14 BUILDBOT_BUILDERNAME to determine whether the script is run locally
15 and whether it should upload an SDK to file storage (GSTORE) 15 and whether it should upload an SDK to file storage (GSTORE)
16 """ 16 """
17 17
18 # pylint: disable=W0621 18 # pylint: disable=W0621
19 19
20 # std python includes 20 # std python includes
21 import copy 21 import copy
22 import datetime 22 import datetime
23 import generate_make 23 import generate_make
24 import optparse 24 import optparse
25 import os 25 import os
26 import re
26 import subprocess 27 import subprocess
27 import sys 28 import sys
28 29
29 # local includes 30 # local includes
30 import buildbot_common 31 import buildbot_common
31 import build_updater 32 import build_updater
32 import build_utils 33 import build_utils
34 import generate_notice
33 import manifest_util 35 import manifest_util
34 from tests import test_server 36 from tests import test_server
35 37
36 # Create the various paths of interest 38 # Create the various paths of interest
37 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 39 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
38 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) 40 SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR)
39 SDK_EXAMPLE_DIR = os.path.join(SDK_SRC_DIR, 'examples') 41 SDK_EXAMPLE_DIR = os.path.join(SDK_SRC_DIR, 'examples')
40 SDK_LIBRARY_DIR = os.path.join(SDK_SRC_DIR, 'libraries') 42 SDK_LIBRARY_DIR = os.path.join(SDK_SRC_DIR, 'libraries')
41 SDK_DIR = os.path.dirname(SDK_SRC_DIR) 43 SDK_DIR = os.path.dirname(SDK_SRC_DIR)
42 SRC_DIR = os.path.dirname(SDK_DIR) 44 SRC_DIR = os.path.dirname(SDK_DIR)
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 buildbot_common.MakeDir(pepperdir) 163 buildbot_common.MakeDir(pepperdir)
162 164
163 165
164 def BuildStepMakePepperDirs(pepperdir, subdirs): 166 def BuildStepMakePepperDirs(pepperdir, subdirs):
165 for subdir in subdirs: 167 for subdir in subdirs:
166 buildbot_common.MakeDir(os.path.join(pepperdir, subdir)) 168 buildbot_common.MakeDir(os.path.join(pepperdir, subdir))
167 169
168 170
169 def BuildStepCopyTextFiles(pepperdir, pepper_ver, revision): 171 def BuildStepCopyTextFiles(pepperdir, pepper_ver, revision):
170 buildbot_common.BuildStep('Add Text Files') 172 buildbot_common.BuildStep('Add Text Files')
171 files = ['AUTHORS', 'COPYING', 'LICENSE', 'NOTICE'] 173 files = ['AUTHORS', 'COPYING', 'LICENSE']
172 files = [os.path.join(SDK_SRC_DIR, filename) for filename in files] 174 files = [os.path.join(SDK_SRC_DIR, filename) for filename in files]
173 oshelpers.Copy(['-v'] + files + [pepperdir]) 175 oshelpers.Copy(['-v'] + files + [pepperdir])
174 176
175 # Replace a few placeholders in README 177 # Replace a few placeholders in README
176 readme_text = open(os.path.join(SDK_SRC_DIR, 'README'), 'rt').read() 178 readme_text = open(os.path.join(SDK_SRC_DIR, 'README'), 'rt').read()
177 readme_text = readme_text.replace('${VERSION}', pepper_ver) 179 readme_text = readme_text.replace('${VERSION}', pepper_ver)
178 readme_text = readme_text.replace('${REVISION}', revision) 180 readme_text = readme_text.replace('${REVISION}', revision)
179 181
180 # Year/Month/Day Hour:Minute:Second 182 # Year/Month/Day Hour:Minute:Second
181 time_format = '%Y/%m/%d %H:%M:%S' 183 time_format = '%Y/%m/%d %H:%M:%S'
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 # Clean to remove temporary files but keep the built libraries. 707 # Clean to remove temporary files but keep the built libraries.
706 buildbot_common.Run([make, '-j8', 'clean'], 708 buildbot_common.Run([make, '-j8', 'clean'],
707 cwd=os.path.abspath(make_dir)) 709 cwd=os.path.abspath(make_dir))
708 710
709 711
710 def BuildStepBuildLibraries(pepperdir, platform, directory, clean=True): 712 def BuildStepBuildLibraries(pepperdir, platform, directory, clean=True):
711 BuildStepMakeAll(pepperdir, platform, directory, 'Build Libraries', 713 BuildStepMakeAll(pepperdir, platform, directory, 'Build Libraries',
712 clean=clean) 714 clean=clean)
713 715
714 716
717 def BuildStepGenerateNotice(pepperdir):
718 # Look for LICENSE files
719 license_filenames_re = re.compile('LICENSE|COPYING')
720
721 license_files = []
722 for root, _, files in os.walk(pepperdir):
723 for filename in files:
724 if license_filenames_re.match(filename):
725 path = os.path.join(root, filename)
726 license_files.append(path)
727 print '\n'.join(license_files)
728
729 notice_filename = os.path.join(pepperdir, 'NOTICE')
730 args = ['--root', pepperdir, '-o', notice_filename]
731 args += license_files
732 generate_notice.main(args)
Sam Clegg 2012/10/06 01:05:59 Seems a little strange to me to construct command
binji 2012/10/08 17:51:48 Done.
733
734
715 def BuildStepTarBundle(pepper_ver, tarfile): 735 def BuildStepTarBundle(pepper_ver, tarfile):
716 buildbot_common.BuildStep('Tar Pepper Bundle') 736 buildbot_common.BuildStep('Tar Pepper Bundle')
717 buildbot_common.MakeDir(os.path.dirname(tarfile)) 737 buildbot_common.MakeDir(os.path.dirname(tarfile))
718 buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, 738 buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile,
719 'pepper_' + pepper_ver], cwd=NACL_DIR) 739 'pepper_' + pepper_ver], cwd=NACL_DIR)
720 740
721 741
722 def GetManifestBundle(pepper_ver, revision, tarfile, archive_url): 742 def GetManifestBundle(pepper_ver, revision, tarfile, archive_url):
723 with open(tarfile, 'rb') as tarfile_stream: 743 with open(tarfile, 'rb') as tarfile_stream:
724 archive_sha1, archive_size = manifest_util.DownloadAndComputeHash( 744 archive_sha1, archive_size = manifest_util.DownloadAndComputeHash(
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber) 976 BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber)
957 BuildStepUntarToolchains(pepperdir, platform, arch, toolchains) 977 BuildStepUntarToolchains(pepperdir, platform, arch, toolchains)
958 BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains) 978 BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains)
959 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs') 979 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs')
960 BuildStepCopyBuildHelpers(pepperdir, platform) 980 BuildStepCopyBuildHelpers(pepperdir, platform)
961 BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental, 981 BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental,
962 True) 982 True)
963 983
964 # Ship with libraries prebuilt, so run that first. 984 # Ship with libraries prebuilt, so run that first.
965 BuildStepBuildLibraries(pepperdir, platform, 'src') 985 BuildStepBuildLibraries(pepperdir, platform, 'src')
986 BuildStepGenerateNotice(pepperdir)
966 987
967 if not options.skip_tar: 988 if not options.skip_tar:
968 BuildStepTarBundle(pepper_ver, tarfile) 989 BuildStepTarBundle(pepper_ver, tarfile)
969 build_updater.BuildUpdater(OUT_DIR) 990 build_updater.BuildUpdater(OUT_DIR)
970 991
971 # BuildStepTestUpdater downloads the bundle to its own directory. Build 992 # BuildStepTestUpdater downloads the bundle to its own directory. Build
972 # the examples and test from this directory instead of the original. 993 # the examples and test from this directory instead of the original.
973 pepperdir = BuildStepTestUpdater(platform, pepper_ver, clnumber, tarfile) 994 pepperdir = BuildStepTestUpdater(platform, pepper_ver, clnumber, tarfile)
974 BuildStepBuildExamples(pepperdir, platform) 995 BuildStepBuildExamples(pepperdir, platform)
975 BuildStepCopyTests(pepperdir, toolchains, options.build_experimental, 996 BuildStepCopyTests(pepperdir, toolchains, options.build_experimental,
976 True) 997 True)
977 BuildStepBuildTests(pepperdir, platform) 998 BuildStepBuildTests(pepperdir, platform)
978 if options.test_examples: 999 if options.test_examples:
979 BuildStepRunPyautoTests(pepperdir, platform, pepper_ver) 1000 BuildStepRunPyautoTests(pepperdir, platform, pepper_ver)
980 1001
981 # Archive on non-trybots. 1002 # Archive on non-trybots.
982 if options.archive or buildbot_common.IsSDKBuilder(): 1003 if options.archive or buildbot_common.IsSDKBuilder():
983 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile) 1004 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile)
984 BuildStepArchiveSDKTools() 1005 BuildStepArchiveSDKTools()
985 1006
986 return 0 1007 return 0
987 1008
988 1009
989 if __name__ == '__main__': 1010 if __name__ == '__main__':
990 sys.exit(main(sys.argv)) 1011 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698