summaryrefslogtreecommitdiff
path: root/tools/integrate/PushAndroidCode.java
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2009-10-08 00:25:33 -0700
committerJesse Wilson <jessewilson@google.com>2009-10-08 15:19:42 -0700
commitd383e2a5ddeb291769b0e59d47c5e8ff205c1f2c (patch)
tree182bdf901653702296dc18f59d2031b175a2400d /tools/integrate/PushAndroidCode.java
parent0141848387e6d359b660ad05086e7d8030af1568 (diff)
Tools to push code back upstream.
Diffstat (limited to 'tools/integrate/PushAndroidCode.java')
-rw-r--r--tools/integrate/PushAndroidCode.java87
1 files changed, 87 insertions, 0 deletions
diff --git a/tools/integrate/PushAndroidCode.java b/tools/integrate/PushAndroidCode.java
new file mode 100644
index 0000000000..c0002f5c99
--- /dev/null
+++ b/tools/integrate/PushAndroidCode.java
@@ -0,0 +1,87 @@
+// Copyright 2009 Google Inc. All Rights Reserved.
+
+import java.util.UUID;
+
+/**
+ * Copy the current Android sourcecode into Apache Harmony, where it can be
+ * reviewed and submitted to their SVN. Only run this script after first merging
+ * the latest harmony code into Android.
+ */
+public class PushAndroidCode {
+
+ private final String androidPath;
+ private final String harmonyPath;
+
+ public PushAndroidCode(String androidPath, String harmonyPath) {
+ this.androidPath = androidPath;
+ this.harmonyPath = harmonyPath;
+ }
+
+ public void push(Module module) {
+ Filesystem filesystem = new Filesystem();
+
+ // copy android code to a temp directory that is laid out like Harmony
+ String temp = "/tmp/" + UUID.randomUUID();
+ filesystem.mkdir(temp);
+ filesystem.copyContents(androidPath + "/" + module.path(),
+ temp + "/" + module.path());
+ for (MappedDirectory mappedDirectory : module.getMappedDirectories()) {
+ filesystem.moveContents(
+ temp + "/" + mappedDirectory.gitPath(),
+ temp + "/" + mappedDirectory.svnPath());
+ }
+
+ // clobber files from harmony with their Android equivalents
+ filesystem.copyContents(temp + "/" + module.path(),
+ harmonyPath + "/" + module.path());
+ }
+
+ public static void main(String[] args) {
+ if (args.length < 3) {
+ printUsage();
+ return;
+ }
+
+ String androidPath = args[0] + "/dalvik/libcore";
+ String harmonyPath = args[1] + "/working_classlib/modules";
+
+ // TODO: validate directories?
+
+ Module[] modules = new Module[args.length - 2];
+ for (int i = 0; i < modules.length; i++) {
+ modules[i] = Module.VALUES.get(args[i+2]);
+ if (modules[i] == null) {
+ System.out.println("No such module: " + args[i+2]);
+ return;
+ }
+ }
+
+ PushAndroidCode pusher = new PushAndroidCode(androidPath, harmonyPath);
+ for (Module module : modules) {
+ pusher.push(module);
+ }
+ }
+
+ private static void printUsage() {
+ System.out.println("This tool will clobber Harmony's core libraries with Android's copy");
+ System.out.println("so that a patch can be submitted upstream.");
+ System.out.println();
+ System.out.println("Usage: PushAndroidCode <android_root> <harmony_root> <module>...");
+ System.out.println();
+ System.out.println(" <android_root> is the android git client directory that contains dalvik");
+ System.out.println(" This should hold an up-to-date checkout of Android. The");
+ System.out.println(" target modules should also be up-to-date with respect to");
+ System.out.println(" Harmony; use the PullHarmonyCode tool first if necessary.");
+ System.out.println();
+ System.out.println(" <harmony_root> is the android client directory that contains working_classlib.");
+ System.out.println(" This should hold an up-to-date checkout of Harmony.");
+ System.out.println();
+ System.out.println(" <module> is one of " + Module.VALUES.keySet());
+ System.out.println();
+ System.out.println("Example usage:");
+ System.out.println(" java -cp out/host/linux-x86/framework/integrate.jar PushAndroidCode \\");
+ System.out.println(" /usr/local/google/jesse/clients/jessewilson_g1 \\");
+ System.out.println(" /usr/local/google/jesse/clients/jessewilson_h0/trunk \\");
+ System.out.println(" crypto");
+ }
+}