diff --git a/Makefile b/Makefile index 372cc9442e..87109c8b40 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ -# include awx/ui-next/Makefile +mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) +current_dir := $(dir $(mkfile_path)) + +include awx/ui-next/Makefile PYTHON ?= python3.9 OFFICIAL ?= no @@ -399,7 +402,7 @@ bulk_data: # UI TASKS # -------------------------------------- -UI_BUILD_FLAG_FILE = awx/ui/.ui-built +UI_BUILD_FLAG_FILE = $(current_dir)ui/.ui-built clean-ui: rm -rf node_modules @@ -460,7 +463,7 @@ HEADLESS ?= no ifeq ($(HEADLESS), yes) dist/$(SDIST_TAR_FILE): else -dist/$(SDIST_TAR_FILE): $(UI_BUILD_FLAG_FILE) +dist/$(SDIST_TAR_FILE): $(UI_BUILD_FLAG_FILE) awx/ui-next/ansible-ui/build endif $(PYTHON) -m build -s ln -sf $(SDIST_TAR_FILE) dist/awx.tar.gz @@ -508,8 +511,6 @@ docker-compose-sources: .git/hooks/pre-commit -e enable_prometheus=$(PROMETHEUS) \ -e enable_grafana=$(GRAFANA) $(EXTRA_SOURCES_ANSIBLE_OPTS) - - docker-compose: awx/projects docker-compose-sources docker-compose -f tools/docker-compose/_sources/docker-compose.yml $(COMPOSE_OPTS) up $(COMPOSE_UP_OPTS) --remove-orphans @@ -542,7 +543,7 @@ docker-compose-container-group-clean: rm -rf tools/docker-compose-minikube/_sources/ ## Base development image build -docker-compose-build: +docker-compose-build: ansible-playbook tools/ansible/dockerfile.yml -e build_dev=True -e receptor_image=$(RECEPTOR_IMAGE) DOCKER_BUILDKIT=1 docker build -t $(DEVEL_IMAGE_NAME) \ --build-arg BUILDKIT_INLINE_CACHE=1 \ @@ -666,3 +667,11 @@ help/generate: } \ { lastLine = $$0 }' $(MAKEFILE_LIST) | sort -u @printf "\n" + +## Display help for a specific target folder +help/%: + @make -s help MAKEFILE_LIST="$*/Makefile" + +## Display help for a specific target folder +help/%/aliases: + @make -s help/all MAKEFILE_LIST="$*/Makefile.aliases" \ No newline at end of file diff --git a/awx/ui-next/Makefile b/awx/ui-next/Makefile index da14ce19f2..d47583e1db 100644 --- a/awx/ui-next/Makefile +++ b/awx/ui-next/Makefile @@ -1,4 +1,87 @@ -ui-next/clone: +ui_next_mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) +ui_next_dir := $(dir $(ui_next_mkfile_path)) + +ifeq ($(current_dir), undefined) + ui_next_dir := $(dir $(ui_next_mkfile_path)) +else + ui_next_dir := $(shell realpath --relative-to $(current_dir) $(ui_next_dir))/ +endif + +ANSIBLE_UI_GIT_REPO_HTTPS ?= +ANSIBLE_UI_GIT_REPO_SSH ?= + +ANSIBLE_UI_GIT_BRANCH ?= main + +ANSIBLE_UI_LOCAL ?= + +ANSIBLE_UI_DIR ?= $(ui_next_dir)ansible-ui + +.PHONY: ui-next/clone-https +## Shallow clone the ui-next repo via https skip if ANSIBLE_UI_GIT_REPO_HTTPS is undefined +ui-next/clone-https: + @if [ -z "$(ANSIBLE_UI_GIT_REPO_HTTPS)" ]; then \ + echo "SKIP: ui-next/clone-https. ANSIBLE_UI_GIT_REPO_HTTPS is not set."; \ + elif [ -d "$(ANSIBLE_UI_DIR)" ]; then \ + echo "SKIP: ui-next/clone-https. $(ANSIBLE_UI_DIR) already exists."; \ + else \ + git clone --depth 1 --branch $(ANSIBLE_UI_GIT_BRANCH) $(ANSIBLE_UI_GIT_REPO_HTTPS) $(ANSIBLE_UI_DIR) || true; \ + fi + +.PHONY: ui-next/clone-ssh +## Shallow clone the ui-next repo via ssh. +ui-next/clone-ssh: + @if [ -z "$(ANSIBLE_UI_GIT_REPO_SSH)" ]; then \ + echo "SKIP: ui-next/clone-ssh. ANSIBLE_UI_GIT_REPO_SSH is not set."; \ + elif [ -d "$(ANSIBLE_UI_DIR)" ]; then \ + echo "SKIP: ui-next/clone-ssh. $(ANSIBLE_UI_DIR) already exists."; \ + else \ + git clone --depth 1 --branch $(ANSIBLE_UI_GIT_BRANCH) $(ANSIBLE_UI_GIT_REPO_SSH) $(ANSIBLE_UI_DIR) || true; \ + fi + +.PHONY: ui-next/link-local +## Link to a existing local clone of ui-next repo. +ui-next/link-local: + @if [ -z "$(ANSIBLE_UI_LOCAL)" ]; then \ + echo "SKIP: ui-next/link-local. ANSIBLE_UI_LOCAL is not set."; \ + elif [ -d "$(ANSIBLE_UI_DIR)" ]; then \ + echo "SKIP: ui-next/link-local. $(ANSIBLE_UI_DIR) already exists."; \ + else \ + ln -s $(ANSIBLE_UI_LOCAL) $(ANSIBLE_UI_DIR); \ + fi + +.PHONY: ui-next +## Try to link to a local clone of ui-next repo if it exist otherwise clone via ssh than https. +ui-next: + @if [ -d "$(ANSIBLE_UI_DIR)" ]; then \ + echo "SKIP: ui-next. $(ANSIBLE_UI_DIR) already exists."; \ + else \ + $(MAKE) ui-next/link-local ui-next/clone-ssh ui-next/clone-https; \ + fi + +## Alias for ui-next, will not run if ui-next already exist +$(ANSIBLE_UI_DIR): + $(MAKE) ui-next + +.PHONY: ui-next/build +## Build ui-next +ui-next/build: ui-next + cd $(ANSIBLE_UI_DIR) && \ + npm install webpack && \ + npm run build:controller + +## Alias for ui-next/build, will not run if build already exist +$(ANSIBLE_UI_DIR)/build: + $(MAKE) ui-next/build + +.PHONY: ui-next/clean +## Clean ui-next +ui-next/clean: + rm -rf $(UI_NEXT_BUILD_FLAG_FILE) + rm -rf $(ANSIBLE_UI_DIR) + +.PHONY: ui-next/clean/build +## Clean ui-next build +ui-next/clean/build: + rm -rf $(UI_NEXT_BUILD_FLAG_FILE) + rm -rf $(ANSIBLE_UI_DIR)/build -ui-next/build: ui-next/clone - $(MAKE) -C ui-next build \ No newline at end of file