diff --git a/CHANGELOG.md b/CHANGELOG.md
index e05a4a0d..9a431bd1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,7 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Flatpak:
- configuration file ( **flatpak.yml** ) will be created during the initialization ( on 0.8.1 it would only be created during the first app installation )
- AUR:
- - downgrading time reduced due to the fix described in ***Fixes***.
+ - downgrading time reduced due to the fix described in ***Fixes***
+ - the custom **makepkg.conf** generated at **~/.config/bauh/arch** will enable **ccache** if available on the system
- Configuration ( **~/.config/bauh/config.yml** )
- new property **hdpi** allowing to disable HDPI improvements
```
diff --git a/bauh/gems/arch/resources/img/arch.svg b/bauh/gems/arch/resources/img/arch.svg
index 69267f5c..39445b97 100644
--- a/bauh/gems/arch/resources/img/arch.svg
+++ b/bauh/gems/arch/resources/img/arch.svg
@@ -1,57 +1 @@
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/bauh/gems/arch/resources/img/mirror.svg b/bauh/gems/arch/resources/img/mirror.svg
index 74336f2b..6ac7e1d0 100644
--- a/bauh/gems/arch/resources/img/mirror.svg
+++ b/bauh/gems/arch/resources/img/mirror.svg
@@ -8,15 +8,15 @@
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
enable-background="new 0 0 515.91 728.5"
- height="24.000002"
+ height="512"
id="Layer_1"
version="1.1"
- viewBox="0 0 24.000003 24.000002"
- width="24.000002"
+ viewBox="0 0 512.00003 512"
+ width="512"
xml:space="preserve"
sodipodi:docname="mirror.svg"
inkscape:version="0.92.4 5da689c313, 2019-01-14">image/svg+xml
\ No newline at end of file
diff --git a/bauh/gems/arch/worker.py b/bauh/gems/arch/worker.py
index 3ca41c95..24ade860 100644
--- a/bauh/gems/arch/worker.py
+++ b/bauh/gems/arch/worker.py
@@ -1,6 +1,7 @@
import logging
import os
import re
+import time
from multiprocessing import Process
from pathlib import Path
from threading import Thread
@@ -8,6 +9,7 @@ from threading import Thread
import requests
from bauh.api.abstract.context import ApplicationContext
+from bauh.commons.system import run_cmd
from bauh.gems.arch import pacman, disk, CUSTOM_MAKEPKG_FILE, CONFIG_DIR, BUILD_DIR, \
AUR_INDEX_FILE, config
@@ -17,7 +19,6 @@ URL_INFO = 'https://aur.archlinux.org/rpc/?v=5&type=info&arg={}'
GLOBAL_MAKEPKG = '/etc/makepkg.conf'
RE_MAKE_FLAGS = re.compile(r'#?\s*MAKEFLAGS\s*=\s*.+\s*')
-RE_COMPRESS_XZ = re.compile(r'#?\s*COMPRESSXZ\s*=\s*.+')
RE_CLEAR_REPLACE = re.compile(r'[\-_.]')
@@ -74,8 +75,15 @@ class ArchCompilationOptimizer(Thread):
def __init__(self, logger: logging.Logger):
super(ArchCompilationOptimizer, self).__init__(daemon=True)
self.logger = logger
+ self.re_compress_xz = re.compile(r'#?\s*COMPRESSXZ\s*=\s*.+')
+ self.re_build_env = re.compile(r'\s+BUILDENV\s*=.+')
+ self.re_ccache = re.compile(r'!?ccache')
+
+ def _is_ccache_installed(self) -> bool:
+ return bool(run_cmd('which ccache', print_error=False))
def optimize(self):
+ ti = time.time()
try:
ncpus = os.cpu_count()
except:
@@ -106,22 +114,50 @@ class ArchCompilationOptimizer(Thread):
else:
optimizations.append('MAKEFLAGS="-j$(nproc)"')
- compress_xz = RE_COMPRESS_XZ.findall(custom_makepkg if custom_makepkg else global_makepkg)
+ compress_xz = self.re_compress_xz.findall(custom_makepkg or global_makepkg)
if compress_xz:
not_eligible = [f for f in compress_xz if not f.startswith('#') and '--threads' in f]
if not not_eligible:
- custom_makepkg = RE_COMPRESS_XZ.sub('', global_makepkg)
+ custom_makepkg = self.re_compress_xz.sub('', custom_makepkg or global_makepkg)
optimizations.append('COMPRESSXZ=(xz -c -z - --threads=0)')
else:
self.logger.warning("It seems '{}' COMPRESSXZ is already customized".format(GLOBAL_MAKEPKG))
else:
optimizations.append('COMPRESSXZ=(xz -c -z - --threads=0)')
+ build_envs = self.re_build_env.findall(custom_makepkg or global_makepkg)
+
+ if build_envs:
+ build_def = None
+ for e in build_envs:
+ env_line = e.strip()
+
+ ccache_defs = self.re_ccache.findall(env_line)
+ ccache_installed = self._is_ccache_installed()
+
+ if ccache_defs:
+ if ccache_installed:
+ custom_makepkg = (custom_makepkg or global_makepkg).replace(e, '')
+
+ if not build_def:
+ build_def = self.re_ccache.sub('', env_line).replace('(', '(ccache ')
+ elif not build_def:
+ build_def = self.re_ccache.sub('', env_line)
+
+ if build_def:
+ optimizations.append(build_def)
+ else:
+ self.logger.warning("No BUILDENV declaration found")
+
+ if self._is_ccache_installed():
+ self.logger.info('Adding a BUILDENV declaration')
+ optimizations.append('BUILDENV=(ccache)')
+
if optimizations:
generated_by = '# \n'
- custom_makepkg = generated_by + custom_makepkg + '\n' + generated_by + '\n'.join(optimizations) + '\n'
+ custom_makepkg = custom_makepkg + '\n' + generated_by + '\n'.join(optimizations) + '\n'
with open(CUSTOM_MAKEPKG_FILE, 'w+') as f:
f.write(custom_makepkg)
@@ -134,6 +170,8 @@ class ArchCompilationOptimizer(Thread):
self.logger.info("Removing old optimized 'makepkg.conf' at '{}'".format(CUSTOM_MAKEPKG_FILE))
os.remove(CUSTOM_MAKEPKG_FILE)
+ tf = time.time()
+ self.logger.info("Optimizations took {0:.2f} seconds".format(tf - ti))
self.logger.info('Finished')
def run(self):