arcast/Makefile
William Petit 7c75b478a3
All checks were successful
arcad/arcast/pipeline/head This commit looks good
feat(android): use native webview instead of gioui framework
2024-04-29 11:51:45 +02:00

154 lines
5.2 KiB
Makefile

export PATH := $(PATH):$(PWD)/tools/gomobile/bin:$(PWD)/tools/gobind/bin
LINT_ARGS ?= --timeout 5m
GORELEASER_VERSION ?= v1.25.1
GORELEASER_ARGS ?= release --snapshot --clean
GITCHLOG_ARGS ?=
SHELL := /bin/bash
JDK_PATH ?= /usr/lib/jvm/java-11-openjdk
GOARCH ?= amd64
MKT_GITEA_RELEASE_PROJECT := arcast
MKT_GITEA_RELEASE_ORG := arcad
GOTEST_ARGS ?= -short
ANDROID_KEYSTORE_FILE ?= .keystore
ANDROID_KEYSTORE_KEY_ALIAS ?= arcast
export ANDROID_KEYSTORE_PASS ?= NotSoSecret
ANDROID_KEYSTORE_KEY_VALIDITY ?= 365000
ANDROID_BUILD_TOOLS_VERSION ?= 34.0.0
VERSION_CODE ?= $(shell git rev-list HEAD --first-parent --count)
APPS := main
watch: tools/modd/bin/modd deps ## Watching updated files - live reload
( set -o allexport && source .env && set +o allexport && tools/modd/bin/modd )
.PHONY: test
test: test-go ## Executing tests
test-go: deps
( set -o allexport && source .env && set +o allexport && go test -v -count=1 $(GOTEST_ARGS) ./... )
build: build-apps build-desktop build-android build-client ## Build artefacts
build-apps: $(foreach name,$(APPS),build-app-$(name))
build-app-%:
$(MAKE) -C apps/$* build
build-desktop: deps ## Build executable
CGO_ENABLED=0 GOARCH=$(GOARCH) go build \
-v \
-o ./bin/desktop_$(GOARCH) \
./cmd/desktop
build-client: deps ## Build executable
CGO_ENABLED=0 go build \
-v \
-o ./bin/client \
./cmd/client
.PHONY: android/app/libs/arcast.aar
android/app/libs/arcast.aar: tools/gomobile/bin/gomobile tools/gobind/bin/gobind
mkdir -p android/app/libs
gomobile bind -v -javapkg com.cadoles.arcast -target android -o android/app/libs/arcast.aar ./pkg/android
build-android: .mktools android/app/libs/arcast.aar deps ## Build executable
mkdir -p dist
( cd android && VERSION_CODE=$(VERSION_CODE) VERSION_NAME=$(MKT_PROJECT_VERSION)-debug ./gradlew assembleDebug )
$(ANDROID_KEYSTORE_FILE):
keytool -genkey -noprompt \
-alias $(ANDROID_KEYSTORE_KEY_ALIAS) \
-dname "CN=cadoles.com, OU=Dev, O=Cadoles, L=Dijon, S=Bourgogne-FrancheComté, C=FR" \
-keystore "$(ANDROID_KEYSTORE_FILE)" \
-keyalg RSA \
-validity $(ANDROID_KEYSTORE_KEY_VALIDITY) \
-storepass "$(ANDROID_KEYSTORE_PASS)"
release-android: deps .mktools android/app/libs/arcast.aar $(ANDROID_KEYSTORE_FILE) ## Build executable
mkdir -p dist
( cd android && VERSION_CODE=$(VERSION_CODE) VERSION_NAME=$(MKT_PROJECT_VERSION) ./gradlew assemble )
rm -f android/app/build/outputs/apk/release/app-release-unsigned-aligned.apk
"$(ANDROID_HOME)/build-tools/$(ANDROID_BUILD_TOOLS_VERSION)/zipalign" -p 4 android/app/build/outputs/apk/release/app-release-unsigned.apk android/app/build/outputs/apk/release/app-release-unsigned-aligned.apk
"$(ANDROID_HOME)/build-tools/$(ANDROID_BUILD_TOOLS_VERSION)/apksigner" \
sign \
--ks-key-alias $(ANDROID_KEYSTORE_KEY_ALIAS) \
--ks "$(ANDROID_KEYSTORE_FILE)" \
--ks-pass env:ANDROID_KEYSTORE_PASS \
--in android/app/build/outputs/apk/release/app-release-unsigned-aligned.apk \
--out android/app/build/outputs/apk/release/app-release.apk
install-android: build-apps build-android
adb uninstall com.cadoles.arcast_player
adb install android/app/build/outputs/apk/debug/app-debug.apk
$(MAKE) run-android
run-android:
adb shell am force-stop com.cadoles.arcast_player
adb shell monkey -p com.cadoles.arcast_player -c android.intent.category.LAUNCHER 1
debug-android:
adb logcat -s 'com.cadoles.arcast_player:* GoLog:* s.arcast_player:* com.cadoles.forge.mobile:*'
.env:
cp -f .env.dist .env
run: .env
( set -o allexport && source .env && set +o allexport && $(RUN_CMD))
.PHONY: deps
deps: .env
tools/modd/bin/modd:
mkdir -p tools/modd/bin
GOBIN=$(PWD)/tools/modd/bin go install github.com/cortesi/modd/cmd/modd@latest
release: gitea-release
gitea-release: .mktools build-apps goreleaser release-android
rm -rf .gitea-release
mkdir -p .gitea-release
cp ./dist/*.apk .gitea-release/
cp ./dist/*.deb .gitea-release/
cp ./dist/*.tar.gz .gitea-release/
cp ./android/app/build/outputs/apk/release/app-release.apk .gitea-release/arcast_player_$(MKT_PROJECT_VERSION)_android.apk
MKT_GITEA_RELEASE_PROJECT="arcast" \
MKT_GITEA_RELEASE_ORG="arcad" \
MKT_GITEA_RELEASE_BASE_URL="https://forge.cadoles.com" \
MKT_GITEA_RELEASE_VERSION="$(MKT_PROJECT_VERSION)" \
MKT_GITEA_RELEASE_NAME="$(MKT_PROJECT_VERSION)" \
MKT_GITEA_RELEASE_COMMITISH_TARGET="$$(git rev-parse HEAD)" \
MKT_GITEA_RELEASE_IS_DRAFT="false" \
MKT_GITEA_RELEASE_IS_PRERELEASE="false" \
MKT_GITEA_RELEASE_BODY="" \
MKT_GITEA_RELEASE_ATTACHMENTS="$$(find .gitea-release/* -type f)" \
$(MAKE) mkt-gitea-release
.PHONY: goreleaser
goreleaser: .env .mktools
( set -o allexport && source .env && set +o allexport && curl -sfL https://goreleaser.com/static/run | VERSION=$(GORELEASER_VERSION) GORELEASER_CURRENT_TAG="$(MKT_PROJECT_VERSION)" GOPATH=$(shell go env GOPATH) bash /dev/stdin $(GORELEASER_ARGS) )
tools/gomobile/bin/gomobile:
mkdir -p tools/gomobile/bin
GOBIN=$(PWD)/tools/gomobile/bin go install golang.org/x/mobile/cmd/gomobile@latest
tools/gobind/bin/gobind:
mkdir -p tools/gobind/bin
GOBIN=$(PWD)/tools/gobind/bin go install golang.org/x/mobile/cmd/gobind@latest
.PHONY: mktools
mktools:
rm -rf .mktools
curl -q https://forge.cadoles.com/Cadoles/mktools/raw/branch/master/install.sh | $(SHELL)
.mktools:
$(MAKE) mktools
-include .mktools/*.mk