Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: packagerKMeleon.py

Issue 8627097: Moved Chrome extension scripts to buildtools repository (Closed)
Patch Set: Added build.py gettranslations support for Chrome Created Oct. 22, 2012, 11:25 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This Source Code is subject to the terms of the Mozilla Public License 3 # This Source Code is subject to the terms of the Mozilla Public License
4 # version 2.0 (the "License"). You can obtain a copy of the License at 4 # version 2.0 (the "License"). You can obtain a copy of the License at
5 # http://mozilla.org/MPL/2.0/. 5 # http://mozilla.org/MPL/2.0/.
6 6
7 import os, subprocess, re, tempfile, shutil, json 7 import os, subprocess, re, tempfile, shutil, json
8 import buildtools.packager as packager 8 import buildtools.packagerGecko as packagerBase
9 9
10 libs = ( 10 libs = (
11 'libcmt.lib', 'kernel32.lib', 'user32.lib', 'gdi32.lib', 'comctl32.lib', 11 'libcmt.lib', 'kernel32.lib', 'user32.lib', 'gdi32.lib', 'comctl32.lib',
12 'nspr4.lib', 'plds4.lib', 'plc4.lib', 'xpcom.lib', 'xpcomglue_s.lib', 12 'nspr4.lib', 'plds4.lib', 'plc4.lib', 'xpcom.lib', 'xpcomglue_s.lib',
13 'embed_base_s.lib', 'unicharutil_external_s.lib', 'js3250.lib' 13 'embed_base_s.lib', 'unicharutil_external_s.lib', 'js3250.lib'
14 ) 14 )
15 compileflags = ('-c', '-O1', '-W3', '-MT', '-DXP_WIN', '-Zc:wchar_t-') 15 compileflags = ('-c', '-O1', '-W3', '-MT', '-DXP_WIN', '-Zc:wchar_t-')
16 linkflags = ('-DLL', '-NODEFAULTLIB', '-NOLOGO') 16 linkflags = ('-DLL', '-NODEFAULTLIB', '-NOLOGO')
17 versionflag = '-DABP_VERSION="%s"' 17 versionflag = '-DABP_VERSION="%s"'
18 18
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 subprocess.Popen(command).communicate() 85 subprocess.Popen(command).communicate()
86 86
87 handle = open(outFile, 'rb') 87 handle = open(outFile, 'rb')
88 result = handle.read() 88 result = handle.read()
89 handle.close() 89 handle.close()
90 return result 90 return result
91 finally: 91 finally:
92 shutil.rmtree(tempDir, ignore_errors=True) 92 shutil.rmtree(tempDir, ignore_errors=True)
93 93
94 def createManifest(baseExtDir, params): 94 def createManifest(baseExtDir, params):
95 localeMetadata = packager.readLocaleMetadata(baseExtDir, params['locales']) 95 localeMetadata = packagerBase.readLocaleMetadata(baseExtDir, params['locales'] )
96 96
97 manifest = {} 97 manifest = {}
98 metadata = params['metadata'] 98 metadata = params['metadata']
99 manifest['id'] = metadata.get('general', 'id') 99 manifest['id'] = metadata.get('general', 'id')
100 manifest['version'] = metadata.get('general', 'version') 100 manifest['version'] = metadata.get('general', 'version')
101 manifest['version'] = params['version'] 101 manifest['version'] = params['version']
102 manifest['name'] = localeMetadata[packager.defaultLocale]['name'] 102 manifest['name'] = localeMetadata[packagerBase.defaultLocale]['name']
103 manifest['description'] = localeMetadata[packager.defaultLocale]['description' ] 103 manifest['description'] = localeMetadata[packagerBase.defaultLocale]['descript ion']
104 manifest['creator'] = metadata.get('general', 'author') 104 manifest['creator'] = metadata.get('general', 'author')
105 manifest['homepage'] = metadata.get('homepage', 'default') 105 manifest['homepage'] = metadata.get('homepage', 'default')
106 if metadata.has_section('contributors'): 106 if metadata.has_section('contributors'):
107 manifest['contributors'] = map(lambda item: item[1], metadata.items('contrib utors')) 107 manifest['contributors'] = map(lambda item: item[1], metadata.items('contrib utors'))
108 manifest['contributors'].sort() 108 manifest['contributors'].sort()
109 else: 109 else:
110 manifest['contributors'] = [] 110 manifest['contributors'] = []
111 manifest['translators'] = packager.getTranslators(localeMetadata) 111 manifest['translators'] = packagerBase.getTranslators(localeMetadata)
112 return 'var EXPORTED_SYMBOLS = ["manifest"];\nvar manifest = ' + json.dumps(ma nifest) 112 return 'var EXPORTED_SYMBOLS = ["manifest"];\nvar manifest = ' + json.dumps(ma nifest)
113 113
114 def processChromeManifest(data, baseName): 114 def processChromeManifest(data, baseName):
115 # Manifest location is different in K-Meleon, update paths 115 # Manifest location is different in K-Meleon, update paths
116 data = re.sub(r'jar:chrome/', 'jar:', data) 116 data = re.sub(r'jar:chrome/', 'jar:', data)
117 data = re.sub(r'(\s)modules/', r'\1../modules/%s/' % baseName, data) 117 data = re.sub(r'(\s)modules/', r'\1../modules/%s/' % baseName, data)
118 data = re.sub(r'(\s)defaults/', r'\1../defaults/', data) 118 data = re.sub(r'(\s)defaults/', r'\1../defaults/', data)
119 return data 119 return data
120 120
121 def createBuild(baseDir, outFile=None, locales=None, buildNum=None, releaseBuild =False): 121 def createBuild(baseDir, outFile=None, locales=None, buildNum=None, releaseBuild =False):
122 if buildNum == None: 122 if buildNum == None:
123 buildNum = packager.getBuildNum(baseDir) 123 buildNum = packagerBase.getBuildNum(baseDir)
124 124
125 baseExtDir = getBaseExtensionDir(baseDir) 125 baseExtDir = getBaseExtensionDir(baseDir)
126 if locales == None: 126 if locales == None:
127 locales = packager.getLocales(baseExtDir) 127 locales = packagerBase.getLocales(baseExtDir)
128 elif locales == 'all': 128 elif locales == 'all':
129 locales = packager.getLocales(baseExtDir, True) 129 locales = packagerBase.getLocales(baseExtDir, True)
130 130
131 metadata = packager.readMetadata(baseExtDir) 131 metadata = packagerBase.readMetadata(baseExtDir)
132 version = metadata.get('general', 'version') 132 version = metadata.get('general', 'version')
133 if not releaseBuild: 133 if not releaseBuild:
134 version += '.' + buildNum 134 version += '.' + buildNum
135 135
136 params = { 136 params = {
137 'locales': locales, 137 'locales': locales,
138 'releaseBuild': releaseBuild, 138 'releaseBuild': releaseBuild,
139 'buildNum': buildNum, 139 'buildNum': buildNum,
140 'version': version.encode('utf-8'), 140 'version': version.encode('utf-8'),
141 'metadata': metadata, 141 'metadata': metadata,
142 'limitMetadata': False, 142 'limitMetadata': False,
143 } 143 }
144 baseName = metadata.get('general', 'baseName') 144 baseName = metadata.get('general', 'baseName')
145 145
146 chromeFiles = {} 146 chromeFiles = {}
147 for xulFile in getXULFiles(baseDir): 147 for xulFile in getXULFiles(baseDir):
148 packager.readFile(chromeFiles, params, xulFile, 'content/ui/%s' % os.path.ba sename(xulFile)) 148 packagerBase.readFile(chromeFiles, params, xulFile, 'content/ui/%s' % os.pat h.basename(xulFile))
149 149
150 files = {} 150 files = {}
151 files['modules/%s/Manifest.jsm' % baseName] = createManifest(baseExtDir, param s) 151 files['modules/%s/Manifest.jsm' % baseName] = createManifest(baseExtDir, param s)
152 files['kplugins/%s.dll' % baseName] = buildDLL(baseDir, '%s.dll' % baseName, v ersion) 152 files['kplugins/%s.dll' % baseName] = buildDLL(baseDir, '%s.dll' % baseName, v ersion)
153 files['chrome/%s.jar' % baseName] = packager.createChromeJar(baseExtDir, param s, files=chromeFiles) 153 files['chrome/%s.jar' % baseName] = packagerBase.createChromeJar(baseExtDir, p arams, files=chromeFiles)
154 154
155 packager.readFile(files, params, os.path.join(baseExtDir, 'chrome.manifest'), 'chrome/%s.manifest' % baseName) 155 packagerBase.readFile(files, params, os.path.join(baseExtDir, 'chrome.manifest '), 'chrome/%s.manifest' % baseName)
156 files['chrome/%s.manifest' % baseName] = processChromeManifest(files['chrome/% s.manifest' % baseName], baseName) 156 files['chrome/%s.manifest' % baseName] = processChromeManifest(files['chrome/% s.manifest' % baseName], baseName)
157 157
158 for macroFile in getMacroFiles(baseDir): 158 for macroFile in getMacroFiles(baseDir):
159 packager.readFile(files, params, macroFile, 'macros/%s' % os.path.basename(m acroFile)) 159 packagerBase.readFile(files, params, macroFile, 'macros/%s' % os.path.basena me(macroFile))
160 for interfaceFile in getInterfaceFiles(baseDir): 160 for interfaceFile in getInterfaceFiles(baseDir):
161 packager.readFile(files, params, interfaceFile, 'components/%s' % os.path.ba sename(interfaceFile)) 161 packagerBase.readFile(files, params, interfaceFile, 'components/%s' % os.pat h.basename(interfaceFile))
162 for moduleFile in getModuleFiles(baseDir): 162 for moduleFile in getModuleFiles(baseDir):
163 packager.readFile(files, params, moduleFile, 'modules/%s/%s' % (baseName, os .path.basename(moduleFile))) 163 packagerBase.readFile(files, params, moduleFile, 'modules/%s/%s' % (baseName , os.path.basename(moduleFile)))
164 for prefsFile in getPrefsFiles(baseDir): 164 for prefsFile in getPrefsFiles(baseDir):
165 packager.readFile(files, params, prefsFile, 'defaults/pref/%s' % os.path.bas ename(prefsFile)) 165 packagerBase.readFile(files, params, prefsFile, 'defaults/pref/%s' % os.path .basename(prefsFile))
166 166
167 packager.readFile(files, params, os.path.join(baseExtDir, 'defaults'), 'defaul ts') 167 packagerBase.readFile(files, params, os.path.join(baseExtDir, 'defaults'), 'de faults')
168 packager.readFile(files, params, os.path.join(baseExtDir, 'modules'), 'modules /%s' %baseName) 168 packagerBase.readFile(files, params, os.path.join(baseExtDir, 'modules'), 'mod ules/%s' %baseName)
169 169
170 # Correct files names (defaults/preferences/ => defaults/pref/) 170 # Correct files names (defaults/preferences/ => defaults/pref/)
171 newFiles = {} 171 newFiles = {}
172 for key, value in files.iteritems(): 172 for key, value in files.iteritems():
173 if key.startswith('defaults/preferences/'): 173 if key.startswith('defaults/preferences/'):
174 key = 'defaults/pref/' + key[len('defaults/preferences/'):] 174 key = 'defaults/pref/' + key[len('defaults/preferences/'):]
175 newFiles[key] = value 175 newFiles[key] = value
176 files = newFiles 176 files = newFiles
177 177
178 # Allow local metadata to overrite settings from base extension 178 # Allow local metadata to overrite settings from base extension
179 metadata.read(packager.getMetadataPath(baseDir)) 179 metadata.read(packagerBase.getMetadataPath(baseDir))
180 if outFile == None: 180 if outFile == None:
181 outFile = packager.getDefaultFileName(baseDir, metadata, version, 'zip') 181 outFile = packagerBase.getDefaultFileName(baseDir, metadata, version, 'zip')
182 182
183 packager.writeXPI(files, outFile) 183 packagerBase.writeXPI(files, outFile)
OLDNEW
« packagerChrome.py ('K') | « packagerGecko.py ('k') | publicSuffixListUpdater.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld