1// Copyright (C) 2016 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package art 16 17import ( 18 "path/filepath" 19 "sort" 20 "strings" 21 22 "android/soong/android" 23 "android/soong/cc/config" 24) 25 26var ( 27 pctx = android.NewPackageContext("android/soong/art") 28 29 // Copy the following prebuilts to the testcases directory. 30 // The original prebuilts directory is not accessible when running tests remotely. 31 prebuiltToolsForTests = []string{ 32 "bin/clang", 33 "bin/clang.real", 34 "bin/llvm-addr2line", 35 "bin/llvm-dwarfdump", 36 "bin/llvm-objdump", 37 "lib64/libc++.so.1", 38 } 39) 40 41func init() { 42 android.RegisterMakeVarsProvider(pctx, makeVarsProvider) 43 pctx.Import("android/soong/cc/config") 44} 45 46func makeVarsProvider(ctx android.MakeVarsContext) { 47 ctx.Strict("LIBART_IMG_HOST_BASE_ADDRESS", ctx.Config().LibartImgHostBaseAddress()) 48 ctx.Strict("LIBART_IMG_TARGET_BASE_ADDRESS", ctx.Config().LibartImgDeviceBaseAddress()) 49 50 testMap := testMap(ctx.Config()) 51 var testNames []string 52 for name := range testMap { 53 testNames = append(testNames, name) 54 } 55 56 sort.Strings(testNames) 57 58 for _, name := range testNames { 59 ctx.Strict("ART_TEST_LIST_"+name, strings.Join(testMap[name], " ")) 60 } 61 62 // Create list of copy commands to install the content of the testcases directory. 63 testcasesContent := testcasesContent(ctx.Config()) 64 copy_cmds := []string{} 65 for _, key := range android.SortedStringKeys(testcasesContent) { 66 copy_cmds = append(copy_cmds, testcasesContent[key]+":"+key) 67 } 68 ctx.Strict("ART_TESTCASES_CONTENT", strings.Join(copy_cmds, " ")) 69 70 // Add prebuilt tools. 71 clang_path := filepath.Join(config.ClangDefaultBase, ctx.Config().PrebuiltOS(), config.ClangDefaultVersion) 72 copy_cmds = []string{} 73 for _, tool := range prebuiltToolsForTests { 74 src := filepath.Join(clang_path, "/", tool) 75 copy_cmds = append(copy_cmds, src+":"+src) 76 } 77 ctx.Strict("ART_TESTCASES_PREBUILT_CONTENT", strings.Join(copy_cmds, " ")) 78} 79