xref: /OK3568_Linux_fs/yocto/poky/bitbake/lib/bb/methodpool.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#
2*4882a593Smuzhiyun# Copyright (C)       2006 Holger Hans Peter Freyther
3*4882a593Smuzhiyun#
4*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0-only
5*4882a593Smuzhiyun#
6*4882a593Smuzhiyun
7*4882a593Smuzhiyunfrom bb.utils import better_compile, better_exec
8*4882a593Smuzhiyun
9*4882a593Smuzhiyundef insert_method(modulename, code, fn, lineno):
10*4882a593Smuzhiyun    """
11*4882a593Smuzhiyun    Add code of a module should be added. The methods
12*4882a593Smuzhiyun    will be simply added, no checking will be done
13*4882a593Smuzhiyun    """
14*4882a593Smuzhiyun    comp = better_compile(code, modulename, fn, lineno=lineno)
15*4882a593Smuzhiyun    better_exec(comp, None, code, fn)
16*4882a593Smuzhiyun
17*4882a593Smuzhiyuncompilecache = {}
18*4882a593Smuzhiyun
19*4882a593Smuzhiyundef compile_cache(code):
20*4882a593Smuzhiyun    h = hash(code)
21*4882a593Smuzhiyun    if h in compilecache:
22*4882a593Smuzhiyun        return compilecache[h]
23*4882a593Smuzhiyun    return None
24*4882a593Smuzhiyun
25*4882a593Smuzhiyundef compile_cache_add(code, compileobj):
26*4882a593Smuzhiyun    h = hash(code)
27*4882a593Smuzhiyun    compilecache[h] = compileobj
28