forked from naskya/firefish
dev: run make recipes only when needed
This commit is contained in:
parent
7d5e062a21
commit
79be37ea47
2 changed files with 30 additions and 7 deletions
33
Makefile
33
Makefile
|
@ -1,3 +1,5 @@
|
||||||
|
T := dev/make_virtual_target
|
||||||
|
|
||||||
PACKAGE_JSONS := package.json
|
PACKAGE_JSONS := package.json
|
||||||
PACKAGE_JSONS += packages/backend/package.json
|
PACKAGE_JSONS += packages/backend/package.json
|
||||||
PACKAGE_JSONS += packages/client/package.json
|
PACKAGE_JSONS += packages/client/package.json
|
||||||
|
@ -13,19 +15,28 @@ RUSTY_STUFF := $(foreach dir, $(RUST_DIR)/src, $(wildcard $(dir)/*))
|
||||||
RUSTY_STUFF += $(foreach dir, $(RUST_DIR)/migration/src, $(wildcard $(dir)/*))
|
RUSTY_STUFF += $(foreach dir, $(RUST_DIR)/migration/src, $(wildcard $(dir)/*))
|
||||||
RUSTY_STUFF += $(CARGO_TOMLS)
|
RUSTY_STUFF += $(CARGO_TOMLS)
|
||||||
|
|
||||||
|
MIGRATIONS := $(foreach dir, packages/backend/migration, $(wildcard $(dir)/*))
|
||||||
|
MIGRATIONS += $(foreach dir, packages/backend/migration-neko, $(wildcard $(dir)/*))
|
||||||
|
MIGRATIONS += $(foreach dir, $(RUST_DIR)/migration/src, $(wildcard $(dir)/*))
|
||||||
|
|
||||||
|
UPDATE_SCRIPTS := update.sh
|
||||||
|
UPDATE_SCRIPTS += $(foreach dir, neko/update, $(wildcard $(dir)/*))
|
||||||
|
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: build-image
|
build: build-image
|
||||||
|
|
||||||
|
|
||||||
.PHONY: pre-commit
|
.PHONY: pre-commit
|
||||||
pre-commit: shellcheck pnpm-lock.yaml $(RUST_DIR)/Cargo.lock regenerate-entities neko/index.js rust-lint
|
pre-commit: shellcheck update-lockfiles regenerate-entities neko/index.js rust-lint
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: update-lockfiles
|
||||||
|
update-lockfiles: pnpm-lock.yaml $(RUST_DIR)/Cargo.lock
|
||||||
|
|
||||||
pnpm-lock.yaml: pnpm-workspace.yaml $(PACKAGE_JSONS)
|
pnpm-lock.yaml: pnpm-workspace.yaml $(PACKAGE_JSONS)
|
||||||
pnpm install
|
pnpm install
|
||||||
|
|
||||||
|
|
||||||
$(RUST_DIR)/Cargo.lock: $(CARGO_TOMLS)
|
$(RUST_DIR)/Cargo.lock: $(CARGO_TOMLS)
|
||||||
cd $(RUST_DIR) && cargo update
|
cd $(RUST_DIR) && cargo update
|
||||||
|
|
||||||
|
@ -39,18 +50,25 @@ debug:
|
||||||
|
|
||||||
|
|
||||||
.PHONY: shellcheck
|
.PHONY: shellcheck
|
||||||
shellcheck:
|
shellcheck: $(T)/shellcheck
|
||||||
shellcheck --external-sources update.sh
|
|
||||||
shellcheck --external-sources neko/update/*
|
$(T)/shellcheck: $(UPDATE_SCRIPTS)
|
||||||
|
shellcheck --external-sources $^
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
|
||||||
.PHONY: rust-lint
|
.PHONY: rust-lint
|
||||||
rust-lint:
|
rust-lint: $(T)/rust-lint
|
||||||
|
|
||||||
|
$(T)/rust-lint:
|
||||||
cd $(RUST_DIR) && pnpm run lint
|
cd $(RUST_DIR) && pnpm run lint
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
|
||||||
.PHONY: regenerate-entities
|
.PHONY: regenerate-entities
|
||||||
regenerate-entities:
|
regenerate-entities: $(T)/regenerate-entities
|
||||||
|
|
||||||
|
$(T)/regenerate-entities: $(MIGRATIONS)
|
||||||
pnpm run migrate
|
pnpm run migrate
|
||||||
cd $(RUST_DIR) && \
|
cd $(RUST_DIR) && \
|
||||||
sea-orm-cli generate entity \
|
sea-orm-cli generate entity \
|
||||||
|
@ -66,6 +84,7 @@ regenerate-entities:
|
||||||
done
|
done
|
||||||
sed -i 's/#\[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)\]/#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]\n#[napi_derive::napi]/' \
|
sed -i 's/#\[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)\]/#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]\n#[napi_derive::napi]/' \
|
||||||
$(RUST_DIR)/src/model/entity/sea_orm_active_enums.rs
|
$(RUST_DIR)/src/model/entity/sea_orm_active_enums.rs
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
|
||||||
neko/index.js: $(RUSTY_STUFF)
|
neko/index.js: $(RUSTY_STUFF)
|
||||||
|
|
4
dev/make_virtual_target/.gitignore
vendored
Normal file
4
dev/make_virtual_target/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
Loading…
Reference in a new issue