Skip to content

Commit 7f65088

Browse files
committed
depends: Add file-based logging for individual packages
1 parent b69fd5e commit 7f65088

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

depends/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ clean-all: clean
271271
@rm -rf $(SOURCES_PATH) x86_64* i686* mips* arm* aarch64* powerpc* riscv32* riscv64* s390x*
272272

273273
clean:
274-
@rm -rf $(WORK_PATH) $(BASE_CACHE) $(BUILD)
274+
@rm -rf $(WORK_PATH) $(BASE_CACHE) $(BUILD) *.log
275275

276276
install: check-packages $(host_prefix)/share/config.site
277277

depends/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ The following can be set when running make: `make FOO=bar`
113113
- `BUILD_ID_SALT`: Optional salt to use when generating build package ids
114114
- `FORCE_USE_SYSTEM_CLANG`: (EXPERTS ONLY) When cross-compiling for macOS, use Clang found in the
115115
system's `$PATH` rather than the default prebuilt release of Clang
116-
from llvm.org. Clang 8 or later is required.
116+
from llvm.org. Clang 8 or later is required
117+
- `LOG`: Use file-based logging for individual packages. During a package build its log file
118+
resides in the `depends` directory, and the log file is printed out automatically in case
119+
of build error. After successful build log files are moved along with package archives
117120

118121
If some packages are not built, for example `make NO_WALLET=1`, the appropriate
119122
options will be passed to bitcoin's configure. In this case, `--disable-wallet`.

depends/funcs.mk

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ $(1)_cached_checksum:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_bui
6767
$(1)_patch_dir:=$(base_build_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)/.patches-$($(1)_build_id)
6868
$(1)_prefixbin:=$($($(1)_type)_prefix)/bin/
6969
$(1)_cached:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_build_id).tar.gz
70+
$(1)_build_log:=$(BASEDIR)/$(1)-$($(1)_version)-$($(1)_build_id).log
7071
$(1)_all_sources=$($(1)_file_name) $($(1)_extra_sources)
7172

7273
#stamps
@@ -85,7 +86,7 @@ $(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path))
8586
# The default behavior for tar will try to set ownership when running as uid 0 and may not succeed, --no-same-owner disables this behavior
8687
$(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)),$$($(1)_download_file),$($(1)_file_name),$($(1)_sha256_hash))
8788
$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_TAR) --no-same-owner --strip-components=1 -xf $$($(1)_source)
88-
$(1)_preprocess_cmds ?=
89+
$(1)_preprocess_cmds ?= true
8990
$(1)_build_cmds ?=
9091
$(1)_config_cmds ?=
9192
$(1)_stage_cmds ?=
@@ -187,6 +188,10 @@ endif
187188
endef
188189

189190
define int_add_cmds
191+
ifneq ($(LOG),)
192+
$(1)_logging = >>$$($(1)_build_log) 2>&1 || { if test -f $$($(1)_build_log); then cat $$($(1)_build_log); fi; exit 1; }
193+
endif
194+
190195
$($(1)_fetched):
191196
mkdir -p $$(@D) $(SOURCES_PATH)
192197
rm -f $$@
@@ -203,23 +208,23 @@ $($(1)_preprocessed): | $($(1)_extracted)
203208
echo Preprocessing $(1)...
204209
mkdir -p $$(@D) $($(1)_patch_dir)
205210
$(foreach patch,$($(1)_patches),cd $(PATCHES_PATH)/$(1); cp $(patch) $($(1)_patch_dir) ;)
206-
cd $$(@D); $($(1)_preprocess_cmds)
211+
{ cd $$(@D); $($(1)_preprocess_cmds); } $$($(1)_logging)
207212
touch $$@
208213
$($(1)_configured): | $($(1)_dependencies) $($(1)_preprocessed)
209214
echo Configuring $(1)...
210215
rm -rf $(host_prefix); mkdir -p $(host_prefix)/lib; cd $(host_prefix); $(foreach package,$($(1)_all_dependencies), $(build_TAR) --no-same-owner -xf $($(package)_cached); )
211216
mkdir -p $$(@D)
212-
+cd $$(@D); $($(1)_config_env) $($(1)_config_cmds)
217+
+{ cd $$(@D); $($(1)_config_env) $($(1)_config_cmds); } $$($(1)_logging)
213218
touch $$@
214219
$($(1)_built): | $($(1)_configured)
215220
echo Building $(1)...
216221
mkdir -p $$(@D)
217-
+cd $$(@D); $($(1)_build_env) $($(1)_build_cmds)
222+
+{ cd $$(@D); $($(1)_build_env) $($(1)_build_cmds); } $$($(1)_logging)
218223
touch $$@
219224
$($(1)_staged): | $($(1)_built)
220225
echo Staging $(1)...
221226
mkdir -p $($(1)_staging_dir)/$(host_prefix)
222-
cd $($(1)_build_dir); $($(1)_stage_env) $($(1)_stage_cmds)
227+
+{ cd $($(1)_build_dir); $($(1)_stage_env) $($(1)_stage_cmds); } $$($(1)_logging)
223228
rm -rf $($(1)_extract_dir)
224229
touch $$@
225230
$($(1)_postprocessed): | $($(1)_staged)
@@ -233,6 +238,7 @@ $($(1)_cached): | $($(1)_dependencies) $($(1)_postprocessed)
233238
rm -rf $$(@D) && mkdir -p $$(@D)
234239
mv $$($(1)_staging_dir)/$$(@F) $$(@)
235240
rm -rf $($(1)_staging_dir)
241+
if test -f $($(1)_build_log); then mv $($(1)_build_log) $$(@D); fi
236242
$($(1)_cached_checksum): $($(1)_cached)
237243
cd $$(@D); $(build_SHA256SUM) $$(<F) > $$(@)
238244

0 commit comments

Comments
 (0)