Skip to content

Commit e82af29

Browse files
pdillingermeta-codesync[bot]
authored andcommitted
Makefile fix and speed up 'clean' (#14767)
Summary: * Fix Makefile default target (was ordered after a folly target) * Improved the speed of `make clean` by using just one `find` and by pruning "hidden" .* and third-party directories that should not be modified anyway. * Reduce excessive output from `make clean` Pull Request resolved: #14767 Test Plan: manual Reviewed By: mszeszko-meta Differential Revision: D105972958 Pulled By: pdillinger fbshipit-source-id: 2c0f6097c74c3129b815450f23c19ef07bfbe656
1 parent acfa68c commit e82af29

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

Makefile

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ missing_make_config_paths := $(shell \
327327
$(foreach path, $(missing_make_config_paths), \
328328
$(warning Warning: $(path) does not exist))
329329

330+
# This (the first rule) must depend on "all".
331+
default: all
332+
330333
ifeq ($(PLATFORM), OS_AIX)
331334
# no debug info
332335
else ifneq ($(PLATFORM), IOS)
@@ -485,9 +488,6 @@ ifdef ROCKSDB_MODIFY_NPHASH
485488
PLATFORM_CXXFLAGS += -DROCKSDB_MODIFY_NPHASH=1
486489
endif
487490

488-
# This (the first rule) must depend on "all".
489-
default: all
490-
491491
WARNING_FLAGS = -W -Wextra -Wall -Wsign-compare -Wshadow \
492492
-Wunused-parameter
493493

@@ -1045,7 +1045,7 @@ check_0:
10451045
awk -v s=$(CI_SHARD_INDEX) -v n=$(CI_TOTAL_SHARDS) '(NR-1)%n==s'; \
10461046
else cat; fi; \
10471047
fi; \
1048-
find t -name 'run-*' -print; \
1048+
$(FIND) t -name 'run-*' -print; \
10491049
} \
10501050
| $(prioritize_long_running_tests) \
10511051
| grep -E '$(tests-regexp)' \
@@ -1067,7 +1067,7 @@ valgrind_check_0:
10671067
' run "make watch-log" in a separate window' ''; \
10681068
{ \
10691069
printf './%s\n' $(filter-out $(PARALLEL_TEST) %skiplist_test options_settable_test, $(TESTS)); \
1070-
find t -name 'run-*' -print; \
1070+
$(FIND) t -name 'run-*' -print; \
10711071
} \
10721072
| $(prioritize_long_running_tests) \
10731073
| grep -E '$(tests-regexp)' \
@@ -1285,11 +1285,17 @@ clean-not-downloaded: clean-ext-libraries-bin clean-rocks clean-not-downloaded-r
12851285

12861286
clean-rocks:
12871287
# Not practical to exactly match all versions/variants in naming (e.g. debug or not)
1288-
rm -f ${LIBNAME}*.so* ${LIBNAME}*.a
1289-
rm -f $(BENCHMARKS) $(TOOLS) $(TESTS) $(PARALLEL_TEST) $(MICROBENCHS)
1290-
rm -rf $(CLEAN_FILES) ios-x86 ios-arm scan_build_report
1291-
$(FIND) . -name "*.[oda]" -exec rm -f {} \;
1292-
$(FIND) . -type f \( -name "*.gcda" -o -name "*.gcno" \) -exec rm -f {} \;
1288+
@echo Removing link targets
1289+
@rm -f ${LIBNAME}*.so* ${LIBNAME}*.a $(BENCHMARKS) $(TOOLS) $(TESTS) $(PARALLEL_TEST) $(MICROBENCHS)
1290+
@echo Finding and cleaning other files
1291+
@rm -rf $(CLEAN_FILES) ios-x86 ios-arm scan_build_report
1292+
@if $(FIND) Makefile -regextype awk &> /dev/null; then \
1293+
$(FIND) . -regextype awk \
1294+
-regex '.*/([.].*|third-party)' -prune -o \
1295+
-type f -regex '.*[.]([oda]|gcda|gcno)' -exec rm -f {} \; ; \
1296+
else \
1297+
$(FIND) . -name "*.[oda]" -exec rm -f {} \; ; \
1298+
fi
12931299

12941300
clean-rocksjava: clean-rocks
12951301
rm -rf jl jls
@@ -1302,7 +1308,7 @@ clean-ext-libraries-all:
13021308
rm -rf bzip2* snappy* zlib* lz4* zstd*
13031309

13041310
clean-ext-libraries-bin:
1305-
find . -maxdepth 1 -type d \( -name bzip2\* -or -name snappy\* -or -name zlib\* -or -name lz4\* -or -name zstd\* \) -prune -exec rm -rf {} \;
1311+
$(FIND) . -maxdepth 1 -type d \( -name bzip2\* -or -name snappy\* -or -name zlib\* -or -name lz4\* -or -name zstd\* \) -prune -exec rm -rf {} \;
13061312

13071313
tags:
13081314
ctags -R .

java/Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,7 @@ endif
332332
clean: clean-not-downloaded clean-downloaded
333333

334334
clean-not-downloaded:
335-
$(AM_V_at)rm -rf $(NATIVE_INCLUDE)
336-
$(AM_V_at)rm -rf $(OUTPUT)
337-
$(AM_V_at)rm -rf $(BENCHMARK_OUTPUT)
338-
$(AM_V_at)rm -rf $(SAMPLES_OUTPUT)
335+
$(AM_V_at)rm -rf $(NATIVE_INCLUDE) $(OUTPUT) $(BENCHMARK_OUTPUT) $(SAMPLES_OUTPUT)
339336

340337
clean-downloaded:
341338
$(AM_V_at)rm -rf $(JAVA_TEST_LIBDIR)

0 commit comments

Comments
 (0)