Skip to content

Commit 9983c07

Browse files
authored
build: Improve speed of find commands in Makefile (#5463)
1 parent 5a786ed commit 9983c07

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Makefile

+11-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,17 @@ else
4444
ZSTDFLAGS := -6
4545
endif
4646

47+
# Common paths to exclude from find commands, this rule is written so
48+
# that it can be it can be used in a chain of AND statements (meaning
49+
# you can simply write `find . $(FIND_EXCLUSIONS) -name thing-i-want`).
50+
# Note, all find statements should be written with `.` or `./path` as
51+
# the search path so that these exclusions match.
52+
FIND_EXCLUSIONS= \
53+
-not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path '*/node_modules/*' -o -path './site/out/*' \) -prune \)
4754
# Source files used for make targets, evaluated on use.
48-
GO_SRC_FILES = $(shell find . -not \( -path './.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path './site/node_modules/*' -o -path './site/out/*' \) -type f -name '*.go')
55+
GO_SRC_FILES = $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go')
4956
# All the shell files in the repo, excluding ignored files.
50-
SHELL_SRC_FILES = $(shell find . -not \( -path './.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path './site/node_modules/*' -o -path './site/out/*' \) -type f -name '*.sh')
57+
SHELL_SRC_FILES = $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.sh')
5158

5259
# All ${OS}_${ARCH} combos we build for. Windows binaries have the .exe suffix.
5360
OS_ARCHES := \
@@ -341,7 +348,7 @@ build/coder_helm_$(VERSION).tgz:
341348
--version "$(VERSION)" \
342349
--output "$@"
343350

344-
site/out/index.html: site/package.json $(shell find ./site -not -path './site/node_modules/*' -type f \( -name '*.ts' -o -name '*.tsx' \))
351+
site/out/index.html: site/package.json $(shell find ./site $(FIND_EXCLUSIONS) -type f \( -name '*.ts' -o -name '*.tsx' \))
345352
./scripts/yarn_install.sh
346353
cd site
347354
yarn build
@@ -447,7 +454,7 @@ provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto
447454
--go-drpc_opt=paths=source_relative \
448455
./provisionerd/proto/provisionerd.proto
449456

450-
site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk -type f -name '*.go')
457+
site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
451458
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
452459
cd site
453460
yarn run format:types

0 commit comments

Comments
 (0)