xref: /aosp_15_r20/external/drm_hwcomposer/Makefile (revision 0a9764fe0a15e71ebbeb85e87e10990c23aab47f)
1#!/usr/bin/make
2
3DOCKER_BIN := $(shell command -v docker 2> /dev/null)
4NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
5
6DOCKERFILE := .ci/Dockerfile
7IMAGE_NAME := drmhwc_ci
8
9# We can't run style and bpfmt check in docker
10# when repo is within AOSP tree, will run it locally.
11GIT_IS_SYMLINK:=$(shell test -L .git && echo true)
12
13define print_no_docker_err
14$(warning Please install docker, e.g. for Ubuntu:)
15$(warning $$ sudo apt install docker.io)
16$(warning $$ sudo usermod -aG docker $$USER)
17$(warning and reboot your PC)
18$(error Aborting...)
19endef
20
21.PHONY : help prepare shell ci_fast ci ci_cleanup build_deploy bd local_presubmit local_cleanup
22.DEFAULT_GOAL := help
23
24help: ## Show this help
25	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
26
27PREPARE:=.out/prepare_docker.timestamp
28$(PREPARE): $(DOCKERFILE)
29	$(if $(DOCKER_BIN),,$(call print_no_docker_err))
30	mkdir -p $(dir $@)
31	$(DOCKER_BIN) build -t local/build-env -f $(DOCKERFILE) .;
32	$(DOCKER_BIN) stop $(IMAGE_NAME) || true
33	$(DOCKER_BIN) rm $(IMAGE_NAME) || true
34	$(DOCKER_BIN) run -itd --name $(IMAGE_NAME) --network="host" -v $(shell pwd):/home/user/drm_hwcomposer local/build-env
35	@touch $@
36
37prepare: $(PREPARE)
38prepare: ## Build and run Docker image
39
40shell: $(PREPARE)
41shell: ## Start shell into a container
42	$(DOCKER_BIN) exec -it $(IMAGE_NAME) bash
43
44ci_fast: $(PREPARE)
45ci_fast: ## Run meson build for arm64 in docker container
46	@echo "Run meson cross-build for Android:"
47	$(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "make -C ~/aospless all"
48
49ci: $(PREPARE)
50ci: ## Run presubmit within the docker container
51	@echo "Run native build:"
52	$(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "make -f .ci/Makefile -j$(NPROCS)"
53	@echo "Run meson cross-build for Android:"
54	$(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "make -C ~/aospless install"
55	@echo "Run style check:"
56	$(if $(GIT_IS_SYMLINK), \
57		./.ci/.gitlab-ci-checkcommit.sh, \
58		$(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "./.ci/.gitlab-ci-checkcommit.sh")
59	@echo "\n\e[32m --- SUCCESS ---\n"
60
61ci_cleanup: ## Cleanup after 'make ci'
62	$(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "make -f .ci/Makefile clean"
63	$(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "rm -rf ~/aospless/build"
64	$(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "rm -rf ~/aospless/install"
65	$(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "rm -rf ~/aospless/out_src"
66
67build_deploy: $(PREPARE)
68build_deploy: ## Build for Andoid and deploy onto the target device (require active adb device connected)
69	$(if $(filter $(shell adb shell getprop ro.bionic.arch),arm64),,$(error arm64 only is supported at the moment))
70	adb root && adb remount vendor
71	mkdir -p .out/arm64
72	$(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "make -C ~/aospless install"
73	$(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "cp -r ~/aospless/install/* ~/drm_hwcomposer/.out/arm64"
74	adb push .out/arm64/vendor/bin/hw/android.hardware.composer.hwc3-service.drm /vendor/bin/hw/android.hardware.composer.hwc3-service.drm
75	adb shell stop
76	adb shell stop vendor.hwcomposer-3 && adb shell start vendor.hwcomposer-3 || true
77	bash -c '[[ "$$HWCLOG" -eq "1" ]] && adb logcat -c || true'
78	adb shell start
79	bash -c '[[ "$$HWCLOG" -eq "1" ]] && adb logcat | grep -i hwc || true'
80
81bd: build_deploy
82bd: ## Alias for build_deploy
83