From 962eb4be43090d3df30276c8e5dae44538351b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sun, 4 Nov 2012 01:12:25 +0100 Subject: [PATCH] Allow local caching of optional packages Introduce HAIKU_DOWNLOAD_CACHE variable that can point to a directory. containing optional packages to check first before downloading. Missing packages are also added to the cache. This allows sharing and reusing them to make builds without a connection. --- build/jam/FileRules | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/build/jam/FileRules b/build/jam/FileRules index 86fbe8b2c6..c2ba3958df 100644 --- a/build/jam/FileRules +++ b/build/jam/FileRules @@ -367,13 +367,28 @@ actions DataFileToSourceFile1 rule DownloadLocatedFile target : url { URL on $(target) = $(url) ; + # HACK + local downloadCache = /dev/null ; + + if $(HAIKU_DOWNLOAD_CACHE) { + downloadCache = $(HAIKU_DOWNLOAD_CACHE) ; + } + + local basePath = + $(downloadCache)/$(TARGET_ARCH)-gcc$(HAIKU_GCC_VERSION[1]) ; + CACHED_PATH on $(target) = + $(basePath)/$(target:G=) ; DownloadLocatedFile1 $(target) ; } actions DownloadLocatedFile1 { - wget -O "$(1)" $(URL) + test -e '$(CACHED_PATH)' && cp "$(CACHED_PATH)" "$(1)" && echo "(cached)" \ + && return 0 + wget -O "$(1)" $(URL) || return $? + test -d "`dirname "$(CACHED_PATH)"`" && cp "$(1)" "$(CACHED_PATH)" \ + && echo "(copied to cache)" || true } rule DownloadFile file : url