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
16import shutil, os
17
18#
19# Perform a mostly normal build.
20# Since this test imports 'dalvik.annotation.optimization.FastNative' (and CriticalNative),
21# we put them to src-aotex/ to allow the annotations to be used at javac-compile time,
22# but remove compiled *-aotex* artifacts afterwards.
23#
24# This enables the test to compile with vanilla RI javac and work on either ART or RI.
25# TODO: The test is currently disabled for RI anyway, presumably because @CriticalNative
26# has a different ABI and cannot be tested on RI.
27#
28
29
30# Use release mode to check optimizations do not break JNI.
31def build(ctx):
32  ctx.default_build(d8_flags=["--release"])
33
34  # Remove the *-aotex build artifacts (but keep src-aotex) with dalvik.* annotations.
35  shutil.rmtree(ctx.test_dir / "classes-aotex")
36  if not ctx.jvm:
37    os.remove(ctx.test_dir / "classes-aotex.jar")
38    os.remove(ctx.test_dir / "004-JniTest-aotex.jar")
39