forked from google/j2objc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
3,104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# 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 j2objc. It's purpose is as a subproject in an Xcode | ||
# project. | ||
# | ||
# Author: Tom Ball | ||
|
||
SUFFIXES: | ||
.PHONY: translator dist test | ||
|
||
default: dist | ||
|
||
# Force test targets to be run sequentially to avoid interspersed output. | ||
ifeq "$(findstring test,$(MAKECMDGOALS))" "test" | ||
.NOTPARALLEL: | ||
endif | ||
|
||
J2OBJC_ROOT = . | ||
|
||
include make/common.mk | ||
include make/j2objc_deps.mk | ||
|
||
MAN_DIR = doc/man | ||
MAN_PAGES = $(MAN_DIR)/j2objc.1 $(MAN_DIR)/j2objcc.1 | ||
|
||
install-man-pages: $(MAN_PAGES) | ||
@mkdir -p $(DIST_DIR)/man/man1 | ||
@install -C -m 0644 $? $(DIST_DIR)/man/man1 | ||
|
||
dist: print_environment translator_dist jre_emul_dist junit_dist jsr305_dist \ | ||
javax_inject_dist guava_dist mockito_dist cycle_finder_dist install-man-pages | ||
|
||
protobuf_dist: protobuf_compiler_dist protobuf_runtime_dist | ||
|
||
|
||
all_dist: dist protobuf_dist | ||
|
||
clean: | ||
@rm -rf $(DIST_DIR) | ||
@cd annotations && $(MAKE) clean | ||
@cd java_deps && $(MAKE) clean | ||
@cd translator && $(MAKE) clean | ||
@cd jre_emul && $(MAKE) clean | ||
@cd junit && $(MAKE) clean | ||
@cd jsr305 && $(MAKE) clean | ||
@cd inject/javax_inject && $(MAKE) clean | ||
@cd guava && $(MAKE) clean | ||
@cd testing/mockito && $(MAKE) clean | ||
@cd cycle_finder && $(MAKE) clean | ||
@cd protobuf/runtime && $(MAKE) clean | ||
@cd protobuf/compiler && $(MAKE) clean | ||
@cd protobuf/tests && $(MAKE) clean | ||
|
||
test_translator: annotations_dist java_deps_dist | ||
@cd translator && $(MAKE) test | ||
|
||
test_jre_emul: jre_emul_dist junit_dist | ||
@cd jre_emul && $(MAKE) -f tests.mk test | ||
|
||
test_jre_cycles: cycle_finder_dist | ||
@cd jre_emul && $(MAKE) find_cycles | ||
|
||
test_junit_cycles: cycle_finder_dist | ||
@cd junit && $(MAKE) find_cycles | ||
|
||
test_guava_cycles: cycle_finder_dist jre_emul_java_manifest | ||
@cd guava && $(MAKE) find_cycles | ||
|
||
test_cycle_finder: cycle_finder_dist | ||
@cd cycle_finder && $(MAKE) test | ||
|
||
test: test_translator test_jre_emul \ | ||
test_cycle_finder test_jre_cycles test_guava_cycles test_junit_cycles | ||
|
||
test_protobuf: junit_dist protobuf_compiler_dist protobuf_runtime_dist | ||
@cd protobuf/tests && $(MAKE) test | ||
|
||
|
||
test_all: test test_protobuf | ||
|
||
print_environment: | ||
@echo Locale: $${LANG} | ||
@echo `uname -a` | ||
@echo `xcodebuild -version` | ||
@echo `xcrun cc -v` | ||
@echo Environment: | ||
@env | grep -v '^_' | sort | ||
@echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# 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. | ||
|
||
# Builds the j2objc annotations as a .jar file. | ||
# | ||
# Author: Tom Ball, Keith Stanger | ||
|
||
SUFFIXES: | ||
|
||
J2OBJC_ROOT = .. | ||
|
||
include ../make/common.mk | ||
include classes.mk | ||
|
||
JAR_NAME = j2objc_annotations.jar | ||
JAR = $(BUILD_DIR)/$(JAR_NAME) | ||
DIST_JAR = $(DIST_JAR_DIR)/$(JAR_NAME) | ||
|
||
CLASSES_DIR = $(BUILD_DIR)/classes | ||
JAVA_SOURCE_DIR = src/main/java | ||
|
||
SOURCE_JAVA_FULL = $(ANNOTATION_SOURCE_JAVA:%=$(JAVA_SOURCE_DIR)/%) | ||
|
||
$(BUILD_DIR) $(CLASSES_DIR) $(DIST_JAR_DIR): | ||
@mkdir -p $@ | ||
|
||
$(JAR): $(SOURCE_JAVA_FULL) | $(BUILD_DIR) $(CLASSES_DIR) | ||
@echo Building j2objc annotations | ||
@javac -d $(CLASSES_DIR) -source 1.6 -target 1.6 -nowarn $^ | ||
@jar cf $(JAR) -C $(CLASSES_DIR) . | ||
|
||
$(DIST_JAR): $(JAR) | $(DIST_JAR_DIR) | ||
@install -m 0644 $< $@ | ||
|
||
dist: $(DIST_JAR) | ||
@: | ||
|
||
clean: | ||
@rm -rf $(BUILD_DIR) $(DIST_JAR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# 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 cycle_finder, a tool for finding reference cycles in a | ||
# Java program. Mainly useful when translating to a language without garbage | ||
# collection. | ||
# | ||
# Author: Keith Stanger | ||
|
||
SUFFIXES: | ||
|
||
SOURCE_DIR = src/main | ||
JAVA_SOURCE_DIR = $(SOURCE_DIR)/java | ||
RESOURCE_DIR = $(SOURCE_DIR)/resources | ||
J2OBJC_ROOT = .. | ||
|
||
include ../make/common.mk | ||
include ../make/j2objc_deps.mk | ||
include ../java_deps/jars.mk | ||
|
||
BUILD_DIR = build_result | ||
CLASS_DIR = $(BUILD_DIR)/classes | ||
TEST_CLASS_DIR = $(BUILD_DIR)/test | ||
|
||
JAVA_SOURCES = \ | ||
com/google/devtools/cyclefinder/CycleFinder.java \ | ||
com/google/devtools/cyclefinder/Edge.java \ | ||
com/google/devtools/cyclefinder/NameList.java \ | ||
com/google/devtools/cyclefinder/Options.java \ | ||
com/google/devtools/cyclefinder/ReferenceGraph.java \ | ||
com/google/devtools/cyclefinder/Tarjans.java \ | ||
com/google/devtools/cyclefinder/TypeCollector.java | ||
|
||
RESOURCES = \ | ||
com/google/devtools/cyclefinder/CycleFinder.properties | ||
|
||
JAR_DEPS = $(ECLIPSE_JARS) $(GUAVA_JAR) j2objc.jar j2objc_annotations.jar | ||
JAR_DEPS_DIST = $(JAR_DEPS:%=$(DIST_JAR_DIR)/%) | ||
JAR_DEPS_PATH = $(subst $(eval) ,:,$(strip $(JAR_DEPS_DIST))) | ||
JUNIT_JAR_DIST = $(DIST_JAR_DIR)/$(JUNIT_JAR) | ||
|
||
MAIN_CLASS = com.google.devtools.cyclefinder.CycleFinder | ||
MANIFEST = $(BUILD_DIR)/manifest.mf | ||
JAR = $(BUILD_DIR)/cycle_finder.jar | ||
JAR_DIST = $(DIST_JAR_DIR)/cycle_finder.jar | ||
|
||
JAVA_SOURCES_FULL = $(JAVA_SOURCES:%=$(JAVA_SOURCE_DIR)/%) | ||
RESOURCE_FILES = $(RESOURCES:%=$(CLASS_DIR)/%) | ||
|
||
TEST_CLASSPATH = $(JAR):$(JUNIT_JAR_DIST):$(JAR_DEPS_PATH):$(TEST_CLASS_DIR) | ||
|
||
ALL_LIBS = $(JAR) $(ECLIPSE_LIBS) | ||
|
||
default: $(JAR) | ||
@: | ||
|
||
clean: | ||
@rm -rf $(BUILD_DIR) $(JAR_DIST) $(DIST_DIR)/cycle_finder | ||
|
||
$(JAR): $(MANIFEST) $(RESOURCE_FILES) $(JAVA_SOURCES_FULL) \ | ||
| $(CLASS_DIR) java_deps_dist annotations_dist translator | ||
@javac -Xlint:unchecked -sourcepath $(JAVA_SOURCE_DIR) -classpath $(JAR_DEPS_PATH) \ | ||
-d $(CLASS_DIR) -source 1.6 -target 1.6 -nowarn $(JAVA_SOURCES:%=$(JAVA_SOURCE_DIR)/%) | ||
@jar cfm $@ $(MANIFEST) -C $(CLASS_DIR) . | ||
|
||
# Format manifest classpath with each jar on a separate line, to avoid | ||
# maximum line length of 72 bytes in UTF-8 encoding. | ||
# http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html | ||
$(MANIFEST): | $(BUILD_DIR) | ||
@echo creating $@ | ||
@echo "Manifest-Version: 1.0" > $@ | ||
@echo "Main-Class:" $(MAIN_CLASS) >> $@ | ||
@/bin/echo -n "Class-Path:" >> $@ | ||
@for lib in $(JAR_DEPS); do echo " " $$lib; done >> $@ | ||
|
||
$(CLASS_DIR)/%: $(RESOURCE_DIR)/% | ||
@mkdir -p $(@D) | ||
@cp -f $< $@ | ||
|
||
DIRS = $(BUILD_DIR) $(CLASS_DIR) $(TEST_CLASS_DIR) $(DIST_DIR) $(DIST_JAR_DIR) | ||
|
||
$(sort $(DIRS)): | ||
@mkdir -p $@ | ||
|
||
$(DIST_DIR)/cycle_finder: $(SOURCE_DIR)/bin/cycle_finder.sh | $(DIST_DIR) | ||
install $< $@ | ||
|
||
$(JAR_DIST): $(JAR) | $(DIST_JAR_DIR) | ||
install -m 0644 $< $@ | ||
|
||
dist: $(JAR_DIST) $(DIST_DIR)/cycle_finder | ||
@: | ||
|
||
test: compile-tests | ||
java -classpath $(TEST_CLASSPATH) junit.textui.TestRunner \ | ||
com.google.devtools.cyclefinder.CycleFinderTest | ||
|
||
compile-tests: $(JAR) | $(TEST_CLASS_DIR) | ||
javac -sourcepath src/test/java -classpath $(TEST_CLASSPATH) -d $(TEST_CLASS_DIR) \ | ||
src/test/java/com/google/devtools/cyclefinder/CycleFinderTest.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# 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. | ||
|
||
# Builds a J2ObjC translated Guava library. | ||
# | ||
# Author: Keith Stanger | ||
# TODO(kstanger): Build a fat library to distribute. | ||
|
||
SUFFIXES: | ||
|
||
default: dist | ||
|
||
include environment.mk | ||
|
||
JAVA_SOURCES := \ | ||
$(filter-out $(SOURCES_TO_EXCLUDE:%=$(SRC_DIR)/%),$(shell find $(SRC_DIR) -name *.java)) | ||
|
||
JAVA_SOURCES_MANIFEST = $(BUILD_DIR)/java_sources.mf | ||
OBJC_SOURCES_MANIFEST = $(BUILD_DIR)/objc_sources.mf | ||
|
||
CLASSPATH = $(DIST_JAR_DIR)/$(JSR305_JAR):$(DIST_JAR_DIR)/j2objc_annotations.jar | ||
SOURCEPATH = $(SRC_DIR) | ||
|
||
INCLUDE_DIRS = $(GEN_OBJC_DIR) | ||
|
||
J2OBJCC = $(ARCH_BIN_DIR)/j2objcc -c -fobjc-abi-version=2 -fobjc-legacy-dispatch \ | ||
$(INCLUDE_DIRS:%=-I%) | ||
|
||
TRANSLATE_JAVA_FULL = $(JAVA_SOURCES) | ||
TRANSLATE_JAVA_RELATIVE = $(JAVA_SOURCES:$(SRC_DIR)/%=%) | ||
TRANSLATE_ARGS = --segmented-headers --extract-unsequenced --batch-translate-max=300 \ | ||
-cp $(CLASSPATH) -sourcepath $(SOURCEPATH) -encoding UTF-8 -J-Xmx2G \ | ||
--hide-private-members --final-methods-as-functions -q | ||
include ../make/translate.mk | ||
|
||
FAT_LIB_NAME = guava | ||
FAT_LIB_SOURCES_RELATIVE = $(TRANSLATE_SOURCES:$(GEN_OBJC_DIR)/%=%) | ||
FAT_LIB_SOURCE_DIRS = $(GEN_OBJC_DIR) | ||
FAT_LIB_COMPILE = $(J2OBJCC) | ||
include ../make/fat_lib.mk | ||
|
||
fat_lib_dependencies: jre_emul_dist jsr305_dist | ||
|
||
DIST_LIBRARY = $(ARCH_LIB_DIR)/libguava.a | ||
JAR = $(BUILD_DIR)/j2objc_guava.jar | ||
DIST_JAR = $(DIST_JAR_DIR)/j2objc_guava.jar | ||
|
||
JAR_STAGE_DIR = /tmp/j2objc_guava | ||
|
||
dist: $(DIST_LIBRARY) $(DIST_JAR) | ||
@(cd $(GEN_OBJC_DIR) && tar cf - $(TRANSLATE_HEADERS:$(GEN_OBJC_DIR)/%=%)) \ | ||
| (cd $(ARCH_INCLUDE_DIR); tar xfp -) | ||
|
||
test: $(FAT_LIB_LIBRARY) | ||
@$(MAKE) -f tests.mk test | ||
|
||
clean: | ||
@rm -rf $(BUILD_DIR) $(DIST_LIBRARY) $(ARCH_INCLUDE_DIR)/com/google/common $(DIST_JAR) | ||
|
||
java: $(DIST_JAR) | ||
|
||
# TODO(kstanger): Add -Xlint:unchecked once warnings are fixed. | ||
$(JAR): $(JAVA_SOURCES) | $(BUILD_DIR) java_deps_dist annotations_dist | ||
@echo "building j2objc_guava.jar" | ||
@rm -rf $(JAR_STAGE_DIR) | ||
@mkdir $(JAR_STAGE_DIR) | ||
@$(JAVAC) -sourcepath $(SOURCEPATH) -cp $(CLASSPATH) -encoding UTF-8 \ | ||
-d $(JAR_STAGE_DIR) -source 1.7 -target 1.7 \ | ||
-bootclasspath $(DIST_JAR_DIR)/jre_emul.jar $^ | ||
@jar cf $@ -C $(JAR_STAGE_DIR) . | ||
|
||
$(DIST_JAR): $(JAR) | $(DIST_JAR_DIR) | ||
@install -m 0644 $< $@ | ||
|
||
$(DIST_LIBRARY): $(FAT_LIB_LIBRARY) | $(ARCH_LIB_DIR) | ||
install -m 0644 $< $@ | ||
|
||
$(JAVA_SOURCES_MANIFEST): $(JAVA_SOURCES) | $(BUILD_DIR) | ||
@echo "Building $$(basename $@)" | ||
@if [ -e $@ ]; then rm $@; fi | ||
@files='$^' && for i in $$files; do echo $$i >> $@; done | ||
|
||
java_sources_manifest: $(JAVA_SOURCES_MANIFEST) | ||
@: | ||
|
||
$(OBJC_SOURCES_MANIFEST): $(TRANSLATE_JAVA_FULL) | $(BUILD_DIR) | ||
@echo "Building $$(basename $@)" | ||
@if [ -e $@ ]; then rm $@; fi | ||
@files='$(sort $(TRANSLATE_OBJC))' && for i in $$files; do \ | ||
echo $$i >> $@; \ | ||
done | ||
|
||
objc_sources_manifest: $(OBJC_SOURCES_MANIFEST) | ||
@: | ||
|
||
find_cycles: $(JAVA_SOURCES_MANIFEST) | cycle_finder_dist jre_emul_java_manifest | ||
$(DIST_DIR)/cycle_finder -sourcepath $(SOURCEPATH) -cp $(CLASSPATH) \ | ||
-w ../jre_emul/cycle_whitelist.txt -w cycle_whitelist \ | ||
-s ../jre_emul/$(BUILD_DIR_NAME)/java_sources.mf -s $(JAVA_SOURCES_MANIFEST) |
Oops, something went wrong.