2017-12-14 18:38:44 +08:00
|
|
|
.PHONY: jar push run clean compile compiletests test
|
2017-12-12 22:12:07 +08:00
|
|
|
|
|
|
|
SRC_DIR := src
|
|
|
|
GEN_DIR := gen
|
|
|
|
CLS_DIR := classes
|
|
|
|
CLS_DEX := classes.dex
|
2017-12-14 18:38:44 +08:00
|
|
|
TEST_SRC_DIR := tests
|
|
|
|
TEST_CLS_DIR := test_classes
|
|
|
|
TEST_LIBS := /usr/share/java/junit4.jar:/usr/share/java/hamcrest-core.jar
|
2017-12-12 22:12:07 +08:00
|
|
|
|
|
|
|
BUILD_TOOLS := $(ANDROID_HOME)/build-tools/26.0.2
|
|
|
|
AIDL := $(BUILD_TOOLS)/aidl
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
DX := $(BUILD_TOOLS)/dx.bat
|
|
|
|
else
|
|
|
|
DX := $(BUILD_TOOLS)/dx
|
|
|
|
endif
|
|
|
|
|
|
|
|
ANDROID_JAR := $(ANDROID_HOME)/platforms/android-26/android.jar
|
|
|
|
|
|
|
|
AIDL_SRC := android/view/IRotationWatcher.aidl
|
|
|
|
SRC := com/genymobile/scrcpy/ScrCpyServer.java \
|
2017-12-14 18:38:44 +08:00
|
|
|
com/genymobile/scrcpy/ControlEvent.java \
|
|
|
|
com/genymobile/scrcpy/ControlEventReader.java \
|
2017-12-12 22:12:07 +08:00
|
|
|
com/genymobile/scrcpy/DesktopConnection.java \
|
2018-01-23 21:37:54 +08:00
|
|
|
com/genymobile/scrcpy/Device.java \
|
2017-12-14 18:38:44 +08:00
|
|
|
com/genymobile/scrcpy/EventController.java \
|
2017-12-12 22:12:07 +08:00
|
|
|
com/genymobile/scrcpy/ScreenInfo.java \
|
|
|
|
com/genymobile/scrcpy/ScreenStreamer.java \
|
|
|
|
com/genymobile/scrcpy/ScreenStreamerSession.java \
|
2017-12-14 00:02:39 +08:00
|
|
|
com/genymobile/scrcpy/wrappers/DisplayManager.java \
|
2017-12-14 18:38:44 +08:00
|
|
|
com/genymobile/scrcpy/wrappers/InputManager.java \
|
2017-12-14 00:02:39 +08:00
|
|
|
com/genymobile/scrcpy/wrappers/ServiceManager.java \
|
|
|
|
com/genymobile/scrcpy/wrappers/WindowManager.java \
|
2017-12-12 22:12:07 +08:00
|
|
|
|
2017-12-14 18:38:44 +08:00
|
|
|
TEST_SRC := com/genymobile/scrcpy/ControlEventReaderTest.java \
|
|
|
|
|
|
|
|
# generate classnames from filepath
|
|
|
|
TEST_CLS := $(subst /,.,$(basename $(TEST_SRC)))
|
|
|
|
|
2017-12-12 22:12:07 +08:00
|
|
|
JAR := scrcpy-server.jar
|
|
|
|
MAIN := com.genymobile.scrcpy.ScrCpyServer
|
|
|
|
|
|
|
|
AIDL_GEN := $(AIDL_SRC:%.aidl=$(GEN_DIR)/%.java)
|
|
|
|
AIDL_CLS := $(AIDL_SRC:%.aidl=$(CLS_DIR)/%.class)
|
|
|
|
SRC_CLS := $(SRC:%.java=$(CLS_DIR)/%.class)
|
|
|
|
CLS := $(AIDL_CLS) $(SRC_CLS)
|
|
|
|
|
|
|
|
ALL_JAVA := $(AIDL_GEN) $(addprefix $(SRC_DIR)/,$(SRC))
|
2017-12-14 18:38:44 +08:00
|
|
|
ALL_TESTS := $(addprefix $(TEST_SRC_DIR)/,$(TEST_SRC))
|
2017-12-12 22:12:07 +08:00
|
|
|
|
|
|
|
jar: $(JAR)
|
|
|
|
|
|
|
|
$(AIDL_GEN): $(GEN_DIR)/%.java : $(SRC_DIR)/%.aidl
|
|
|
|
mkdir -p $(GEN_DIR)
|
|
|
|
"$(AIDL)" -o$(GEN_DIR) $(SRC_DIR)/$(AIDL_SRC)
|
|
|
|
|
2017-12-14 18:38:44 +08:00
|
|
|
compile: $(ALL_JAVA)
|
|
|
|
@mkdir -p "$(CLS_DIR)"
|
2017-12-12 22:12:07 +08:00
|
|
|
javac -source 1.7 -target 1.7 \
|
|
|
|
-cp "$(ANDROID_JAR)" \
|
|
|
|
-d "$(CLS_DIR)" -sourcepath $(SRC_DIR):$(GEN_DIR) \
|
|
|
|
$(ALL_JAVA)
|
2017-12-14 18:38:44 +08:00
|
|
|
|
|
|
|
$(JAR): $(ALL_JAVA)
|
|
|
|
# we cannot track easily class dependencies, so execute compile only when jar is outdated
|
|
|
|
+$(MAKE) compile
|
2017-12-12 22:12:07 +08:00
|
|
|
"$(DX)" --dex --output=$(CLS_DEX) $(CLS_DIR)
|
|
|
|
jar cvf $(JAR) classes.dex
|
|
|
|
|
|
|
|
push: jar
|
|
|
|
adb push $(JAR) /data/local/tmp/
|
|
|
|
|
|
|
|
run: push
|
|
|
|
adb shell "CLASSPATH=/data/local/tmp/$(JAR) app_process /system/bin $(MAIN)"
|
|
|
|
|
|
|
|
clean:
|
2017-12-14 18:38:44 +08:00
|
|
|
rm -rf $(CLS_DEX) $(CLS_DIR) $(GEN_DIR) $(JAR) $(TEST_CLS_DIR)
|
|
|
|
|
|
|
|
compiletests: compile $(ALL_TESTS)
|
|
|
|
@mkdir -p "$(TEST_CLS_DIR)"
|
|
|
|
javac -cp "$(TEST_LIBS):$(ANDROID_JAR):$(CLS_DIR)" -d "$(TEST_CLS_DIR)" -sourcepath "$(TEST_SRC_DIR)" $(ALL_TESTS)
|
|
|
|
|
|
|
|
test:
|
|
|
|
+$(MAKE) compiletests
|
|
|
|
java -cp "$(TEST_LIBS):$(ANDROID_JAR):$(CLS_DIR):$(TEST_CLS_DIR)" org.junit.runner.JUnitCore $(TEST_CLS)
|