forked from RandyMcMillan/gnostr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
206 lines (171 loc) · 11 KB
/
Makefile
File metadata and controls
206 lines (171 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
ACT_VERBOSE ?=
ACT_BIND ?= --bind
ACT_USE_NEW_ACTION_CACHE ?= ${ACT_BIND}
export HOMEBREW_NO_INSTALL_CLEANUP=1
ifeq ($(TAG),)
TAG := v$(shell cat Cargo.toml | grep 'version = "' | head -n 1 | sed 's/version = "\(.*\)".*/\1/')
endif
export TAG
ifeq ($(NPROC),)
NPROC := $(shell sysctl -n hw.logicalcpu 2>/dev/null || nproc 2>/dev/null || echo 1)
endif
export NPROC
JFLAGS := -j$(NPROC)
ifeq ($(FORCE),)
FORCE :=-f
endif
export FORCE
help:
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?##/ {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo
rm_cargo_lock: ### rm_cargo_lock
rm /Users/git/.cache/cargo/debug/.cargo-lock 2>/dev/null || true
##
##===============================================================================
##all
## bin
all: bin### all
##bin
## cargo b -j $(NPROC)
bin: ### bin
bash ./scripts/with-system-rocksdb.sh cargo b -j $(NPROC)
##
##===============================================================================
##make cargo-*
cargo-help: ### cargo-help
@awk 'BEGIN {FS = ":.*?###"} /^[a-zA-Z_-]+:.*?###/ {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
cargo-release-all: ### cargo-release-all
## cargo-release-all recursively cargo build --release
for t in **Cargo.toml; do echo $$t; cargo b -r -j $(NPROC) -vv --manifest-path $$t; done
cargo-clean-release: ### cargo-clean-release - clean release artifacts
## cargo-clean-release recursively cargo clean --release
for t in **Cargo.toml; do echo $$t && cargo clean -r -j $(NPROC) -vv --manifest-path $$t 2>/dev/null; done
cargo-publish-all: ### cargo-publish-all
## cargo-publish-all recursively publish rust projects
for t in *Cargo.toml; do echo $$t; cargo publish -j $(NPROC) -vv --manifest-path $$t; done
cargo-install-bins:### cargo-install-bins
## cargo-install-all recursively cargo install -vv $(SUBMODULES)
## *** cargo install -vv --force is NOT used.
## *** FORCE=--force cargo install -vv $(FORCE) is used.
## *** FORCE=--force cargo install -vv $(FORCE) --path <path>
## *** to overwrite deploy cargo.io crates.
export RUSTFLAGS=-Awarning; for t in $(SUBMODULES); do echo $$t; cargo -j $(NPROC) install --bins --path $$t -vv $(FORCE) 2>/dev/null || echo ""; done
#for t in $(SUBMODULES); do echo $$t; cargo install -j $(NPROC) -vv gnostr-$$t --force || echo ""; done
cargo-build: ## cargo build
## cargo-build q=true
@. $(HOME)/.cargo/env
@RUST_BACKTRACE=all bash ./scripts/with-system-rocksdb.sh cargo b -j $(NPROC) $(QUIET)
cargo-install: ### cargo install --path . $(FORCE)
@. $(HOME)/.cargo/env
@cargo install -j $(NPROC) --path ./bins $(FORCE)
@cargo install -j $(NPROC) --path . $(FORCE)
cargo-sort: cargo-sort
for cargo_toml in $(shell ls */Cargo.toml); do cargo sort -n $(cargo_toml);done
## cargo-br q=true
cargo-build-release: ### cargo-build-release
## cargo-build-release q=true
@. $(HOME)/.cargo/env
@bash ./scripts/with-system-rocksdb.sh cargo b -r -j $(NPROC) $(QUIET)
cargo-check: ### cargo-check
@. $(HOME)/.cargo/env
@bash ./scripts/with-system-rocksdb.sh cargo c -j $(NPROC)
cargo-bench: ### cargo-bench
@. $(HOME)/.cargo/env
@bash ./scripts/with-system-rocksdb.sh cargo bench -j $(NPROC)
cargo-test: ### cargo-test
@. $(HOME)/.cargo/env
#@cargo test
bash ./scripts/with-system-rocksdb.sh cargo test -j $(NPROC)
cargo-test--ignored: ### cargo-test--ignored
@. $(HOME)/.cargo/env
#@cargo test
bash ./scripts/with-system-rocksdb.sh cargo test -j $(NPROC) -- --ignored --nocapture
cargo-test-workspace: ### cargo-test-workspace
@. $(HOME)/.cargo/env
#@cargo test
bash ./scripts/with-system-rocksdb.sh cargo test -j $(NPROC) --workspace
test: cargo-test-workspace
cargo-test-nightly: ### cargo-test-nightly
@. $(HOME)/.cargo/env
#@cargo test
bash ./scripts/with-system-rocksdb.sh cargo +nightly test -j $(NPROC)
cargo-test-nightly-workspace: ### cargo-test-nightly-workspace
@. $(HOME)/.cargo/env
#@cargo test
bash ./scripts/with-system-rocksdb.sh cargo +nightly test -j $(NPROC) --workspace
cargo-test-types-nip_three_four: ### cargo-test-types-nip34
@. $(HOME)/.cargo/env
#@cargo test
bash ./scripts/with-system-rocksdb.sh cargo test -j $(NPROC) -p gnostr -- --test-threads=1 --test types::nip34
cargo-clippy-workspace: ### cargo-clippy-workspace
bash ./scripts/with-system-rocksdb.sh cargo +nightly clippy --workspace --all-targets -- -D warnings
bash ./scripts/with-system-rocksdb.sh cargo +nightly clippy --workspace --all-targets --all-features -- -D warnings
cargo-clippy-fix-workspace: ### cargo-clippy-fix-workspace
bash ./scripts/with-system-rocksdb.sh cargo +nightly clippy --allow-dirty --fix --workspace --all-targets -- -D warnings
bash ./scripts/with-system-rocksdb.sh cargo +nightly clippy --allow-dirty --fix --workspace --all-targets --all-features -- -D warnings
clippy: cargo-clippy-workspace
cargo-report: ### cargo-report
@. $(HOME)/.cargo/env
cargo report future-incompatibilities --id 1 -j $(NPROC)
cargo-run: ### cargo-run
@. $(HOME)/.cargo/env
bash ./scripts/with-system-rocksdb.sh cargo run -j $(NPROC) --bin gnostr -- -h
##===============================================================================
cargo-git-cliff-changelog: ### cargo-git-cliff-changelog
git-cliff --output CHANGELOG.md || cargo install git-cliff
dep-graph: ### dep-graph
@cargo depgraph --depth 1 | dot -Tpng > graph.png || brew install graphviz || cargo install cargo-depgraph
gnostr-chat: ## gnostr-chat
/Users/git/.cargo/bin/gnostr chat --topic gnostr-dev --headless & cargo b -vv -j $(NPROC) --bin gnostr
cargo run --bin gnostr -- chat --topic gnostr-dev --name "$(shell gnostr --weeble)/$(shell gnostr --blockheight)/$(shell gnostr --wobble):$(USER)" --headless
cargo run --bin gnostr -- chat --topic gnostr-dev --oneshot "testing-1873/949100/939485" -n "a0b5322afbb030d7c3c8d9c63bc05fb133843d319efaab413da4180d2b4a9c3d"
cargo run --bin gnostr -- chat --topic gnostr-dev --name "$(shell gnostr --weeble)/$(shell gnostr --blockheight)/$(shell gnostr --wobble):$(USER)"
fetch-by-id: ### fetch-by-id
cargo -j $(NPROC) install --bin gnostr-fetch-by-id --path .
event_id=$(shell gnostr note -c test --hex | jq .id | sed "s/\"//g") && gnostr-fetch-by-id $;
fetch-by-kind-and-author: ### fetch-by-kind-and-author
cargo -j $(NPROC) install --bin fetch_by_kind-and-author --path .
cargo -j $(NPROC) install --bin fetch_by_kind_and_author --path .
fetch_by_kind_and_author wss://relay.nostr.band 1 a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd
gnostr-note-debug: ### gnostr-note-debug
@gnostr --debug --hash "" note -c "gnostr --debug" --hex -s "gnostr --debug subject" --ptag a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd --etag 8bd85322d47f896c1cc4b20887b08513a0c6065b997debe7f4e87cc949ee7686 -t "gnostr--debug|tag" --verbose --expiration 144000
gnostr-note-trace: ### gnostr-note-debug
@gnostr --trace --hash "" note -c "gnostr --trace" --hex -s "gnostr --trace subject" --ptag a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd --etag 8bd85322d47f896c1cc4b20887b08513a0c6065b997debe7f4e87cc949ee7686 -t "gnostr--trace|tag" --verbose --expiration 144000
post_event: ### post_event
cat tests/events/json/first-gnostr-commit.json | post_event wss://relay.nostr.band
post_from_files: ### post_from_files
post_from_files ./tests/events/json wss://relay.nostr.band
broadcast_event_list: ### nip-0034-events syndication example
@RUST_LOG=debug gnostr --debug list-events -k 30617 -k 30618 -k 1617 -k 1621 -k 1630 -k 1631 -k 1632 -k 1633 -o nip-0034.json && gnostr --debug --nsec $(shell gnostr-sha256) broadcast-events -f ./nip-0034.json
nip_thirty_four_requests: ### nip_thirty_four_requests
@echo '["REQ","nip-0034",{"kinds":[1630,1632,1621,30618,1633,1631,1617,30617]}]' | gnostr-cat -k -t -n -B 210000 wss://relay.nostr.band | jq
plan-dist-manifest: ### plan-dist-manifest
dist host --allow-dirty --steps=create --tag=$(TAG) --output-format=json | sed 's/windows-2019/windows-latest/g' | sed 's/ubuntu-20.04/ubuntu-latest/g' > plan-dist-manifest.json
docker: ### gnostr in a docker container
docker buildx build . -t gnostr:latest && docker run -it gnostr:latest -c "git init && git config --global init.defaultBranch gnostr && gnostr chat --name gnostr-docker-$(shell gnostr-wobble) --topic gnostr"
docker-tui: ### gnostr tui in a docker container
docker buildx build . -t gnostr:latest && docker run -it gnostr:latest -c "git init && git config --global init.defaultBranch gnostr && gnostr tui --gitdir ."
docker-chat: ### gnostr chat in a docker container
docker buildx build . -t gnostr:latest && docker run -it gnostr:latest -c "git init && git config --global init.defaultBranch gnostr && gnostr chat --name gnostr-docker-$(shell gnostr-wobble) --topic gnostr"
docker-shared: ### docker container with volumes
docker buildx build . -t gnostr:latest && docker run -it --privileged -v /Users/Shared:/Users/Shared -v /Users/git:/Users/git gnostr:latest
gh-act-run-all: ### gh-act-run-all
gh extension install nektos/gh-act || true
gh act ${ACT_VERBOSE} ${ACT_USE_NEW_ACTION_CACHE} -W .github/workflows/run-all-workflows.yml --container-architecture linux/amd64 || act ${ACT_VERBOSE} ${ACT_USE_NEW_ACTION_CACHE} -W .github/workflows/run-all-workflows.yml --container-architecture linux/amd64
gnostr-test-matrix: ### gnostr-test-matrix
gh extension install nektos/gh-act || true
gh act ${ACT_VERBOSE} ${ACT_USE_NEW_ACTION_CACHE} -W .github/workflows/gnostr-test-matrix.yml --container-architecture linux/amd64 || act ${ACT_VERBOSE} ${ACT_USE_NEW_ACTION_CACHE} -W .github/workflows/gnostr-test-matrix.yml --container-architecture linux/amd64
gnostr-test-macos: ### gnostr-test-macos
gh extension install nektos/gh-act || true
gh act ${ACT_VERBOSE} ${ACT_USE_NEW_ACTION_CACHE} -W .github/workflows/gnostr-test-matrix.yml -P macos-latest=-self-hosted --container-architecture linux/amd64 || act ${ACT_VERBOSE} ${ACT_USE_NEW_ACTION_CACHE} -W .github/workflows/gnostr-test-matrix.yml -P macos-latest=-self-hosted --container-architecture linux/amd64
gnostr-test-macos-intel: ### gnostr-test-macos
gh extension install nektos/gh-act || true
gh act ${ACT_VERBOSE} ${ACT_USE_NEW_ACTION_CACHE} -W .github/workflows/gnostr-test-matrix.yml -P macos-15-intel=-self-hosted --container-architecture linux/amd64 || act ${ACT_VERBOSE} ${ACT_USE_NEW_ACTION_CACHE} -W .github/workflows/gnostr-test-matrix.yml -P macos-15-intel=-self-hosted --container-architecture linux/amd64
act-cargo-cross-setup: ### acto-cargo-cross-setup
act -W .github/workflows/cargo-cross.yml -j setup --container-architecture linux/amd64 -P ubuntu-latest=catthehacker/ubuntu:full-latest
act-cargo-cross: ### acto-cargo-cross
act -W .github/workflows/cargo-cross.yml --container-architecture linux/amd64 -P ubuntu-latest=catthehacker/ubuntu:full-latest
act-gnostr-act: ## act-gnostr-act
docker build -t gnostr-act -f ./docker/Dockerfile.gnostr . && act -W .github/workflows/cargo-cross.yml -j setup --container-architecture linux/amd64 -P ubuntu-latest=gnostr-act
# vim: set noexpandtab:
# vim: set setfiletype make