1# This has various targets to assist in developing
2# and testing the mock ril. The default "all" target
3# invokes protoc to generate the appropriate protobuf
4# code. The other targest are used for testing.
5
6# Assume this Makefile is run in place then top
7# point to the top of the android source tree
8top=../../../
9
10PROTOC=$(wildcard $(top)out/host/*/bin/aprotoc)
11#if ((($(words $(PROTO)) != 1)))
12ifneq ($(words $(PROTOC)),1)
13$(error expecting 1 protoc we have $(words $(PROTOC)), PROTOC='$(PROTOC)')
14endif
15
16ifeq ("$(ANDROID_DEVICE)","")
17$(warning Default to ANDROID_DEVICE=passion")
18ANDROID_DEVICE=passion
19endif
20
21# Directories of source files
22device=$(ANDROID_DEVICE)
23src_js=src/js
24src_proto=src/proto
25src_generated=$(top)out/target/product/$(device)/obj/SHARED_LIBRARIES/libmock_ril_intermediates/proto/hardware/ril/mock-ril/src/proto
26
27# Directories of generated source files
28gen_src_py=$(src_generated)/python
29gen_src_desc=$(src_generated)/desc
30
31# Generated files
32generated=$(gen_src_desc)/msgheader.desc $(gen_src_py)/msgheader_pb2.py \
33      $(gen_src_desc)/ril.desc $(gen_src_py)/ril_pb2.py \
34      $(gen_src_desc)/ctrl.desc $(gen_src_py)/ctrl_pb2.py
35
36# A Makefile to run protoc and simplify testing.
37.PHONY : all
38all : $(generated)
39
40# TODO: Document/cleanup these testing targets as we learn whats needed.
41
42# Make the unit tests
43.PHONY : ut
44ut :
45	source $(top)build/envsetup.sh ; mmm $(top)frameworks/base/telephony/tests/telephonytests
46	adb install -r $(top)out/target/product/$(device)/data/app/FrameworksTelephonyTests.apk
47
48t : $(gen_src_desc)/msgheader.desc $(gen_src_py)/msgheader_pb2.py
49
50# Run protoc to create the descriptor files for msgheader
51$(gen_src_desc)/msgheader.desc : $(src_proto)/msgheader.proto
52	mkdir -p $(gen_src_desc)
53	$(PROTOC) --descriptor_set_out=$@ --proto_path=$(src_proto) --include_imports $<
54
55# Run protoc to create the python files for msgheader
56$(gen_src_py)/msgheader_pb2.py : $(src_proto)/msgheader.proto
57	mkdir -p $(gen_src_py)
58	$(PROTOC) --python_out=$(gen_src_py) --proto_path=$(src_proto) $<
59
60# Run protoc to create the ril descriptor file for ril
61$(gen_src_desc)/ril.desc : $(src_proto)/ril.proto
62	mkdir -p $(gen_src_desc)
63	$(PROTOC) --descriptor_set_out=$@ --proto_path=$(src_proto) --include_imports $<
64
65# Run protoc to create the python files for ril
66$(gen_src_py)/ril_pb2.py : $(src_proto)/ril.proto
67	mkdir -p $(gen_src_py)
68	$(PROTOC) --python_out=$(gen_src_py) --proto_path=$(src_proto) $<
69
70# Run protoc to create the python files for control
71$(gen_src_py)/ctrl_pb2.py : $(src_proto)/ctrl.proto
72	mkdir -p $(gen_src_py)
73	$(PROTOC) --python_out=$(gen_src_py) --proto_path=$(top) --proto_path=$(src_proto) $<
74
75# Run protoc to create the ctrl descriptor file for control
76$(gen_src_desc)/ctrl.desc : $(src_proto)/ctrl.proto
77	mkdir -p $(gen_src_desc)
78	$(PROTOC) --descriptor_set_out=$@ --proto_path=$(top) --proto_path=$(src_proto) --include_imports $<
79
80# After starting phone do this first to get lastest ril.desc/proto and setup rild
81.PHONY : first
82first : root_remount copy_all forward
83
84# copy js and descriptors, restart rild and run mockril_tests
85.PHONY : tmr
86tmr : copy_js_desc restart_rild mockril_tests
87
88# Copy all files, restart rild and run mockril_tests
89.PHONY : test
90test : copy_all restart_rild install_mockril_tests mockril_tests
91
92# Restart rild
93.PHONY : restart_rild
94restart_rild :
95	adb shell setprop ctl.restart ril-daemon
96
97# Update only the js/copy and restart rild
98.PHONY : tjs
99tjs : copy_js_desc restart_rild
100
101# Run test control server python script
102.PHONY : tcs
103tcs :
104	./tcs.py 127.0.0.1 11111
105
106# Run the mock ril tests (use adb shell pm list instrumentation to see the Runner)
107.PHONY : mockril_tests
108mockril_tests :
109	adb  shell am instrument -e class 'com.android.internal.telephony.mockril.MockRilTest' -w com.android.frameworks.telephonytests/.TelephonyMockRilTestRunner
110
111# forward the control server tcp port (54312) to a port on the PC side (11111)
112.PHONY : forward
113forward :
114	adb forward tcp:11111 tcp:54312
115
116# change to root and remount device
117.PHONY : root_remount
118root_remount :
119	adb root ; sleep 3 ; adb remount ; adb shell setprop rild.libpath /data/lib/libmock_ril.so
120
121# Copy all files
122.PHONY : copy_all
123copy_all : copy_js_desc copy_mockril
124
125# Copy js and the protobuf descriptor files
126.PHONY : copy_js_desc
127copy_js_desc :
128	adb push $(src_js)/mock_ril.js /sdcard/data/
129	adb push $(src_js)/mock_ril_tests.js /sdcard/data/
130	adb push $(src_js)/simulated_radio.js /sdcard/data/
131	adb push $(src_js)/simulated_radio_tests.js /sdcard/data/
132	adb push $(src_js)/simulated_icc.js /sdcard/data/
133	adb push $(src_js)/simulated_icc_tests.js /sdcard/data/
134	adb push $(src_js)/ctrl_server.js /sdcard/data/
135	adb push $(src_js)/ctrl_server_tests.js /sdcard/data/
136	adb push $(src_js)/ril_vars.js /sdcard/data/
137	adb push $(gen_src_desc)/ril.desc /sdcard/data/
138	adb push $(gen_src_desc)/ctrl.desc /sdcard/data/
139	adb forward tcp:11111 tcp:54312
140
141
142# Copy the mock ril library
143.PHONY : copy_mockril
144copy_mockril :
145	adb push $(top)out/target/product/$(device)/system/lib/libmock_ril.so /data/lib/
146
147.PHONY : install_mockril_tests
148install_mockril_tests :
149	adb install -r $(top)out/target/product/$(device)/data/app/FrameworksTelephonyTests.apk
150
151# Remove generated files
152.PHONY : clean
153clean :
154	rm -f $(generated)
155