Home | History | Annotate | Download | only in mock-ril
      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
      8 top=../../../
      9 
     10 # Directories of source files
     11 src_java=src/java
     12 src_cpp=src/cpp
     13 src_py=src/py
     14 src_js=src/js
     15 src_proto=src/proto
     16 src_generated=src/generated
     17 
     18 # Directories of generated source files
     19 gen_src_cpp=$(src_generated)/cpp
     20 gen_src_java=$(src_generated)/java
     21 gen_src_py=$(src_generated)/python
     22 gen_src_desc=$(src_generated)/desc
     23 
     24 # Generated files
     25 generated=$(gen_src_cpp)/msgheader.pb.cpp $(gen_src_cpp)/msgheader.pb.h $(gen_src_desc)/msgheader.desc \
     26       $(gen_src_py)/msgheader_pb2.py $(gen_src_java)/com/android/internal/communication/MsgHeader.java \
     27       $(gen_src_cpp)/ril.pb.cpp $(gen_src_cpp)/ril.pb.h $(gen_src_desc)/ril.desc \
     28       $(gen_src_py)/ril_pb2.py $(gen_src_java)/com/android/internal/telephony/ril_proto/RilCmds.java \
     29       $(gen_src_cpp)/ctrl.pb.cpp $(gen_src_cpp)/ctrl.pb.h $(gen_src_desc)/ctrl.desc \
     30       $(gen_src_py)/ctrl_pb2.py $(gen_src_java)/com/android/internal/telephony/ril_proto/RilCtrlCmds.java
     31 
     32 # A Makefile to run protoc and simplify testing.
     33 .PHONY : all
     34 all : $(generated)
     35 
     36 # TODO: Document/cleanup these testing targets as we learn whats needed.
     37 
     38 # Make the unit tests
     39 .PHONY : ut
     40 ut :
     41 	source $(top)build/envsetup.sh ; mmm $(top)frameworks/base/telephony/tests/telephonytests
     42 	adb install -r $(top)out/target/product/passion/data/app/FrameworksTelephonyTests.apk
     43 
     44 t : $(gen_src_cpp)/msgheader.pb.cpp $(gen_src_desc)/msgheader.desc $(gen_src_py)/msgheader_pb2.py $(gen_src_java)/com/android/internal/communication/MsgHeader.java
     45 
     46 # Run protoc to create the c++ files for msgheader
     47 $(gen_src_cpp)/msgheader.pb.cpp $(gen_src_cpp)/msgheader.pb.h : $(src_proto)/msgheader.proto
     48 	mkdir -p $(gen_src_cpp)
     49 	protoc --cpp_out=$(gen_src_cpp) --proto_path=$(src_proto) $<
     50 	mv $(gen_src_cpp)/msgheader.pb.cc $(gen_src_cpp)/msgheader.pb.cpp
     51 
     52 # Run protoc to create the python files for msgheader
     53 $(gen_src_desc)/msgheader.desc : $(src_proto)/msgheader.proto
     54 	mkdir -p $(gen_src_desc)
     55 	protoc --descriptor_set_out=$@ --proto_path=$(src_proto) --include_imports $<
     56 
     57 # Run protoc to create the pyhton files for msgheader
     58 $(gen_src_py)/msgheader_pb2.py : $(src_proto)/msgheader.proto
     59 	mkdir -p $(gen_src_py)
     60 	protoc --python_out=$(gen_src_py) --proto_path=$(src_proto) $<
     61 
     62 # Run protoc to create the java files for ril
     63 $(gen_src_java)/com/android/internal/communication/MsgHeader.java : $(src_proto)/msgheader.proto
     64 	mkdir -p $(gen_src_java)
     65 	protoc --javamicro_out=$(gen_src_java) --proto_path=$(src_proto) $<
     66 
     67 # Run protoc to create the c++ files for ril
     68 $(gen_src_cpp)/ril.pb.cpp $(gen_src_cpp)/ril.pb.h : $(src_proto)/ril.proto
     69 	mkdir -p $(gen_src_cpp)
     70 	protoc --cpp_out=$(gen_src_cpp) --proto_path=$(src_proto) $<
     71 	mv $(gen_src_cpp)/ril.pb.cc $(gen_src_cpp)/ril.pb.cpp
     72 
     73 # Run protoc to create the ril descriptor file for ril
     74 $(gen_src_desc)/ril.desc : $(src_proto)/ril.proto
     75 	mkdir -p $(gen_src_desc)
     76 	protoc --descriptor_set_out=$@ --proto_path=$(src_proto) --include_imports $<
     77 
     78 # Run protoc to create the pyhton files for ril
     79 $(gen_src_py)/ril_pb2.py : $(src_proto)/ril.proto
     80 	mkdir -p $(gen_src_py)
     81 	protoc --python_out=$(gen_src_py) --proto_path=$(src_proto) $<
     82 
     83 # Run protoc to create the java files for ril
     84 $(gen_src_java)/com/android/internal/telephony/ril_proto/RilCmds.java : $(src_proto)/ril.proto
     85 	mkdir -p $(gen_src_java)
     86 	protoc --javamicro_out=$(gen_src_java) --proto_path=$(src_proto) $<
     87 
     88 # Run protoc to create the c++ files for control
     89 $(gen_src_cpp)/ctrl.pb.cpp $(gen_src_cpp)/ctrl.pb.h : $(src_proto)/ctrl.proto
     90 	mkdir -p $(gen_src_cpp)
     91 	protoc --cpp_out=$(gen_src_cpp) --proto_path=$(src_proto) $<
     92 	mv $(gen_src_cpp)/ctrl.pb.cc $(gen_src_cpp)/ctrl.pb.cpp
     93 
     94 # Run protoc to create the pyhton files for control
     95 $(gen_src_py)/ctrl_pb2.py : $(src_proto)/ctrl.proto
     96 	mkdir -p $(gen_src_py)
     97 	protoc --python_out=$(gen_src_py) --proto_path=$(src_proto) $<
     98 
     99 # Run protoc to create the ctrl descriptor file for control
    100 $(gen_src_desc)/ctrl.desc : $(src_proto)/ctrl.proto
    101 	mkdir -p $(gen_src_desc)
    102 	protoc --descriptor_set_out=$@ --proto_path=$(src_proto) --include_imports $<
    103 
    104 # Run protoc to create the java files for ril
    105 $(gen_src_java)/com/android/internal/telephony/ril_proto/RilCtrlCmds.java : $(src_proto)/ctrl.proto
    106 	mkdir -p $(gen_src_java)
    107 	protoc --javamicro_out=$(gen_src_java) --proto_path=$(src_proto) $<
    108 
    109 # After starting phone do this first to get lastest ril.desc/proto and setup rild
    110 .PHONY : first
    111 first : root_remount copy_all forward
    112 
    113 # copy js and descriptors, restart rild and run mockril_tests
    114 .PHONY : tmr
    115 tmr : copy_js_desc restart_rild mockril_tests
    116 
    117 # Copy all files, restart rild and run mockril_tests
    118 .PHONY : test
    119 test : copy_all restart_rild install_mockril_tests mockril_tests
    120 
    121 # Restart rild
    122 .PHONY : restart_rild
    123 restart_rild :
    124 	adb shell ps | awk '/rild/ { print $$2 }' | xargs adb shell kill
    125 
    126 # Update only the js/copy and restart rild
    127 .PHONY : tjs
    128 tjs : copy_js_desc restart_rild
    129 
    130 # Run test control server python script
    131 .PHONY : tcs
    132 tcs :
    133 	./tcs.py 127.0.0.1 11111
    134 
    135 # Run the mock ril tests (use adb shell pm list instrumentation to see the Runner)
    136 .PHONY : mockril_tests
    137 mockril_tests :
    138 	adb  shell am instrument -e class 'com.android.internal.telephony.mockril.MockRilTest' -w com.android.frameworks.telephonytests/.TelephonyMockRilTestRunner
    139 
    140 # forward the control server tcp port (54312) to a port on the PC side (11111)
    141 .PHONY : forward
    142 forward :
    143 	adb forward tcp:11111 tcp:54312
    144 
    145 # change to root and remount device
    146 .PHONY : root_remount
    147 root_remount :
    148 	adb root ; sleep 3 ; adb remount ; adb shell setprop rild.libpath /data/lib/libmock_ril.so
    149 
    150 # Copy all files
    151 .PHONY : copy_all
    152 copy_all : copy_js_desc copy_mockril
    153 
    154 # Copy js and the protobuf descriptor files
    155 .PHONY : copy_js_desc
    156 copy_js_desc :
    157 	adb push $(src_js)/mock_ril.js /sdcard/data/
    158 	adb push $(src_js)/mock_ril_tests.js /sdcard/data/
    159 	adb push $(src_js)/simulated_radio.js /sdcard/data/
    160 	adb push $(src_js)/simulated_radio_tests.js /sdcard/data/
    161 	adb push $(src_js)/simulated_icc.js /sdcard/data/
    162 	adb push $(src_js)/simulated_icc_tests.js /sdcard/data/
    163 	adb push $(src_js)/ctrl_server.js /sdcard/data/
    164 	adb push $(src_js)/ctrl_server_tests.js /sdcard/data/
    165 	adb push $(src_js)/ril_vars.js /sdcard/data/
    166 	adb push $(gen_src_desc)/ril.desc /sdcard/data/
    167 	adb push $(gen_src_desc)/ctrl.desc /sdcard/data/
    168 	adb forward tcp:11111 tcp:54312
    169 
    170 # Copy the mock ril library
    171 .PHONY : copy_mockril
    172 copy_mockril :
    173 	adb push $(top)out/target/product/passion/system/lib/libmock_ril.so /data/lib/
    174 
    175 .PHONY : install_mockril_tests
    176 install_mockril_tests :
    177 	adb install -r $(top)out/target/product/passion/data/app/FrameworksTelephonyTests.apk
    178 
    179 # Remove generated files
    180 .PHONY : clean
    181 clean :
    182 	rm -f $(generated)
    183