OSDN Git Service

envsetup: add a helper to fix "out/target/common" not being really common
authorChirayu Desai <cdesai@cyanogenmod.org>
Sun, 30 Jun 2013 04:34:25 +0000 (10:04 +0530)
committerSteve Kondik <steve@cyngn.com>
Sun, 4 Sep 2016 04:47:36 +0000 (21:47 -0700)
* out/target/common isn't really common, and if you do
  back to back builds for multiple devices, that is noticable.
* Use out/target/common-$device instead, and link the appropriate
  dir to out/target/common every time lunch() is run, if
  CM_FIXUP_COMMON_OUT is set.
* Refer https://groups.google.com/forum/#!topic/android-building/ispbOgzoyg8
  for more info.

Change-Id: I11e7df0e68e2a60ce32576f06397d60fc9465b60

envsetup.sh

index 12cd1f7..ab25989 100644 (file)
@@ -714,6 +714,8 @@ function lunch()
 
     echo
 
+    fixup_common_out_dir
+
     set_stuff_for_environment
     printconfig
     destroy_build_var_cache
@@ -2162,6 +2164,24 @@ function repopick() {
     $T/build/tools/repopick.py $@
 }
 
+function fixup_common_out_dir() {
+    common_out_dir=$(get_build_var OUT_DIR)/target/common
+    target_device=$(get_build_var TARGET_DEVICE)
+    if [ ! -z $CM_FIXUP_COMMON_OUT ]; then
+        if [ -d ${common_out_dir} ] && [ ! -L ${common_out_dir} ]; then
+            mv ${common_out_dir} ${common_out_dir}-${target_device}
+            ln -s ${common_out_dir}-${target_device} ${common_out_dir}
+        else
+            [ -L ${common_out_dir} ] && rm ${common_out_dir}
+            mkdir -p ${common_out_dir}-${target_device}
+            ln -s ${common_out_dir}-${target_device} ${common_out_dir}
+        fi
+    else
+        [ -L ${common_out_dir} ] && rm ${common_out_dir}
+        mkdir -p ${common_out_dir}
+    fi
+}
+
 # Force JAVA_HOME to point to java 1.7/1.8 if it isn't already set.
 function set_java_home() {
     # Clear the existing JAVA_HOME value if we set it ourselves, so that