From 7410cebd3b6b081e2d0f582691151399de66bb80 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Wed, 8 Apr 2020 03:42:10 -0700 Subject: [PATCH] [deadcode] more portable `find` command Summary: Unbreak Linux. Reviewed By: ezgicicek Differential Revision: D20894536 fbshipit-source-id: b9088798f --- infer/src/deadcode/Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/infer/src/deadcode/Makefile b/infer/src/deadcode/Makefile index 179cae0aa..735c628df 100644 --- a/infer/src/deadcode/Makefile +++ b/infer/src/deadcode/Makefile @@ -39,23 +39,30 @@ ALL_MLI_FILES_COPIED = all_mli_files_copied default: detect_dead_code +# Annoying find being different on OSX/BSD and GNU/Linux +ifeq ($(PLATFORM),Linux) +DEPTH_ONE=-mindepth 1 -maxdepth 1 +else +DEPTH_ONE=-depth 1 +endif + # ./ is necessary for find to work correctly. # Note that we run find under _build directory. Since we copy some # sources from subfolders to src/ folder to avoid duplicates we use -# -depth 1 and iteration over main and library folders. +# $(DEPTH_ONE) and iteration over main and library folders. LIBRARY_FOLDERS = . ./IR ./atd ./base ./c_stubs ./istd ./scripts INCLUDE_FOLDERS = -I IR -I atd -I base -I c_stubs -I istd -I scripts ml_src_files:=$(shell \ cd $(INFER_BUILD_DIR); \ for d in $(LIBRARY_FOLDERS); do \ - [ -d $$d ] && echo $$(find $$d -depth 1 -regex '\./[a-zA-Z].*\.ml' \( -not -regex '.*\.pp\.ml' \) \ + [ -d $$d ] && echo $$(find $$d $(DEPTH_ONE) -regex '\./[a-zA-Z].*\.ml' \( -not -regex '.*\.pp\.ml' \) \ | sed 's/^\.\///'); \ done) mli_src_files:=$(shell \ cd $(INFER_BUILD_DIR); \ for d in $(LIBRARY_FOLDERS); do \ - [ -d $$d ] && echo $$(find $$d -depth 1 -regex '\./[a-zA-Z].*\.mli' \( -not -regex '.*\.pp\.mli' \) \ + [ -d $$d ] && echo $$(find $$d $(DEPTH_ONE) -regex '\./[a-zA-Z].*\.mli' \( -not -regex '.*\.pp\.mli' \) \ | sed 's/^\.\///'); \ done) ml_src_files_without_mli:=$(shell \