Skip to content

Commit 9fa5cd2

Browse files
committed
wb | rewrite Make shell targets as explicit static rules, drop jq
- Replace the eval/call/foreach "proftgt" code generation with one literal greppable stanza per profile variant. - Make everything explicit: per-variant ARG_*_YES/NO --arg fragments. - Drop jq and the "nix build && cat result" dance from list-profiles / show-profile / ps. - Move the workbench Make code to nix/workbench/.
1 parent 7a4cbce commit 9fa5cd2

6 files changed

Lines changed: 318 additions & 125 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ generation workload -- using the `workbench` environment:
113113
Nix or downloaded from Hydra CI cache directly.
114114
- `-prof` and `-profnix` suffixes -- same as both before, but all
115115
binaries will be built such that GHC profiling is enabled.
116-
- ...there are other modes as per
117-
[lib.mk](https://github.com/intersectmbo/cardano-node/tree/master/lib.mk#L34-L44)
116+
- ...there are other modes (`-auto`, `-autostay`, `-autonix`, `-nomadexec`, ...); see
117+
[nix/workbench/lib.mk](https://github.com/intersectmbo/cardano-node/blob/master/nix/workbench/lib.mk)
118118

119119
3. Enter the workbench shell for the chosen profile & mode:
120120
`make <PROFILE-NAME>` or `make <PROFILE-NAME>-<SUFFIX>` (when there

Makefile

Lines changed: 25 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
help: ## Print documentation
2-
@{ grep -hE '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST); echo -e '$(EXTRA_HELP)'; } | sed 's/^ //' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-33s\033[0m %s\n", $$1, $$2}'
2+
@grep -hE '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sed 's/^ //' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-33s\033[0m %s\n", $$1, $$2}'
33

4-
include lib.mk
54
include nix.mk
65

76
PROJECT_NAME = cardano-node
87
NUM_PROC = $(nproc --all)
98

10-
PROFILE ?= default
11-
## One of: shelley allegra mary alonzo babbage conway dijkstra
12-
ERA ?= conway
13-
BACKEND ?= supervisor
14-
REV ?= master
15-
ITER ?=
16-
BATCH ?=
17-
ARGS ?=
18-
CMD ?=
19-
RUN ?=
20-
219
lint hlint: ## Run the CI version of hlint
2210
nix build --no-link '.#checks/hlint' --cores 0
2311
haddock-hoogle haddocks hoogle:
@@ -50,75 +38,46 @@ trace-schemas-validate: ## Validate trace message schemas against meta.schema.js
5038
nix run .#validate-trace-schemas
5139

5240
###
53-
### Workbench
41+
### Workbench: cluster shells
5442
###
43+
## `make shell` (and -nix/-prof/-dev) opens a workbench dev shell for $(PROFILE) -- the usual
44+
## entry point (below). `make <profile>[-VARIANT]` are per-profile aliases; `make ps` lists
45+
## profile names. Targets, flags and the (generated) profile lists all live in
46+
## nix/workbench/lib.mk (which pulls in profiles.mk itself).
47+
include nix/workbench/lib.mk
48+
49+
## Dev shells -- the usual entry point; each runs $(WB_ENTER) (defined in nix/workbench/lib.mk).
50+
shell: ## workbench dev shell for PROFILE (cabal build-on-demand); vars: PROFILE ERA BACKEND CMD RUN
51+
$(WB_ENTER)
52+
shell-nix: ## like shell, but run the Nix-store binary
53+
$(WB_ENTER) --arg useCabalRun false
54+
shell-prof: ## like shell, profiled build, run with -hT
55+
$(WB_ENTER) --arg profiledBuild true --arg profilingType '"space-heap"'
56+
shell-dev:
57+
$(WB_ENTER)
58+
.PHONY: shell shell-nix shell-prof shell-dev
59+
60+
## CI entrypoints (drive the generated variant targets + Nix ci-test):
5561
workbench-ci: workbench-ci-test ci-test-auto ci-test-autonix
5662
CI_TARGETS := hlint workbench-ci haddock-hoogle
5763
ci: ci-report ci-targets
5864
ci-report:
5965
@echo -e "\033[34mGoals under test\033[0m: \033[33m$(CI_TARGETS)\033[0m"
6066
ci-targets: $(CI_TARGETS)
6167

62-
workbench-internals-walkthrough:
63-
emn nix/workbench/doc.org
64-
65-
# Alias for removed profiles: inject RTS -hT (space-heap) heap profile + -l (eventlog) as shell parameters on a NON-profiled build.
66-
# Neither -hT nor -l needs a profiled runtime, so delegate to the base target, not -prof (a -prof target hardcodes --arg profiledBuild true).
67-
6-dense-rtsprof:
68-
WB_PROFILING="space-heap+eventlog" $(MAKE) 6-dense
69-
6-dense-1h-rtsprof:
70-
WB_PROFILING="space-heap+eventlog" $(MAKE) 6-dense-1h
71-
6-dense-4h-rtsprof:
72-
WB_PROFILING="space-heap+eventlog" $(MAKE) 6-dense-4h
73-
74-
##
75-
## Base targets:
76-
##
77-
shell: ## Nix shell, (workbench from /nix/store), vars: PROFILE, ERA, CMD, RUN
78-
nix-shell -A 'workbench-shell' --max-jobs 8 --cores 0 --show-trace --argstr profileName ${PROFILE} --argstr eraName ${ERA} --argstr backendName ${BACKEND} ${ARGS} ${if ${CMD},--command "${CMD}"} ${if ${RUN},--run "${RUN}"}
79-
shell-dev shell-prof shell-nix: shell
80-
shell-nix: ARGS += --arg 'useCabalRun' false ## Nix shell, (workbench from Nix store), vars: PROFILE, CMD, RUN
81-
shell-prof: ARGS += --arg 'profiledBuild' true --arg 'profilingType' '"space-heap"' ## Nix shell, everything Haskell built profiled and run with `-hT`.
82-
83-
analyse: RUN := wb analyse std ${TAG}
84-
analyse: shell
85-
86-
list-profiles: ## List workbench profiles
87-
nix build .#all-profiles-json && cat result
88-
show-profile: ## NAME=profile-name
89-
@test -n "${NAME}" || { echo 'HELP: to specify profile to show, add NAME=profle-name' && exit 1; }
90-
nix build .#all-profiles-json --json --option substitute false | jq '.[0].outputs.out' -r | xargs jq ".\"${NAME}\" | if . == null then error(\"\n###\n### Error: unknown profile: ${NAME} Please consult: make list-profiles\n###\") else . end"
91-
ps: ## Plain-text list of profiles
92-
@nix build .#workbench.profile-names-json --json | jq '.[0].outputs.out' -r | xargs jq '.[]' --raw-output
93-
94-
##
95-
## Profile-based cluster shells (autogenerated targets)
96-
##
97-
## wb_profiles.mk is autogenerated by `cardano-profile lib-make`. It contains all known profile families and flavours (minus the era, backend and shell type suffixes).
98-
## After adding or removing profile definitions in `cardano-profile`, you'll probably want to also commit a regenerated version of that file.
99-
##
100-
include wb_profiles.mk
101-
102-
$(eval $(call define_profile_targets, $(LOCAL_PROFILES)))
103-
$(eval $(call define_profile_targets_nomadcloud,$(CLOUD_PROFILES)))
104-
105-
# Dynamic local/supervisor profile targets.
106-
playground-%:
107-
nix-shell -A 'workbench-shell' --max-jobs 8 --cores 0 --show-trace --argstr profileName $* --argstr eraName ${ERA} --argstr backendName supervisor
108-
10968
###
11069
### Misc
11170
###
112-
clean-profile proclean:
113-
rm -f *.html *.prof *.hp *.stats *.eventlog
114-
11571
clean: clean-profile
116-
rm -rf logs/ socket/ cluster.*
11772

11873
full-clean: clean
11974
rm -rf db dist-newstyle $(shell find . -name '*~' -or -name '*.swp')
12075

12176
cls:
12277
echo -en "\ec"
12378

124-
.PHONY: cabal-hashes clean cli cls cluster-profiles help node run-test shell shell-dev stylish-haskell $(LOCAL_PROFILES) workbench-ci-test
79+
.PHONY: help lint hlint host-hlint haddock-hoogle stylish-haskell cabal-hashes cli node \
80+
trace-documentation trace-schemas-regenerate trace-schemas-overrides-check \
81+
trace-schemas-overrides-coverage trace-schemas-validate \
82+
workbench-ci ci ci-report ci-targets \
83+
clean full-clean cls

lib.mk

Lines changed: 0 additions & 52 deletions
This file was deleted.

nix/workbench/doc.org

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
* Key entry/intermediate points
22
*** =Makefile= /convenience/
3-
- all workbench shell targets [[file:~/cardano-node/Makefile::$(eval $(call define_profile_targets,$(SHELL_PROFILES)))]]
4-
- define_profile_targets [[file:~/cardano-node/lib.mk::define define_profile_targets]]
5-
- proftgt [[file:~/cardano-node/lib.mk::$(1): shell]]
6-
- shell [[file:~/cardano-node/Makefile::shell: ## Nix shell, (workbench from /nix/store), vars: PROFILE, CMD, RUN]]
7-
- =Makefile= -> Nix =workbench-shell= [[file:~/cardano-node/Makefile::nix-shell -A 'workbench-shell' --max-jobs 8 --cores 0 --show-trace --argstr profileName ${PROFILE} --argstr backendName ${BACKEND} ${ARGS} ${if ${CMD},--command "${CMD}"} ${if ${RUN},--run "${RUN}"}]]
3+
- workbench shell targets live in [[file:lib.mk::## Workbench shell targets.]]
4+
- pulled in by the top-level [[file:~/cardano-node/Makefile::include nix/workbench/lib.mk]]
5+
- per-profile variant targets are static pattern rules [[file:lib.mk::## ---- variant stanzas]]
6+
- generic entry: the =shell= target [[file:lib.mk::shell: ## Workbench dev shell]]
7+
- =lib.mk= -> Nix =workbench-shell= via =WB_ENTER= [[file:lib.mk::WB_ENTER = nix-shell -A 'workbench-shell']]
88
*** =start-cluster= /shell script available inside workbench shell/
99
- workbench-interactive-start [[file:backend/runner.nix::workbench-interactive-start = pkgs.writeScriptBin "start-cluster" '']]
1010
*** =workbench-shell= /Nix attribute implementing the workbench shell/

0 commit comments

Comments
 (0)