-
Notifications
You must be signed in to change notification settings - Fork 959
/
java.mk
117 lines (95 loc) · 3.58 KB
/
java.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Copyright 2011 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Makefile for building the iOS emulation library.
#
# Author: Tom Ball
.SUFFIXES:
.PHONY: clean
include environment.mk
include jre_sources.mk
JAVA_SOURCES_MANIFEST = $(BUILD_DIR)/java_sources.mf
ALL_JAVA_SOURCES = $(JAVA_SOURCES) $(NO_TRANSLATE_JAVA_SOURCES)
ANNOTATIONS_JAR = $(DIST_JAR_DIR)/j2objc_annotations.jar
clean:
@rm -f $(EMULATION_JAR_DIST) $(EMULATION_SRC_JAR_DIST)
jars_dist: emul_jar_dist emul_src_jar_dist
ifndef JAVA_8
jars_dist: emul_module_dist
endif
emul_jar_dist: $(EMULATION_JAR_DIST)
@:
emul_module_dist: $(EMULATION_MODULE_DIST)
@:
emul_src_jar_dist: $(EMULATION_SRC_JAR_DIST)
@:
$(EMULATION_JAR_DIST): $(EMULATION_JAR)
@mkdir -p $(@D)
@install -m 0644 $< $@
$(EMULATION_MODULE_DIST): $(EMULATION_MODULE)
@mkdir -p $(@D)
@cp -r $< $@
$(EMULATION_SRC_JAR_DIST): $(EMULATION_SRC_JAR)
@mkdir -p $(@D)
@install -m 0644 $< $@
# The following test returns true on Linux or with GNU tools installed,
# otherwise false on macOS which uses the BSD version.
ifeq ($(shell mktemp --version >/dev/null 2>&1 && echo GNU || echo BSD), GNU)
MKTEMP_CMD = mktemp -d --tmpdir j2objc-jre_emul.XXXXXX
else
MKTEMP_CMD = mktemp -d -t j2objc-jre_emul
endif
$(EMULATION_JAR): $(ALL_JAVA_SOURCES)
@mkdir -p $(@D)
@echo "building jre_emul.jar"
@set -e; stage_dir=`${MKTEMP_CMD}`; \
../scripts/javac_no_deprecated_warnings.sh $(JAVAC) \
-classpath $(ANNOTATIONS_JAR) \
-d $$stage_dir -encoding UTF-8 -source 1.8 -target 1.8 -nowarn $^; \
jar cf $(EMULATION_JAR) -C $$stage_dir .; \
rm -rf $$stage_dir
$(EMULATION_MODULE): $(EMULATION_JAR)
@echo "building jre_emul_module"
@rm -rf $(EMULATION_MODULE)
@mkdir $(BUILD_DIR)/jre_emul
@cd $(BUILD_DIR)/jre_emul; jar xf $(EMULATION_JAR)
@../scripts/gen_module_info.py --name java.base --root $(BUILD_DIR)/jre_emul \
--output $(BUILD_DIR)/module-info.java
@$(JAVAC) --system=none --patch-module=java.base=$(EMULATION_JAR) \
-d $(BUILD_DIR)/jre_emul $(BUILD_DIR)/module-info.java
@mkdir $(BUILD_DIR)/jmod
@$(JAVA_HOME)/bin/jmod create --module-version $(JAVA_VERSION) \
--target-platform osx --class-path $(BUILD_DIR)/jre_emul \
$(BUILD_DIR)/jmod/jre_emul.jmod
@$(JAVA_HOME)/bin/jlink --module-path $(BUILD_DIR)/jmod \
--add-modules java.base --output $(EMULATION_MODULE)
@cp $(JAVA_HOME)/lib/jrt-fs.jar $(EMULATION_MODULE)/lib/
@rm -rf $(BUILD_DIR)/jre_emul
@rm -rf $(BUILD_DIR)/jmod
@rm $(BUILD_DIR)/module-info.*
$(EMULATION_SRC_JAR): $(ALL_JAVA_SOURCES)
@mkdir -p $(@D)
@echo "building jre_emul-src.jar"
@../scripts/gen_java_source_jar.py -sourcepath $(JRE_SRC) \
-o $(EMULATION_SRC_JAR) $^
$(JAVA_SOURCES_MANIFEST): $(ALL_JAVA_SOURCES)
@mkdir -p $(@D)
@echo "building $$(basename $@)"
@if [ -e $@ ]; then rm $@; fi
@for i in $^; do echo $(CURDIR)/$$i >> $@; done
java_sources_manifest: $(JAVA_SOURCES_MANIFEST)
@:
find_cycles: cycle_finder_dist $(JAVA_SOURCES_MANIFEST)
$(DIST_DIR)/cycle_finder --patch-module java.base=$(JRE_SRC) \
-w cycle_whitelist.txt -s $(JAVA_SOURCES_MANIFEST) \
-external-annotation-file $(J2OBJC_ANNOTATIONS)