erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
| 3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | # |
| 5 | # This code is free software; you can redistribute it and/or modify it |
| 6 | # under the terms of the GNU General Public License version 2 only, as |
| 7 | # published by the Free Software Foundation. Oracle designates this |
| 8 | # particular file as subject to the "Classpath" exception as provided |
| 9 | # by Oracle in the LICENSE file that accompanied this code. |
| 10 | # |
| 11 | # This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | # version 2 for more details (a copy is included in the LICENSE file that |
| 15 | # accompanied this code). |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License version |
| 18 | # 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | # |
| 21 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 22 | # or visit www.oracle.com if you need additional information or have any |
| 23 | # questions. |
| 24 | # |
| 25 | |
| 26 | GENSRC_JOBJC := |
| 27 | |
| 28 | JOBJC_FRAMEWORKS := Foundation CoreFoundation AppKit |
| 29 | FRAMEWORKS_DIR := /System/Library/Frameworks |
| 30 | GBM := /usr/bin/gen_bridge_metadata |
| 31 | |
| 32 | JOBJC_SRC := $(JDK_TOPDIR)/src/macosx/native/jobjc |
| 33 | JOBJC_TMP := $(JDK_OUTPUTDIR)/gensrc_jobjc |
| 34 | JOBJC_DST := $(JDK_OUTPUTDIR)/gensrc_jobjc/src |
| 35 | |
| 36 | # |
| 37 | # Build generator |
| 38 | # |
| 39 | $(eval $(call SetupJavaCompilation,BUILD_JOBJC_PRIMITIVE_CODER,\ |
| 40 | SETUP:=GENERATE_OLDBYTECODE,\ |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 41 | DISABLE_SJAVAC:=true,\ |
erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 42 | INCLUDES:=core/java \ |
| 43 | com/apple,\ |
erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 44 | SRC:=$(JOBJC_SRC)/src \ |
| 45 | $(JOBJC_SRC)/src/generator/java, \ |
| 46 | BIN:=$(JOBJC_TMP)/bin)) |
| 47 | |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 48 | GENSRC_JOBJC += $(BUILD_JOBJC_PRIMITIVE_CODER) |
erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 49 | |
| 50 | # |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 51 | # Generate bridge support for select frameworks |
erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 52 | # |
| 53 | BRIDGESUPPORT := $(addprefix $(JOBJC_TMP)/bridge/,$(addsuffix Full.bridgesupport,$(JOBJC_FRAMEWORKS))) |
| 54 | |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 55 | # |
| 56 | # Define macro for rules to create bridge support |
| 57 | # Not sure why, but if the system has this framework bridge support, |
| 58 | # we appear to copy that, otherwise we run GBM which can be very slow. |
| 59 | # |
| 60 | define CreateBridgeSupport # Framework |
| 61 | $(RM) $@ $@.tmp |
| 62 | $(MKDIR) -p $(@D) |
| 63 | if [ -f $(FRAMEWORKS_DIR)/$1.framework/Resources/BridgeSupport/$(@F) ]; then \ |
| 64 | $(CP) $(FRAMEWORKS_DIR)/$1.framework/Resources/BridgeSupport/$(@F) $@.tmp ;\ |
| 65 | else \ |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 66 | $(GBM) $(LOG_INFO) -F complete --framework $1 -o $@.tmp ; \ |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 67 | fi |
| 68 | $(MV) $@.tmp $@ |
| 69 | endef |
erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 70 | |
| 71 | # |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 72 | # Currently 3 frameworks, avoid pattern rule due to the names being conflicting |
erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 73 | # |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 74 | $(JOBJC_TMP)/bridge/FoundationFull.bridgesupport : \ |
| 75 | $(wildcard $(FRAMEWORKS_DIR)/Foundation.framework/Headers/*.h) |
| 76 | $(call CreateBridgeSupport,Foundation) |
| 77 | $(JOBJC_TMP)/bridge/CoreFoundationFull.bridgesupport : \ |
| 78 | $(wildcard $(FRAMEWORKS_DIR)/CoreFoundation.framework/Headers/*.h) |
| 79 | $(call CreateBridgeSupport,CoreFoundation) |
| 80 | $(JOBJC_TMP)/bridge/AppKitFull.bridgesupport : \ |
| 81 | $(wildcard $(FRAMEWORKS_DIR)/AppKit.framework/Headers/*.h) |
| 82 | $(call CreateBridgeSupport,AppKit) |
| 83 | |
| 84 | # |
| 85 | # Find Xbootclasspath, for some reason, this involves firing up Java just |
| 86 | # so we can get the boot classpath, so we can remove anything in that |
| 87 | # classpath that ends with "JObjC.jar", and emit the new bootclasspath. |
| 88 | # |
| 89 | $(JOBJC_TMP)/_the.generator_bootclasspath : $(BUILD_JOBJC_PRIMITIVE_CODER) |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 90 | $(ECHO) Generating jobjc framework bridge |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 91 | $(RM) $@ |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 92 | $(JAVA) $(LOG_INFO) -cp $(JOBJC_TMP)/bin com.apple.internal.jobjc.generator.BootClassPathMinus JObjC.jar > $@.tmp |
erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 93 | $(MV) $@.tmp $@ |
| 94 | |
erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 95 | # |
| 96 | # Run generator |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 97 | # Now we use bootclasspath to run java again, with the bridge support to |
| 98 | # generate more source. |
erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 99 | # |
erikj | 4f66f2d | 2012-11-03 16:27:01 -0700 | [diff] [blame] | 100 | $(JOBJC_TMP)/_the.generator : $(JOBJC_TMP)/_the.generator_bootclasspath $(BRIDGESUPPORT) |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 101 | $(RM) $@ |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 102 | $(JAVA) $(LOG_INFO) -d64 -Xbootclasspath:`$(CAT) $(JOBJC_TMP)/_the.generator_bootclasspath` -cp $(JOBJC_TMP)/bin -ea com.apple.internal.jobjc.generator.Generator dst=$(JOBJC_DST) frameworks=$(JOBJC_TMP)/bridge |
erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 103 | $(TOUCH) $@ |
| 104 | |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 105 | # The generator delets all files in the target dir so it has to work in its |
| 106 | # own dir and have the files copied over to gensrc aftewards. |
| 107 | $(JDK_OUTPUTDIR)/gensrc/_the.jobjc.files : $(JOBJC_TMP)/_the.generator |
| 108 | $(MKDIR) -p $(@D) |
| 109 | $(CP) -rp $(JOBJC_DST)/* $(@D) |
| 110 | $(TOUCH) $@ |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 111 | |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 112 | GENSRC_JOBJC += $(JDK_OUTPUTDIR)/gensrc/_the.jobjc.files |