2026-03-11 15:34:15 +08:00
.DEFAULT_GOAL := help
SHELL := /bin/bash
FLUTTER ?= flutter
PNPM ?= pnpm
DART ?= dart
DEVICE ?= macos
2026-03-23 17:28:54 +08:00
APP_STORE_DART_DEFINE ?= --dart-define= XWORKMATE_APP_STORE = true
2026-03-28 20:22:48 +08:00
PUBSPEC_VERSION_LINE := $( shell sed -n 's/^version:[[:space:]]*//p' pubspec.yaml | head -n 1)
PUBSPEC_BUILD_DATE := $( shell sed -n 's/^build-date:[[:space:]]*//p' pubspec.yaml | head -n 1)
PUBSPEC_BUILD_ID := $( shell sed -n 's/^build-id:[[:space:]]*//p' pubspec.yaml | head -n 1)
APP_VERSION := $( firstword $( subst +, ,$( PUBSPEC_VERSION_LINE) ) )
APP_BUILD_NUMBER_RAW := $( word 2,$( subst +, ,$( PUBSPEC_VERSION_LINE) ) )
APP_BUILD_NUMBER := $( if $( APP_BUILD_NUMBER_RAW) ,$( APP_BUILD_NUMBER_RAW) ,1)
2026-04-13 18:02:30 +08:00
APP_BUILD_DATE := $( if $( PUBSPEC_BUILD_DATE) ,$( PUBSPEC_BUILD_DATE) ,unknown)
APP_BUILD_COMMIT := $( if $( PUBSPEC_BUILD_ID) ,$( PUBSPEC_BUILD_ID) ,unknown)
2026-03-28 20:22:48 +08:00
APP_DART_DEFINE_VERSION ?= --dart-define= XWORKMATE_DISPLAY_VERSION = $( APP_VERSION)
APP_DART_DEFINE_BUILD ?= --dart-define= XWORKMATE_BUILD_NUMBER = $( APP_BUILD_NUMBER)
2026-04-13 18:02:30 +08:00
APP_DART_DEFINE_BUILD_DATE ?= --dart-define= XWORKMATE_BUILD_DATE = $( APP_BUILD_DATE)
APP_DART_DEFINE_BUILD_COMMIT ?= --dart-define= XWORKMATE_BUILD_COMMIT = $( APP_BUILD_COMMIT)
2026-03-11 15:34:15 +08:00
2026-05-28 13:20:57 +08:00
.PHONY : help deps analyze test test -all test -flutter test -golden test -integration test -integration -macos test -patrol test -go test -ci check format run open -macos -xcode sync -version build -linux build -macos build -ios -sim ios -pods ios -pods -check build -ios -release -no -codesign verify -ios -release package -deb package -rpm package -linux package -mac install -mac clean render -release -docs docs -public -api check -export -compliance test -real -env -login -chain inspect -xworkmate -bridge -service test -api -contract test -api -scenario -contract check -api -external
2026-03-11 15:34:15 +08:00
help : ## Show available targets
@grep -E '^[a-zA-Z0-9_.-]+:.*?## ' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-18s %s\n", $$1, $$2}'
deps : ## Install Flutter dependencies
$( FLUTTER) pub get
analyze : ## Run static analysis
$( FLUTTER) analyze
test : ## Run Flutter tests
$( FLUTTER) test
2026-04-08 16:37:12 +08:00
test-flutter : ## Run the full Flutter unit/widget test suite
$( FLUTTER) test
test-golden : ## Run Flutter Golden tests
$( FLUTTER) test test/golden
test-integration : ## Run Flutter integration tests
$( FLUTTER) test integration_test
test-integration-macos : ## Run macOS integration tests serially for the desktop app
$( FLUTTER) test integration_test/desktop_navigation_flow_test.dart -d macos
$( FLUTTER) test integration_test/desktop_settings_flow_test.dart -d macos
2026-04-10 10:18:46 +08:00
test-real-env-login-chain : ## Run the real-env login/sync integration chain on macOS
$( FLUTTER) test integration_test/login_flow_test.dart -d macos
inspect-xworkmate-bridge-service : ## Read-only SSH inspection for xworkmate-bridge.svc.plus service
bash scripts/check-xworkmate-bridge-service.sh
2026-04-22 09:47:38 +08:00
test-api-contract : ## Run the API interface contract script against external services
bash scripts/ci/verify_api_interface_contract.sh
test-api-scenario-contract : ## Run the scenario-oriented API script against external services
bash scripts/ci/verify_api_scenario_contract.sh
check-api-external : test -api -contract test -api -scenario -contract ## Run both external API validation scripts
2026-04-08 16:37:12 +08:00
test-patrol : ## Run Patrol end-to-end tests
dart pub global activate patrol_cli
patrol test
2026-04-09 11:19:40 +08:00
test-go : ## Run xworkmate-bridge Go unit tests
cd ../xworkmate-bridge && go test ./...
2026-04-08 16:37:12 +08:00
test-ci : test -flutter test -golden test -integration test -go ## Run the PR validation chain
test-all : test -ci test -patrol ## Run the full local validation chain
2026-03-11 15:34:15 +08:00
check : analyze test ## Run the standard validation suite
format : ## Format Dart sources
$( DART) format lib test
2026-03-22 10:49:13 +08:00
render-release-docs : ## Render feature matrix, roadmap, release notes, and changelog docs
$( DART) run tool/render_release_docs.dart
2026-04-14 16:20:45 +08:00
docs-public-api : ## Generate the public API inventory docs payload
python3 scripts/docs/extract_public_api_inventory.py
2026-05-19 11:22:52 +08:00
sync-version : ## Sync Flutter/Xcode build metadata from pubspec.yaml
$( FLUTTER) build macos --config-only --build-name= $( APP_VERSION) --build-number= $( APP_BUILD_NUMBER) $( APP_DART_DEFINE_VERSION) $( APP_DART_DEFINE_BUILD) $( APP_DART_DEFINE_BUILD_DATE) $( APP_DART_DEFINE_BUILD_COMMIT)
2026-03-28 20:22:48 +08:00
@echo " version= $( APP_VERSION) "
@echo " build= $( APP_BUILD_NUMBER) "
@echo " build-date= $( PUBSPEC_BUILD_DATE) "
@echo " build-id= $( PUBSPEC_BUILD_ID) "
2026-05-19 11:22:52 +08:00
@sed -n 's/^FLUTTER_BUILD_NAME=/xcode-build-name=/p; s/^FLUTTER_BUILD_NUMBER=/xcode-build-number=/p' macos/Flutter/ephemeral/Flutter-Generated.xcconfig
2026-03-28 20:22:48 +08:00
2026-03-11 15:34:15 +08:00
run : ## Run the app on a device or desktop target (DEVICE=macos by default)
$( FLUTTER) run -d $( DEVICE)
2026-03-27 16:15:27 +08:00
open-macos-xcode : ## Open the supported macOS Xcode workspace entrypoint
open macos/Runner.xcworkspace
2026-03-16 17:58:37 +08:00
build-linux : ## Build the Linux app in release mode
2026-04-13 18:02:30 +08:00
$( FLUTTER) build linux --release --build-name= $( APP_VERSION) --build-number= $( APP_BUILD_NUMBER) $( APP_DART_DEFINE_VERSION) $( APP_DART_DEFINE_BUILD) $( APP_DART_DEFINE_BUILD_DATE) $( APP_DART_DEFINE_BUILD_COMMIT)
2026-03-16 17:58:37 +08:00
2026-03-11 15:34:15 +08:00
build-macos : ## Build the macOS app in release mode
2026-04-13 18:02:30 +08:00
$( FLUTTER) build macos --release $( APP_STORE_DART_DEFINE) --build-name= $( APP_VERSION) --build-number= $( APP_BUILD_NUMBER) $( APP_DART_DEFINE_VERSION) $( APP_DART_DEFINE_BUILD) $( APP_DART_DEFINE_BUILD_DATE) $( APP_DART_DEFINE_BUILD_COMMIT)
2026-03-25 14:03:09 +08:00
bash scripts/check-apple-export-compliance.sh build/macos/Build/Products/Release/XWorkmate.app
2026-03-11 15:34:15 +08:00
build-ios-sim : ## Build the iOS app for the simulator
2026-04-13 18:02:30 +08:00
$( FLUTTER) build ios --simulator $( APP_STORE_DART_DEFINE) --build-name= $( APP_VERSION) --build-number= $( APP_BUILD_NUMBER) $( APP_DART_DEFINE_VERSION) $( APP_DART_DEFINE_BUILD) $( APP_DART_DEFINE_BUILD_DATE) $( APP_DART_DEFINE_BUILD_COMMIT)
2026-03-25 14:03:09 +08:00
bash scripts/check-apple-export-compliance.sh build/ios/iphonesimulator/Runner.app
2026-03-11 15:34:15 +08:00
2026-05-25 08:54:48 +08:00
ios-pods : ## Regenerate the iOS CocoaPods sandbox
cd ios && pod install
ios-pods-check : ios -pods ## Verify Podfile.lock and Pods/Manifest.lock are in sync
cmp -s ios/Podfile.lock ios/Pods/Manifest.lock
build-ios-release-no-codesign : ios -pods -check ## Build the iOS device app in release mode without codesigning
$( FLUTTER) build ios --release --no-codesign $( APP_STORE_DART_DEFINE) --build-name= $( APP_VERSION) --build-number= $( APP_BUILD_NUMBER) $( APP_DART_DEFINE_VERSION) $( APP_DART_DEFINE_BUILD) $( APP_DART_DEFINE_BUILD_DATE) $( APP_DART_DEFINE_BUILD_COMMIT)
verify-ios-release : ios -pods -check build -ios -release -no -codesign analyze ## Regenerate pods, build iOS release without codesigning, and run static analysis
2026-03-16 17:58:37 +08:00
package-deb : ## Create the Linux .deb package
bash scripts/package-linux-deb.sh
package-rpm : ## Create the Linux .rpm package
bash scripts/package-linux-rpm.sh
package-linux : ## Create both Linux packages
bash scripts/package-linux.sh
2026-05-28 13:20:57 +08:00
package-mac : ## Create the macOS .app and DMG
2026-03-23 17:28:54 +08:00
XWORKMATE_APP_STORE = true bash scripts/package-flutter-mac-app.sh
2026-03-11 15:34:15 +08:00
2026-04-18 17:06:34 +08:00
install-mac : package -mac ## Package and install the macOS app into /Applications
2026-03-11 15:34:15 +08:00
bash scripts/install-flutter-mac-dmg.sh
clean : ## Remove generated artifacts
$( FLUTTER) clean
rm -rf build dist
2026-03-14 00:10:27 +08:00
2026-03-25 14:03:09 +08:00
check-export-compliance : ## Verify source and built Apple plist export-compliance flags
bash scripts/check-apple-export-compliance.sh