diff options
| -rw-r--r-- | common/strings.mk | 2 | ||||
| -rw-r--r-- | core/binary.mk | 2 | ||||
| -rw-r--r-- | core/clear_vars.mk | 1 | ||||
| -rw-r--r-- | core/config_sanitizers.mk | 3 | ||||
| -rw-r--r-- | tools/Android.bp | 20 | ||||
| -rwxr-xr-x | tools/extract_kernel.py | 84 |
6 files changed, 86 insertions, 26 deletions
diff --git a/common/strings.mk b/common/strings.mk index ba20e272c0..e560bf06ea 100644 --- a/common/strings.mk +++ b/common/strings.mk @@ -28,7 +28,7 @@ to-lower=$(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f ########################################################### to-upper=$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1)))))))))))))))))))))))))) -# Sanity-check to-lower and to-upper +# Test to-lower and to-upper lower := abcdefghijklmnopqrstuvwxyz-_ upper := ABCDEFGHIJKLMNOPQRSTUVWXYZ-_ diff --git a/core/binary.mk b/core/binary.mk index 29a78a3984..be7dc2737a 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -594,7 +594,7 @@ rs_generated_cpps := $(addprefix \ $(call track-src-file-gen,$(renderscript_sources),$(rs_generated_cpps)) -# This is just a dummy rule to make sure gmake doesn't skip updating the dependents. +# This is just a no-op rule to make sure gmake doesn't skip updating the dependents. $(rs_generated_cpps) : $(RenderScript_file_stamp) @echo "Updated RS generated cpp file $@." $(hide) touch $@ diff --git a/core/clear_vars.mk b/core/clear_vars.mk index e2acf96a9f..f87f6b4887 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -259,6 +259,7 @@ LOCAL_SANITIZE_DIAG:= LOCAL_SANITIZE_RECOVER:= LOCAL_SANITIZE_NO_RECOVER:= LOCAL_SANITIZE_BLACKLIST := +LOCAL_SANITIZE_BLOCKLIST := LOCAL_SDK_LIBRARIES := LOCAL_SDK_RES_VERSION:= LOCAL_SDK_VERSION:= diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk index c5cb91c102..323bb36d9d 100644 --- a/core/config_sanitizers.mk +++ b/core/config_sanitizers.mk @@ -147,6 +147,9 @@ ifneq ($(my_sanitize)$(my_global_sanitize),) ifneq ($(LOCAL_SANITIZE_BLACKLIST),) my_cflags += -fsanitize-blacklist=$(LOCAL_PATH)/$(LOCAL_SANITIZE_BLACKLIST) endif + ifneq ($(LOCAL_SANITIZE_BLOCKLIST),) + my_cflags += -fsanitize-blacklist=$(LOCAL_PATH)/$(LOCAL_SANITIZE_BLOCKLIST) + endif endif # Disable integer_overflow if LOCAL_NOSANITIZE=integer. diff --git a/tools/Android.bp b/tools/Android.bp index 149d06df4c..e0f3739280 100644 --- a/tools/Android.bp +++ b/tools/Android.bp @@ -56,3 +56,23 @@ python_test_host { test_config: "post_process_props_unittest.xml", test_suites: ["general-tests"], } + +python_binary_host { + name: "extract_kernel", + srcs: ["extract_kernel.py"], + version: { + py2: { + enabled: true, + }, + py3: { + enabled: false, + }, + }, +} + +genrule_defaults { + name: "extract_kernel_release_defaults", + tools: ["extract_kernel", "lz4"], + out: ["kernel_release.txt"], + cmd: "$(location) --tools lz4:$(location lz4) --input $(in) --output-release > $(out)" +} diff --git a/tools/extract_kernel.py b/tools/extract_kernel.py index 8ca11d1cc6..92a647be3c 100755 --- a/tools/extract_kernel.py +++ b/tools/extract_kernel.py @@ -40,10 +40,10 @@ COMPRESSION_ALGO = ( # LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n"; LINUX_BANNER_PREFIX = b'Linux version ' LINUX_BANNER_REGEX = LINUX_BANNER_PREFIX + \ - r'([0-9]+[.][0-9]+[.][0-9]+).* \(.*@.*\) \(.*\) .*\n' + r'(?P<release>(?P<version>[0-9]+[.][0-9]+[.][0-9]+).*) \(.*@.*\) \(.*\) .*\n' -def get_version(input_bytes, start_idx): +def get_from_release(input_bytes, start_idx, key): null_idx = input_bytes.find('\x00', start_idx) if null_idx < 0: return None @@ -53,24 +53,43 @@ def get_version(input_bytes, start_idx): return None mo = re.match(LINUX_BANNER_REGEX, linux_banner) if mo: - return mo.group(1) + return mo.group(key) return None -def dump_version(input_bytes): +def dump_from_release(input_bytes, key): + """ + Helper of dump_version and dump_release + """ idx = 0 while True: idx = input_bytes.find(LINUX_BANNER_PREFIX, idx) if idx < 0: return None - version = get_version(input_bytes, idx) - if version: - return version + value = get_from_release(input_bytes, idx, key) + if value: + return value idx += len(LINUX_BANNER_PREFIX) +def dump_version(input_bytes): + """ + Dump kernel version, w.x.y, from input_bytes. Search for the string + "Linux version " and do pattern matching after it. See LINUX_BANNER_REGEX. + """ + return dump_from_release(input_bytes, "version") + + +def dump_release(input_bytes): + """ + Dump kernel release, w.x.y-..., from input_bytes. Search for the string + "Linux version " and do pattern matching after it. See LINUX_BANNER_REGEX. + """ + return dump_from_release(input_bytes, "release") + + def dump_configs(input_bytes): """ Dump kernel configuration from input_bytes. This can be done when @@ -140,6 +159,23 @@ def decompress_dump(func, input_bytes): if o: return o + +def dump_to_file(f, dump_fn, input_bytes, desc): + """ + Call decompress_dump(dump_fn, input_bytes) and write to f. If it fails, return + False; otherwise return True. + """ + if f is not None: + o = decompress_dump(dump_fn, input_bytes) + if o: + f.write(o) + else: + sys.stderr.write( + "Cannot extract kernel {}".format(desc)) + return False + return True + + def main(): parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter, @@ -165,6 +201,13 @@ def main(): nargs='?', type=argparse.FileType('wb'), const=sys.stdout) + parser.add_argument('--output-release', + help='If specified, write kernel release. Use stdout if ' + 'no file is specified.', + metavar='FILE', + nargs='?', + type=argparse.FileType('wb'), + const=sys.stdout) parser.add_argument('--tools', help='Decompression tools to use. If not specified, PATH ' 'is searched.', @@ -181,25 +224,18 @@ def main(): input_bytes = args.input.read() ret = 0 - if args.output_configs is not None: - o = decompress_dump(dump_configs, input_bytes) - if o: - args.output_configs.write(o) - else: - sys.stderr.write( - "Cannot extract kernel configs in {}".format(args.input.name)) - ret = 1 - if args.output_version is not None: - o = decompress_dump(dump_version, input_bytes) - if o: - args.output_version.write(o) - else: - sys.stderr.write( - "Cannot extract kernel versions in {}".format(args.input.name)) - ret = 1 + if not dump_to_file(args.output_configs, dump_configs, input_bytes, + "configs in {}".format(args.input.name)): + ret = 1 + if not dump_to_file(args.output_version, dump_version, input_bytes, + "version in {}".format(args.input.name)): + ret = 1 + if not dump_to_file(args.output_release, dump_release, input_bytes, + "kernel release in {}".format(args.input.name)): + ret = 1 return ret if __name__ == '__main__': - exit(main()) + sys.exit(main()) |