1/* 2 * Copyright (C) 2024 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 */ 16syntax = "proto3"; 17 18package ide_query; 19 20option go_package = "ide_query/ide_query_proto"; 21 22message GeneratedFile { 23 // Path to the file relative to build_out_dir. 24 string path = 1; 25 26 // The text of the generated file, if not provided contents will be read 27 // from the path above in user's workstation. 28 optional bytes contents = 2; 29} 30 31message IdeAnalysis { 32 // Directory that contains build outputs generated by the build system. 33 // Relative to repository root. 34 string build_out_dir = 1; 35 // Working directory used by the build system. 36 // Relative to repository root. 37 string working_dir = 4; 38 // Only set if the whole query failed. 39 optional AnalysisError error = 5; 40 // List of results, one per queried file. 41 repeated AnalysisResult results = 6; 42 // List of buildable units directly or indirectly references by the results. 43 repeated BuildableUnit units = 7; 44 45 reserved 2, 3; 46} 47 48message AnalysisError { 49 // Human readable error message. 50 string error_message = 1; 51} 52 53message AnalysisResult { 54 // Path to the source file that was queried, relative to repository root. 55 string source_file_path = 1; 56 // Indicates the success/failure for the query. 57 message Status { 58 enum Code { 59 CODE_UNSPECIFIED = 0; 60 CODE_OK = 1; 61 CODE_NOT_FOUND = 2; // no target or module found for the source file. 62 CODE_BUILD_FAILED = 3; 63 } 64 Code code = 1; 65 // Details about the status, might be displayed to user. 66 optional string status_message = 2; 67 } 68 // Represents status for this result. e.g. not part of the build graph. 69 Status status = 2; 70 // ID of buildable unit that contains the source file. 71 // The ide_query script can choose the most relevant unit from multiple 72 // options. 73 string unit_id = 3; 74 // Invalidation rule to check if the result is still valid. 75 Invalidation invalidation = 4; 76} 77 78enum Language { 79 LANGUAGE_UNSPECIFIED = 0; 80 LANGUAGE_JAVA = 1; // also includes Kotlin 81 LANGUAGE_CPP = 2; 82} 83 84message BuildableUnit { 85 // Unique identifier of the buildable unit. 86 // 87 // Examples: 88 // - Java: module or target name, e.g. "framework-bluetooth" or 89 // "//third_party/hamcrest:hamcrest_java" 90 // - C++: source file, e.g. "path/to/file.cc" 91 string id = 1; 92 // Language of the unit. 93 // Required for buildable units directly referenced by the AnalysisResult, 94 // e.g. the unit associated with the compilation stage for the source file. 95 Language language = 2; 96 // Source files that are part of this unit. 97 // Path to the file relative to working_dir. 98 repeated string source_file_paths = 3; 99 // Compiler arguments to compile the source files. 100 repeated string compiler_arguments = 4; 101 // List of generated files produced by this unit. 102 repeated GeneratedFile generated_files = 5; 103 // List of other BuildableUnits this unit depend on. 104 repeated string dependency_ids = 6; 105} 106 107// Invalidation rule to check if the result is still valid. 108// This should contain files/dirs that are not directly part of the build graph 109// but still affect the result. For example BUILD files, directory to the 110// toolchain or config files etc. 111message Invalidation { 112 // If any of these files change the result may become invalid. 113 // Path to the file relative to repository root. 114 repeated string file_paths = 1; 115 116 message Wildcard { 117 // Prefix of the file path (e.g. "path/to/") 118 optional string prefix = 1; 119 // Suffix of the file path (e.g. "Android.bp") 120 optional string suffix = 2; 121 // If false, the part of the path between the given `prefix` and `suffix` 122 // should not contain directory separators ('/'). 123 optional bool can_cross_folder = 3; 124 } 125 // If any of these rules match a changed file the result may become invalid. 126 repeated Wildcard wildcards = 4; 127}