diff options
author | Loïc Hoguin <[email protected]> | 2024-06-21 15:43:14 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2024-06-21 15:43:14 +0200 |
commit | 396761469b69f7a328343cdd1b2d18d8b5552f83 (patch) | |
tree | 7ef8ca6786461abfe097f2288d10143732e743c0 | |
parent | e4cc2f00fe85ad9f59a09ffc2d74c6cb5252816a (diff) | |
download | erlang.mk-396761469b69f7a328343cdd1b2d18d8b5552f83.tar.gz erlang.mk-396761469b69f7a328343cdd1b2d18d8b5552f83.tar.bz2 erlang.mk-396761469b69f7a328343cdd1b2d18d8b5552f83.zip |
Don't use the shell in core_find
Instead of calling `find` we use $(wildcard ...) and some
logic on top to find all the files we are looking for.
This is more efficient and greatly helps reduce re-build
times when there's little to be done, particularly when
many dependencies are involved.
-rw-r--r-- | core/core.mk | 5 | ||||
-rw-r--r-- | test/core_makedep.mk | 20 | ||||
-rw-r--r-- | test/core_query.mk | 2 |
3 files changed, 24 insertions, 3 deletions
diff --git a/core/core.mk b/core/core.mk index 250a2eb..dde4f86 100644 --- a/core/core.mk +++ b/core/core.mk @@ -184,8 +184,9 @@ core_http_get = curl -Lf$(if $(filter-out 0,$(V)),,s)o $(call core_native_path,$ core_eq = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1))) -# We skip files that contain spaces or '#' because they end up causing issues. -core_find = $(if $(wildcard $1),$(shell find $(1:%/=%) \( -type l -o -type f \) -name $(subst *,\*,$2) -not -name "*[ \#]*")) +# We skip files that contain spaces because they end up causing issues. +# Files that begin with a dot are already ignored by the wildcard function. +core_find = $(foreach f,$(wildcard $(1:%/=%)/*),$(if $(wildcard $f/.),$(call core_find,$f,$2),$(if $(filter $(subst *,%,$2),$f),$(if $(wildcard $f),$f)))) core_lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$(1))))))))))))))))))))))))))) diff --git a/test/core_makedep.mk b/test/core_makedep.mk index f2ab860..077df6b 100644 --- a/test/core_makedep.mk +++ b/test/core_makedep.mk @@ -25,6 +25,26 @@ core-makedep-behavior: init $t test -f $(APP)/ebin/boy.beam $t test -f $(APP)/ebin/human.beam +core-makedep-ignore-filenames-with-spaces: init + + $i "Bootstrap a new OTP library named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v + $t mkdir $(APP)/src/core + + $i "Generate related .erl files" + $t printf "%s\n" "-module(human)." "-export([live/0])." "live() -> ok." > $(APP)/src/core/human.erl + $t printf "%s\n" "-module(boy)." "-import(human,[live/0])." > $(APP)/src/boy.erl + $t printf "%s\n" "-module(boy)." "-import(human,[live/0])." > $(APP)/src/my\ boy.erl + $t $(MAKE) -C $(APP) $v + + $i "Check that all compiled files exist" + $t test -f $(APP)/$(APP).d + $t test -f $(APP)/ebin/$(APP).app + $t test -f $(APP)/ebin/boy.beam + $t test -f $(APP)/ebin/human.beam + core-makedep-ignore-special-files: init $i "Bootstrap a new OTP library named $(APP)" diff --git a/test/core_query.mk b/test/core_query.mk index 9f348a1..85e863f 100644 --- a/test/core_query.mk +++ b/test/core_query.mk @@ -154,7 +154,7 @@ endif "farwest: cowlib git https://github.com/ninenines/cowlib master" \ "farwest: cowboy git https://github.com/ninenines/cowboy master" \ "farwest: gun git https://github.com/ninenines/gun master" \ - "gun: cowlib git https://github.com/ninenines/cowlib 2.12.1" \ + "gun: cowlib git https://github.com/ninenines/cowlib master" \ > $(APP)/expected-deps.txt $t cmp $(APP)/expected-deps.txt $(APP)/.erlang.mk/query-deps.log |