]> granicus.if.org Git - icu/commitdiff
ICU-10491 a little less simpleā€¦ added some things needed for swapping to java.
authorSteven R. Loomis <srl@icu-project.org>
Thu, 17 Oct 2013 06:04:01 +0000 (06:04 +0000)
committerSteven R. Loomis <srl@icu-project.org>
Thu, 17 Oct 2013 06:04:01 +0000 (06:04 +0000)
X-SVN-Rev: 34576

tools/scripts/bldicures.py

index ac859652b798a728a10db1cbd9cf7d9c1017b8d4..907f8363c51d7c492c3ef89a0a03a3e1409bf03f 100755 (executable)
@@ -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??
+