OSDN Git Service

Support build targets with no installable apps/packages
authorGaurav Shah <gauravsh@google.com>
Sun, 23 Aug 2015 16:40:05 +0000 (09:40 -0700)
committerGaurav Shah <gauravsh@google.com>
Mon, 2 Nov 2015 22:18:30 +0000 (14:18 -0800)
Specifically, do not error out if no installable apps are found.

- When creating an archive of all the apps, and if no apps exist
for the target, generate an empty archive file.
- If building for a target with no installable jar(s) or apk(s),
generate an empty package stats file.

The former is just an output artifact. The latter is used
by the upload_pkg_stats.py script which correctly handles
an empty input file.

BUG: 23421592

Change-Id: I48db9f9e1f61914d8fd938130e09b41849685450

core/Makefile

index 94585c6..649a0aa 100644 (file)
@@ -314,7 +314,12 @@ $(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT)
        @echo Package stats: $@
        @mkdir -p $(dir $@)
        $(hide) rm -f $@
+ifeq ($(PACKAGES_TO_STAT),)
+# Create empty package stats file if target builds no jar(s) or apk(s).
+       $(hide) touch $@
+else
        $(hide) build/tools/dump-package-stats $^ > $@
+endif
 
 .PHONY: package-stats
 package-stats: $(PACKAGE_STATS_FILE)
@@ -1736,8 +1741,13 @@ $(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE)
        @echo "Package apps: $@"
        $(hide) rm -rf $@
        $(hide) mkdir -p $(dir $@)
-       $(hide) zip -qj $@ $(TARGET_OUT_APPS)/*/*.apk $(TARGET_OUT_APPS_PRIVILEGED)/*/*.apk
-
+       $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \
+       if [ -z "$$apps_to_zip" ]; then \
+               echo "No apps to zip up. Generating empty apps archive." ; \
+               a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \
+       else \
+               zip -qj $@ $$apps_to_zip; \
+       fi
 
 #------------------------------------------------------------------
 # A zip of emma code coverage meta files. Generated for fully emma