Roman Stratiienko | 3295719 | 2022-12-15 10:12:31 +0200 | [diff] [blame] | 1 | #!/usr/bin/make |
| 2 | |
| 3 | DOCKER_BIN := $(shell command -v docker 2> /dev/null) |
| 4 | NPROCS:=$(shell grep -c ^processor /proc/cpuinfo) |
| 5 | |
| 6 | DOCKERFILE := .ci/Dockerfile |
| 7 | IMAGE_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. |
| 11 | GIT_IS_SYMLINK:=$(shell test -L .git && echo true) |
| 12 | |
| 13 | define 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...) |
| 19 | endef |
| 20 | |
Roman Stratiienko | 2bf68c3 | 2022-12-16 12:57:27 +0200 | [diff] [blame] | 21 | .PHONY : help prepare shell ci_fast ci ci_cleanup build_deploy bd local_presubmit local_cleanup |
Roman Stratiienko | 3295719 | 2022-12-15 10:12:31 +0200 | [diff] [blame] | 22 | .DEFAULT_GOAL := help |
| 23 | |
| 24 | help: ## Show this help |
| 25 | @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
| 26 | |
| 27 | PREPARE:=.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 | |
| 37 | prepare: $(PREPARE) |
| 38 | prepare: ## Build and run Docker image |
| 39 | |
| 40 | shell: $(PREPARE) |
| 41 | shell: ## Start shell into a container |
| 42 | $(DOCKER_BIN) exec -it $(IMAGE_NAME) bash |
| 43 | |
Roman Stratiienko | 2bf68c3 | 2022-12-16 12:57:27 +0200 | [diff] [blame] | 44 | ci_fast: $(PREPARE) |
| 45 | ci_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 | |
Roman Stratiienko | 3295719 | 2022-12-15 10:12:31 +0200 | [diff] [blame] | 49 | ci: $(PREPARE) |
| 50 | ci: ## 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)" |
Roman Stratiienko | 2bf68c3 | 2022-12-16 12:57:27 +0200 | [diff] [blame] | 53 | @echo "Run meson cross-build for Android:" |
| 54 | $(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "make -C ~/aospless all" |
Roman Stratiienko | 3295719 | 2022-12-15 10:12:31 +0200 | [diff] [blame] | 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 | |
| 61 | ci_cleanup: ## Cleanup after 'make ci' |
Roman Stratiienko | 2a93e4c | 2022-12-19 18:24:47 +0200 | [diff] [blame] | 62 | $(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "make -f .ci/Makefile clean " |
Roman Stratiienko | 2bf68c3 | 2022-12-16 12:57:27 +0200 | [diff] [blame] | 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 | |
| 67 | build_deploy: $(PREPARE) |
| 68 | build_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 all" |
| 73 | $(DOCKER_BIN) exec -it $(IMAGE_NAME) bash -c "cp -r ~/aospless/install/* ~/drm_hwcomposer/.out/arm64" |
| 74 | adb push .out/arm64/vendor/lib64/hw/hwcomposer.drm.so /vendor/lib64/hw/hwcomposer.drm.so |
| 75 | adb shell stop |
| 76 | adb shell stop vendor.hwcomposer-2-1 && adb shell start vendor.hwcomposer-2-1 || true |
| 77 | adb shell stop vendor.hwcomposer-2-2 && adb shell start vendor.hwcomposer-2-2 || true |
| 78 | adb shell stop vendor.hwcomposer-2-3 && adb shell start vendor.hwcomposer-2-3 || true |
| 79 | adb shell stop vendor.hwcomposer-2-4 && adb shell start vendor.hwcomposer-2-4 || true |
| 80 | bash -c '[[ "$$HWCLOG" -eq "1" ]] && adb logcat -c || true' |
| 81 | adb shell start |
| 82 | bash -c '[[ "$$HWCLOG" -eq "1" ]] && adb logcat | grep -i hwc || true' |
| 83 | |
| 84 | bd: build_deploy |
| 85 | bd: ## Alias for build_deploy |