Home | History | Annotate | Download | only in adtproductbuild
      1 # Copyright 2012 The Android Open Source Project
      2 #
      3 # Makefile rules to build the ADT Eclipse IDE.
      4 # This is invoked from sdk/eclipse/scripts/build_server.sh using
      5 # something like "make PRODUCT-sdk-adt_eclipse_ide".
      6 #
      7 # Expected env vars:
      8 # ADT_IDE_DEST_DIR:  existing directory where to copy the IDE zip files.
      9 # ADT_IDE_QUALIFIER: a root qualifier to incorporate before the build timestamp in plugins.
     10 # ADT_IDE_ZIP_QUALIFIER: either a date or build number to incorporate in the zip names.
     11 
     12 # Expose the ADT Eclipse IDE build only for the SDK when building adt_eclipse_ide
     13 ifneq (,$(is_sdk_build)$(filter sdk sdk_x86 sdk_mips,$(TARGET_PRODUCT)))
     14 ifneq (,$(filter adt_eclipse_ide,$(MAKECMDGOALS)))
     15 
     16 LOCAL_PATH := $(call my-dir)
     17 include $(CLEAR_VARS)
     18 
     19 LOCAL_MODULE := adt_eclipse_ide
     20 LOCAL_MODULE_CLASS := EXECUTABLES
     21 LOCAL_MODULE_TAGS := optional
     22 LOCAL_IS_HOST_MODULE := true
     23 include $(BUILD_SYSTEM)/base_rules.mk
     24 
     25 ADT_IDE_MODULE_DEPS := $(TOPDIR)sdk/adtproductbuild/$(LOCAL_MODULE)
     26 
     27 ADT_IDE_BUILD_LOG    := $(TOPDIR)out/host/eclipse/adtproduct/adtproduct.log
     28 ADT_IDE_ARTIFACT_DIR := $(TOPDIR)out/host/eclipse/adtproduct/pbuild/I.RcpBuild
     29 ADT_IDE_RELEASE_DIR  := $(TOPDIR)out/host/eclipse/adtproduct/release
     30 
     31 ADT_IDE_JAVA_LIBS := $(shell $(TOPDIR)sdk/eclipse/scripts/create_all_symlinks.sh -d)
     32 ADT_IDE_JAVA_DEPS := $(foreach m,$(ADT_IDE_JAVA_LIBS),$(HOST_OUT_JAVA_LIBRARIES)/$(m).jar)
     33 
     34 ADT_IDE_JAVA_TARGET := $(ADT_IDE_RELEASE_DIR)/adt_eclipse_ide_java_build
     35 ADT_VERSION := $(shell grep Bundle-Version $(TOPDIR)sdk/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF | sed 's/.*: \([0-9]\+.[0-9]\+.[0-9]\+\).*/\1/')
     36 
     37 # Common not-quite-phony rule to perform the eclipse build only once
     38 # This invokes the java builder on eclipse. It generates multiple
     39 # zipped versions (one per OS, all built at the same time)
     40 # of the ide as specified in the build.properties file.
     41 $(ADT_IDE_JAVA_TARGET) : $(TOPDIR)sdk/adtproductbuild/adt_eclipse_ide \
     42 			 $(TOPDIR)sdk/adtproductbuild/build.xml \
     43 			 $(TOPDIR)sdk/adtproductbuild/build.properties \
     44 			 $(ADT_IDE_JAVA_DEPS)
     45 	@if [[ ! -d $(TOPDIR)prebuilts/eclipse-build-deps ]]; then \
     46 		echo "*** [adt_eclipse_ide] ERROR: Missing prebuilts/eclipse-build-deps directory. Make sure to run 'repo init -g all;repo sync' first."; \
     47 		exit 1; \
     48 	fi
     49 	$(hide)rm -rf $(TOPDIR)out/host/eclipse/adtproduct/fbuild/plugins
     50 	$(hide)rm -rf $(TOPDIR)out/host/eclipse/adtproduct/pbuild/plugins
     51 	$(hide)mkdir -p $(dir $@)
     52 	$(hide) $(TOPDIR)sdk/eclipse/scripts/create_all_symlinks.sh -c
     53 	$(hide)cd $(TOPDIR)sdk/adtproductbuild && \
     54 		rm -f ../../$(ADT_IDE_BUILD_LOG) && mkdir -p ../../$(dir $(ADT_IDE_BUILD_LOG)) && \
     55 		( java -jar ../../external/eclipse-basebuilder/basebuilder-3.6.2/org.eclipse.releng.basebuilder/plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar \
     56 			org.eclipse.equinox.launcher.Main \
     57 			-application org.eclipse.ant.core.antRunner \
     58 			-configuration ../../out/host/eclipse/adtproduct/ant-configuration \
     59 			-data ../../out/host/eclipse/adtproduct/ant-workspace \
     60 			-DADT_IDE_QUALIFIER=$(ADT_IDE_QUALIFIER) \
     61 			2>&1 && \
     62 		  mv -f ../../$(ADT_IDE_BUILD_LOG) ../../$(ADT_IDE_BUILD_LOG).1 ) \
     63 		| tee ../../$(ADT_IDE_BUILD_LOG) \
     64 		| sed 's/^/IDE: /'; \
     65 		if [[ -f ../../$(ADT_IDE_BUILD_LOG) ]]; then \
     66 		  echo "ADT IDE build failed. Full log:" ; \
     67 		  cat ../../$(ADT_IDE_BUILD_LOG) ; \
     68 		  exit 1 ; \
     69 		fi
     70 	$(hide)$(ACP) -fp $(V) $(TOPDIR)sdk/adtproductbuild/adt_eclipse_ide $@
     71 
     72 # Defines the zip filename generated for an OS specific android IDE.
     73 define adt-ide-zip
     74 $(ADT_IDE_RELEASE_DIR)/android-ide-$(ADT_IDE_ZIP_QUALIFIER)-$(1).$(2).zip
     75 endef
     76 
     77 # Defines the rule needed to make one of the OS specific android IDE.
     78 # If ADT_IDE_DEST_DIR it also defines the rule to produce the final dest zip.
     79 # $1 = the platform (linux|macosx|win32).(gtk|cocoa|win32)
     80 # $2 = the architecture (x86 or x8_64).
     81 # $3 = the src zip (from out/host/eclipse/artifacts/RcpBuild-...)
     82 # $4 = the destination directory (where the unpacked eclipse is created)
     83 # $5 = the destination zip with the zipped eclipse ide.
     84 # This rule is in used primarily to post process the .zip file that is
     85 # generated by the Eclipse PDE build process. Ideally, we'd fix things in the PDE build
     86 # itself, but since we don't know how we do this. These changes include:
     87 # - Changing the product definition in eclipse.ini from org.eclipse.platform to ..adt.package.product
     88 # - Setting eclipse.buildId in eclipse.ini
     89 # - Setting eclipse.buildId in about.mappings
     90 # - Changing the splash screen location from platform to adt.package in config.ini
     91 # - Mac only: The PDE build produces eclipse.app and Eclipse.app folders. This is probably a bug
     92 #   in the PDE build since the filesystems on Mac are case insensitive. In any case, eclipse.ini is
     93 #   present only in eclipse.app, so we copy it over to Eclipse.app and remove the eclipse.app folder.
     94 #   In addition, the root folder has a symlink to Eclipse.app/Contents/MacOS/eclipse. Since .zip files
     95 #   don't support symlinks, this just gets copied over. We don't really need this file as users just
     96 #   open the Eclipse.app application, so we just remove it. Lastly, the .icns file is manually copied
     97 #   over and specified in eclipse.ini, only because including it directly in the product definition
     98 #   causes the build on our servers to fail.
     99 define mk-adt-ide-2
    100 $(5): $(ADT_IDE_JAVA_TARGET)
    101 	$(hide) \
    102 	rm -rf $(V) $(4) && \
    103 	rm  -f $(V) $(5) && \
    104 	mkdir -p $(4) && \
    105 	unzip -q $(3) -d $(4) && \
    106 	if [[ "$(1)" == "macosx.cocoa" ]]; then \
    107 	  mv $(4)/eclipse/eclipse.app/Contents/MacOS/eclipse.ini $(4)/eclipse/Eclipse.app/Contents/MacOS && \
    108 	  rm -rf $(4)/eclipse/eclipse.app && \
    109 	  rm -r  $(4)/eclipse/eclipse && \
    110 	  chmod +x $(4)/eclipse/Eclipse.app/Contents/MacOS/eclipse && \
    111 	  cp $(4)/eclipse/plugins/com.android.ide.eclipse.adt.package*/icons/adt.icns \
    112 	     $(4)/eclipse/Eclipse.app/Contents/Resources && \
    113 	  sed -i -e 's/Eclipse.icns/adt.icns/g' $(4)/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini && \
    114 	  sed -i -e 's/Eclipse.icns/adt.icns/g' $(4)/eclipse/Eclipse.app/Contents/Info.plist ; \
    115 	fi && \
    116 	sed -i -e 's/org.eclipse.platform/com.android.ide.eclipse.adt.package.product/g' \
    117 	  $(4)/eclipse/$(if $(filter macosx.cocoa,$(1)),Eclipse.app/Contents/MacOS/)eclipse.ini && \
    118 	echo "-Declipse.buildId=v$(ADT_VERSION)-$(ADT_IDE_ZIP_QUALIFIER)" >> \
    119 	  $(4)/eclipse/$(if $(filter macosx.cocoa,$(1)),Eclipse.app/Contents/MacOS/)eclipse.ini && \
    120 	sed -i -e "s/buildId/v$(ADT_VERSION)-$(ADT_IDE_ZIP_QUALIFIER)/g" \
    121 	  $(4)/eclipse/plugins/com.android.ide.eclipse.adt.package_*/about.mappings && \
    122 	sed -i -e 's/org.eclipse.platform.ide/com.android.ide.eclipse.adt.package.product/g' \
    123 	       -e 's/org.eclipse.platform/com.android.ide.eclipse.adt.package/g' \
    124 	  $(4)/eclipse/configuration/config.ini && \
    125 	echo "-XX:MaxPermSize=512M" >> \
    126 	  $(4)/eclipse/$(if $(filter macosx.cocoa,$(1)),Eclipse.app/Contents/MacOS/)eclipse.ini
    127 	$(hide)cd $(4) && zip -9rq ../$(notdir $(5)) eclipse
    128 ifneq (,$(ADT_IDE_DEST_DIR))
    129 $(ADT_IDE_DEST_DIR)/$(notdir $(5)): $(5)
    130 	@mkdir -p $(ADT_IDE_DEST_DIR)
    131 	$(hide)cp $(V) $(5) $(ADT_IDE_DEST_DIR)/$(notdir $(5))
    132 	@echo "ADT IDE copied to $(ADT_IDE_DEST_DIR)/$(notdir $(5))"
    133 else
    134 	@echo "ADT IDE available at $(5)"
    135 endif
    136 endef
    137 
    138 # Defines the rule needed to make one of the OS specific android IDE.
    139 # This is just a convenience wrapper that calls mk-adt-ide-2 and presets
    140 # the source and destination zip paths.
    141 # It also sets the dependencies we need to produce the final dest zip.
    142 # $1 = the platform (linux|macosx|win32).(gtk|cocoa|win32)
    143 # $2 = the architecture (x86 or x8_64).
    144 define mk-adt-ide
    145 $(call mk-adt-ide-2,$(1),$(2), \
    146     $(ADT_IDE_ARTIFACT_DIR)/RcpBuild-$(1).$(2).zip, \
    147     $(ADT_IDE_RELEASE_DIR)/android-ide-$(1).$(2), \
    148     $(call adt-ide-zip,$(1),$(2)))
    149 ADT_IDE_MODULE_DEPS += $(call adt-ide-zip,$(1),$(2))
    150 ifneq (,$(ADT_IDE_DEST_DIR))
    151 ADT_IDE_MODULE_DEPS += $(ADT_IDE_DEST_DIR)/$(notdir $(call adt-ide-zip,$(1),$(2)))
    152 endif
    153 endef
    154 
    155 $(eval $(call mk-adt-ide,linux.gtk,x86))
    156 $(eval $(call mk-adt-ide,linux.gtk,x86_64))
    157 $(eval $(call mk-adt-ide,macosx.cocoa,x86_64))
    158 $(eval $(call mk-adt-ide,win32.win32,x86))
    159 $(eval $(call mk-adt-ide,win32.win32,x86_64))
    160 
    161 # This rule triggers the build of the 3 ide zip files.
    162 # The adt_eclipse_ide script is currently a platceholder used
    163 # to detect when the build was completed. We may use it later
    164 # as a launch script.
    165 $(LOCAL_BUILT_MODULE) : $(ADT_IDE_MODULE_DEPS)
    166 	@mkdir -p $(dir $@)
    167 	$(hide)$(ACP) -fp $(V) $(TOPDIR)sdk/adtproductbuild/adt_eclipse_ide $@
    168 	@echo "Packing of ADT IDE done"
    169 
    170 endif
    171 endif
    172