# RemoveBG Studio
#
# Common entry points for building/running the native app and keeping the
# Python engine's virtualenv in sync. Requires: CMake, MSVC (Visual Studio
# 2022 Build Tools or full VS), PowerShell, and uv (or pip) for Python deps.

GENERATOR ?= Visual Studio 17 2022
CONFIG ?= Release
BUILD_DIR := native/build
WEBVIEW2_HEADER := native/third_party/webview2/include/WebView2.h
EXE := $(BUILD_DIR)/$(CONFIG)/RemoveBGStudio.exe

.PHONY: all sync fetch-deps configure build run clean

all: build

# --- Python engine -----------------------------------------------------

sync:
	uv sync

# --- Native app ----------------------------------------------------------

$(WEBVIEW2_HEADER):
	powershell -ExecutionPolicy Bypass -File native/third_party/fetch-webview2.ps1

fetch-deps: $(WEBVIEW2_HEADER)

configure: fetch-deps
	cmake -S native -B $(BUILD_DIR) -G "$(GENERATOR)" -A x64

build: configure
	cmake --build $(BUILD_DIR) --config $(CONFIG)

run: build
	$(EXE)

clean:
	rm -rf $(BUILD_DIR)
