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

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: feedback 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
« no previous file with comments | « native_client_sdk/src/NOTICE ('k') | native_client_sdk/src/build_tools/generate_notice.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
24 import optparse 23 import optparse
25 import os 24 import os
25 import re
26 import subprocess 26 import subprocess
27 import sys 27 import sys
28 28
29 # local includes 29 # local includes
30 import buildbot_common 30 import buildbot_common
31 import build_updater 31 import build_updater
32 import build_utils 32 import build_utils
33 import generate_make
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 generate_notice.Generate(notice_filename, pepperdir, license_files)
731
732
715 def BuildStepTarBundle(pepper_ver, tarfile): 733 def BuildStepTarBundle(pepper_ver, tarfile):
716 buildbot_common.BuildStep('Tar Pepper Bundle') 734 buildbot_common.BuildStep('Tar Pepper Bundle')
717 buildbot_common.MakeDir(os.path.dirname(tarfile)) 735 buildbot_common.MakeDir(os.path.dirname(tarfile))
718 buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile, 736 buildbot_common.Run([sys.executable, CYGTAR, '-C', OUT_DIR, '-cjf', tarfile,
719 'pepper_' + pepper_ver], cwd=NACL_DIR) 737 'pepper_' + pepper_ver], cwd=NACL_DIR)
720 738
721 739
722 def GetManifestBundle(pepper_ver, revision, tarfile, archive_url): 740 def GetManifestBundle(pepper_ver, revision, tarfile, archive_url):
723 with open(tarfile, 'rb') as tarfile_stream: 741 with open(tarfile, 'rb') as tarfile_stream:
724 archive_sha1, archive_size = manifest_util.DownloadAndComputeHash( 742 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) 974 BuildStepCopyTextFiles(pepperdir, pepper_ver, clnumber)
957 BuildStepUntarToolchains(pepperdir, platform, arch, toolchains) 975 BuildStepUntarToolchains(pepperdir, platform, arch, toolchains)
958 BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains) 976 BuildStepBuildToolchains(pepperdir, platform, arch, pepper_ver, toolchains)
959 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs') 977 InstallHeaders(os.path.join(pepperdir, 'include'), None, 'libs')
960 BuildStepCopyBuildHelpers(pepperdir, platform) 978 BuildStepCopyBuildHelpers(pepperdir, platform)
961 BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental, 979 BuildStepCopyExamples(pepperdir, toolchains, options.build_experimental,
962 True) 980 True)
963 981
964 # Ship with libraries prebuilt, so run that first. 982 # Ship with libraries prebuilt, so run that first.
965 BuildStepBuildLibraries(pepperdir, platform, 'src') 983 BuildStepBuildLibraries(pepperdir, platform, 'src')
984 BuildStepGenerateNotice(pepperdir)
966 985
967 if not options.skip_tar: 986 if not options.skip_tar:
968 BuildStepTarBundle(pepper_ver, tarfile) 987 BuildStepTarBundle(pepper_ver, tarfile)
969 build_updater.BuildUpdater(OUT_DIR) 988 build_updater.BuildUpdater(OUT_DIR)
970 989
971 # BuildStepTestUpdater downloads the bundle to its own directory. Build 990 # BuildStepTestUpdater downloads the bundle to its own directory. Build
972 # the examples and test from this directory instead of the original. 991 # the examples and test from this directory instead of the original.
973 pepperdir = BuildStepTestUpdater(platform, pepper_ver, clnumber, tarfile) 992 pepperdir = BuildStepTestUpdater(platform, pepper_ver, clnumber, tarfile)
974 BuildStepBuildExamples(pepperdir, platform) 993 BuildStepBuildExamples(pepperdir, platform)
975 BuildStepCopyTests(pepperdir, toolchains, options.build_experimental, 994 BuildStepCopyTests(pepperdir, toolchains, options.build_experimental,
976 True) 995 True)
977 BuildStepBuildTests(pepperdir, platform) 996 BuildStepBuildTests(pepperdir, platform)
978 if options.test_examples: 997 if options.test_examples:
979 BuildStepRunPyautoTests(pepperdir, platform, pepper_ver) 998 BuildStepRunPyautoTests(pepperdir, platform, pepper_ver)
980 999
981 # Archive on non-trybots. 1000 # Archive on non-trybots.
982 if options.archive or buildbot_common.IsSDKBuilder(): 1001 if options.archive or buildbot_common.IsSDKBuilder():
983 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile) 1002 BuildStepArchiveBundle(pepper_ver, clnumber, tarfile)
984 BuildStepArchiveSDKTools() 1003 BuildStepArchiveSDKTools()
985 1004
986 return 0 1005 return 0
987 1006
988 1007
989 if __name__ == '__main__': 1008 if __name__ == '__main__':
990 sys.exit(main(sys.argv)) 1009 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « native_client_sdk/src/NOTICE ('k') | native_client_sdk/src/build_tools/generate_notice.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698