ICU-10491 a little less simple… added some things needed for swapping to java.

X-SVN-Rev: 34576
This commit is contained in:
Steven R. Loomis 2013-10-17 06:04:01 +00:00
parent 2914240e10
commit 29d9ed392c

View file

@ -42,6 +42,7 @@ parser.add_argument('-f', '--from', action='append', dest='fromdirs', help='read
parser.add_argument('-n', '--name', action='store', help='set the bundle name, such as "myapp"', metavar='bundname', required=True)
parser.add_argument('-m', '--mode', action='store', help='pkgdata mode', metavar='mode', default="archive")
parser.add_argument('-d', '--dest', action='store', dest='destdir', help='dest dir, default is ".".', default=".", metavar='destdir')
parser.add_argument('-e', '--endian', action='store', dest='endian', help='endian, big or little, default is "host".', default="host", metavar='endianness')
parser.add_argument('--verbose', '-v', action='count',default=0)
args = parser.parse_args()
@ -56,6 +57,25 @@ os.makedirs('%s/%s/' % (args.destdir, tmpdir))
listname = '%s/%s/icufiles.lst' % (args.destdir, tmpdir)
if args.endian not in ("big","little","host"):
print "Unknown endianness: %s" % args.endian
sys.exit(1)
if args.endian not in ("big"):
print "Unsupported endianness: %s" % args.endian
sys.exit(1)
needswap = args.endian not in ("host")
if needswap and args.mode not in ("archive", "files"):
print "Don't know how to do swapping for mode=%s" % args.mode
sys.exit(1)
pkgmode = args.mode
if needswap and args.mode in ("files"):
pkgmode = "archive"
if args.verbose > 0:
print ">%s" % (listname)
listfn = open(listname, 'w')
@ -129,8 +149,41 @@ for gen in gens:
print "# " + cmd
os.system(cmd)
cmd = 'pkgdata -m "%s" -T "%s/%s" -p "%s" -s "%s/%s" -d "%s" "%s"' % (args.mode,args.destdir,tmpdir,args.name,args.destdir,tmpdir,args.destdir,listname)
cmd = 'pkgdata -m "%s" -T "%s/%s" -p "%s" -s "%s/%s" -d "%s" "%s"' % (pkgmode,args.destdir,tmpdir,args.name,args.destdir,tmpdir,args.destdir,listname)
if (args.verbose>1):
cmd = cmd + " -v"
print "# " + cmd
os.system(cmd)
rc = os.system(cmd)
if rc is not 0:
print "# Command failed: " + cmd
sys.exit(rc)
if needswap:
outfile = "%s/%s.dat" % (args.destdir, args.name)
tmpfile = "%s/%s/%s.dat" % (args.destdir, tmpdir, args.name)
if args.mode in ("files","archive"):
print "# %s -> %s" % (outfile, tmpfile)
os.rename(outfile,tmpfile)
# swap tmp back to out
cmd = 'icupkg -w -tb "%s" "%s"' % (tmpfile, outfile)
if (args.verbose>1):
cmd = cmd + " -v"
print "# " + cmd
rc = os.system(cmd)
if rc is not 0:
print "# Swap command failed: " + cmd
sys.exit(rc)
# fall through for files mode.
if args.mode in ("files"):
os.mkdir("%s/%s/" % (args.destdir, args.name))
# unpack
cmd = 'icupkg -tb -x "%s" -d "%s/%s/" "%s"' % (listname, args.destdir, args.name, outfile)
if (args.verbose>1):
cmd = cmd + " -v"
print "# " + cmd
rc = os.system(cmd)
if rc is not 0:
print "# Swap command failed: " + cmd
sys.exit(rc)
# todo cleanup??