-
Notifications
You must be signed in to change notification settings - Fork 118
/
kconfigfunctions.py
39 lines (33 loc) · 1013 Bytes
/
kconfigfunctions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#
# Custom KConfig preprocessor functions for Legato configuration.
#
# Copyright (C) Sierra Wireless Inc.
#
import os
import shutil
def b2k(kconf, _, val):
"""Convert a binary 1/0 value to a KConfig y/n."""
return "y" if val in ("1", "y") else "n"
def empty(kconf, _, val):
"""Convert an empty/non-empty string to a KConfig y/n."""
return "y" if not val else "n"
def dfault(kconf, _, val, defval):
"""If a value is empty, use the provided default."""
return val if val else defval
def getccache(kconfig, _):
"""Find the local version of ccache to use, if any."""
ccache = os.environ.get("CCACHE", "")
if not ccache:
try:
ccache = shutil.which("sccache") or ""
if not ccache:
ccache = shutil.which("cache") or ""
except:
pass
return ccache
functions = {
"b2k": (b2k, 1, 1),
"def": (dfault, 2, 2),
"empty": (empty, 1, 1),
"getccache": (getccache, 0, 0)
}