1# 2# Copyright (C) 2022 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16def build(ctx): 17 ctx.default_build() 18 if ctx.jvm: 19 return 20 # Change the generated dex file to have a v37 magic number if it is version 35 21 with open(ctx.test_dir / "classes.dex", "rb+") as f: 22 if f.read(8) == b"dex\n035\x00": 23 f.seek(0) 24 f.write(b"dex\n037\x00") 25 (ctx.test_dir / "370-dex-v37.jar").unlink() 26 ctx.soong_zip([ 27 "-o", ctx.test_dir / "370-dex-v37.jar", "-j", "-f", 28 ctx.test_dir / "classes.dex" 29 ]) 30