mach_commands.py (1065B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, # You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 6 import os 7 8 from mach.decorators import Command, CommandArgument 9 from mozpack.copier import Jarrer 10 from mozpack.files import FileFinder 11 12 13 @Command("tps-build", category="testing", description="Build TPS add-on.") 14 @CommandArgument("--dest", default=None, help="Where to write add-on.") 15 def build(command_context, dest): 16 src = os.path.join( 17 command_context.topsrcdir, "services", "sync", "tps", "extensions", "tps" 18 ) 19 dest = os.path.join( 20 dest or os.path.join(command_context.topobjdir, "services", "sync"), 21 "tps.xpi", 22 ) 23 24 if not os.path.exists(os.path.dirname(dest)): 25 os.makedirs(os.path.dirname(dest)) 26 27 if os.path.isfile(dest): 28 os.unlink(dest) 29 30 jarrer = Jarrer() 31 for p, f in FileFinder(src).find("*"): 32 jarrer.add(p, f) 33 jarrer.copy(dest) 34 35 print("Built TPS add-on as %s" % dest)