farzanahmed112 commited on
Commit
e1f1625
·
1 Parent(s): d9339dd

Create Makefile

Browse files
Files changed (1) hide show
  1. Makefile +44 -0
Makefile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ SHELL := /bin/bash
2
+ ALIAS = "android"
3
+ EXISTS := $(shell docker ps -a -q -f name=$(ALIAS))
4
+ RUNNED := $(shell docker ps -q -f name=$(ALIAS))
5
+ ifneq "$(RUNNED)" ""
6
+ IP := $(shell docker inspect $(ALIAS) | grep "IPAddress\"" | head -n1 | cut -d '"' -f 4)
7
+ endif
8
+ STALE_IMAGES := $(shell docker images | grep "<none>" | awk '{print($$3)}')
9
+ EMULATOR ?= "android-19"
10
+ ARCH ?= "armeabi-v7a"
11
+
12
+ COLON := :
13
+
14
+ .PHONY = run ports kill ps
15
+
16
+ all:
17
+ @docker build -q -t tracer0tong/android-emulator\:latest .
18
+ @docker images
19
+
20
+ run: clean
21
+ @docker run -e "EMULATOR=$(EMULATOR)" -e "ARCH=$(ARCH)" -d -P --name android --log-driver=json-file tracer0tong/android-emulator
22
+
23
+ ports:
24
+ ifneq "$(RUNNED)" ""
25
+ $(eval ADBPORT := $(shell docker port $(ALIAS) | grep '5555/tcp' | awk '{split($$3,a,"$(COLON)");print a[2]}'))
26
+ @echo -e "Use:\n adb kill-server\n adb connect $(IP):$(ADBPORT)"
27
+ @echo -e "or\n adb connect 0.0.0.0:$(ADBPORT)"
28
+ else
29
+ @echo "Run container"
30
+ endif
31
+
32
+ clean: kill
33
+ @docker ps -a -q | xargs -n 1 -I {} docker rm -f {}
34
+ ifneq "$(STALE_IMAGES)" ""
35
+ @docker rmi -f $(STALE_IMAGES)
36
+ endif
37
+
38
+ kill:
39
+ ifneq "$(RUNNED)" ""
40
+ @docker kill $(ALIAS)
41
+ endif
42
+
43
+ ps:
44
+ @docker ps -a -f name=$(ALIAS)