Move SdkExtensions/proto to packages/modules/common.
The proto definitions may be needed at build time to generate appropriate configs for the modules. Unbundled ART branches do not include packages/modules/SdkExtenstion in their manifest; so put the proto in a project that should be visible to all unbundled modules. Move any relevant tools to packages/modules/common/tools as well. Bug: 180105615 Test: m nothing Change-Id: I4efa4300553af6b321f46adb29b8cc90e4556955
This commit is contained in:
75
proto/Android.bp
Normal file
75
proto/Android.bp
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
// Copyright (C) 2021 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package {
|
||||||
|
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||||
|
}
|
||||||
|
|
||||||
|
python_defaults {
|
||||||
|
name: "modules-common-proto-python-defaults",
|
||||||
|
version: {
|
||||||
|
py2: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
py3: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
python_library_host {
|
||||||
|
name: "sdk_proto_python",
|
||||||
|
defaults: ["modules-common-proto-python-defaults"],
|
||||||
|
srcs: ["sdk.proto"],
|
||||||
|
proto: {
|
||||||
|
canonical_path_from_root: false,
|
||||||
|
},
|
||||||
|
visibility: [
|
||||||
|
"//packages/modules/SdkExtensions/gen_sdk",
|
||||||
|
"//packages/modules/common/tools",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library_static {
|
||||||
|
name: "libsdk_proto",
|
||||||
|
proto: {
|
||||||
|
export_proto_headers: true,
|
||||||
|
type: "lite",
|
||||||
|
},
|
||||||
|
srcs: ["sdk.proto"],
|
||||||
|
min_sdk_version: "30",
|
||||||
|
apex_available: ["com.android.sdkext"],
|
||||||
|
visibility: ["//packages/modules/SdkExtensions/derive_sdk"],
|
||||||
|
}
|
||||||
|
|
||||||
|
python_library_host {
|
||||||
|
name: "classpaths_proto_python",
|
||||||
|
defaults: ["modules-common-proto-python-defaults"],
|
||||||
|
srcs: ["classpaths.proto"],
|
||||||
|
proto: {
|
||||||
|
canonical_path_from_root: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library_static {
|
||||||
|
name: "libclasspaths_proto",
|
||||||
|
proto: {
|
||||||
|
export_proto_headers: true,
|
||||||
|
type: "lite",
|
||||||
|
},
|
||||||
|
srcs: ["classpaths.proto"],
|
||||||
|
min_sdk_version: "30",
|
||||||
|
apex_available: ["com.android.sdkext"],
|
||||||
|
visibility: ["//packages/modules/SdkExtensions/derive_classpath"],
|
||||||
|
}
|
||||||
62
proto/classpaths.proto
Normal file
62
proto/classpaths.proto
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
enum Classpath {
|
||||||
|
UNKNOWN = 0;
|
||||||
|
BOOTCLASSPATH = 1;
|
||||||
|
SYSTEMSERVERCLASSPATH = 2;
|
||||||
|
DEX2OATBOOTCLASSPATH = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Individual entry in a classpath variable.
|
||||||
|
message Jar {
|
||||||
|
|
||||||
|
// Path on the filesystem for the jar, relative to the partition.
|
||||||
|
// For example, for APEX "com.android.myapex", relative_path of
|
||||||
|
// `javalib/myjar.jar` would correspond to an absolute path of
|
||||||
|
// `/apex/com.android.myapex/javalib/myjar.jar` at runtime.
|
||||||
|
string relative_path = 1;
|
||||||
|
|
||||||
|
// Environ classpath variable this jar belongs to.
|
||||||
|
// Must be set to a known classpath.
|
||||||
|
Classpath classpath = 2;
|
||||||
|
|
||||||
|
// Minimum API level required for the jar to be included on the classpath.
|
||||||
|
// If the system's API level is lower than the value specified in this
|
||||||
|
// attribute, the jar will not be included in the classpath.
|
||||||
|
// Not setting this attribute, defaults the value to zero and implies the jar
|
||||||
|
// can be used on all API levels.
|
||||||
|
int32 min_sdk_version = 3;
|
||||||
|
|
||||||
|
// Maximum API level that the jar file supports.
|
||||||
|
// Not setting this attribute implies unbound maximum; otherwise set value
|
||||||
|
// must be greater or equal to min_sdk value.
|
||||||
|
// If the system's API level is higher that the value specified in this
|
||||||
|
// attribute, the jar will not be included in the classpath.
|
||||||
|
int32 max_sdk_version = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jars exported by a single partition.
|
||||||
|
message ExportedClasspathsJars {
|
||||||
|
|
||||||
|
// All jars that are exported as part of any classpath environ variable
|
||||||
|
// (according to API level restrictions).
|
||||||
|
// The relative order of the jars is preserved upon final merging.
|
||||||
|
repeated Jar jars = 1;
|
||||||
|
|
||||||
|
}
|
||||||
58
proto/sdk.proto
Normal file
58
proto/sdk.proto
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
// The version of a single module.
|
||||||
|
message SdkVersion {
|
||||||
|
int32 version = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// All the modules that can be used for version requirements.
|
||||||
|
enum SdkModule {
|
||||||
|
UNKNOWN = 0;
|
||||||
|
|
||||||
|
// R modules
|
||||||
|
IPSEC = 1;
|
||||||
|
MEDIA = 2;
|
||||||
|
MEDIA_PROVIDER = 3;
|
||||||
|
PERMISSIONS = 4;
|
||||||
|
SDK_EXTENSIONS = 5;
|
||||||
|
STATSD = 6;
|
||||||
|
TETHERING = 7;
|
||||||
|
|
||||||
|
// S modules
|
||||||
|
ART = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A single extension version.
|
||||||
|
message ExtensionVersion {
|
||||||
|
message ModuleRequirement {
|
||||||
|
SdkModule module = 1;
|
||||||
|
SdkVersion version = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The extension version.
|
||||||
|
int32 version = 1;
|
||||||
|
|
||||||
|
// The modules required for this extension version.
|
||||||
|
repeated ModuleRequirement requirements = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// All the defined extension versions.
|
||||||
|
message ExtensionDatabase {
|
||||||
|
repeated ExtensionVersion versions = 1;
|
||||||
|
}
|
||||||
61
tools/Android.bp
Normal file
61
tools/Android.bp
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package {
|
||||||
|
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||||
|
}
|
||||||
|
|
||||||
|
python_defaults {
|
||||||
|
name: "modules-common-tools-python-defaults",
|
||||||
|
version: {
|
||||||
|
py2: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
py3: {
|
||||||
|
enabled: true,
|
||||||
|
embedded_launcher: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
python_binary_host {
|
||||||
|
name: "conv_classpaths_proto",
|
||||||
|
defaults: ["modules-common-tools-python-defaults"],
|
||||||
|
srcs: ["conv_classpaths_proto.py"],
|
||||||
|
libs: ["classpaths_proto_python"],
|
||||||
|
}
|
||||||
|
|
||||||
|
python_binary_host {
|
||||||
|
name: "gen_sdkinfo",
|
||||||
|
defaults: ["modules-common-tools-python-defaults"],
|
||||||
|
srcs: ["gen_sdkinfo.py"],
|
||||||
|
libs: ["sdk_proto_python"],
|
||||||
|
}
|
||||||
|
|
||||||
|
gensrcs {
|
||||||
|
name: "cur_sdkinfo_src",
|
||||||
|
srcs: [""],
|
||||||
|
tools: [ "gen_sdkinfo" ],
|
||||||
|
cmd: "$(location) -v 0 -o $(out)",
|
||||||
|
}
|
||||||
|
|
||||||
|
prebuilt_etc {
|
||||||
|
name: "cur_sdkinfo",
|
||||||
|
src: ":cur_sdkinfo_src",
|
||||||
|
filename: "sdkinfo.binarypb",
|
||||||
|
installable: false,
|
||||||
|
visibility: ["//packages/modules/SdkExtensions"],
|
||||||
|
}
|
||||||
76
tools/conv_classpaths_proto.py
Normal file
76
tools/conv_classpaths_proto.py
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
# Copyright (C) 2021 The Android Open Source Project
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
import classpaths_pb2
|
||||||
|
|
||||||
|
import google.protobuf.json_format as json_format
|
||||||
|
import google.protobuf.text_format as text_format
|
||||||
|
|
||||||
|
|
||||||
|
def encode(args):
|
||||||
|
pb = classpaths_pb2.ExportedClasspathsJars()
|
||||||
|
if args.format == 'json':
|
||||||
|
json_format.Parse(args.input.read(), pb)
|
||||||
|
else:
|
||||||
|
text_format.Parse(args.input.read(), pb)
|
||||||
|
args.output.write(pb.SerializeToString())
|
||||||
|
args.input.close()
|
||||||
|
args.output.close()
|
||||||
|
|
||||||
|
|
||||||
|
def decode(args):
|
||||||
|
pb = classpaths_pb2.ExportedClasspathsJars()
|
||||||
|
pb.ParseFromString(args.input.read())
|
||||||
|
if args.format == 'json':
|
||||||
|
args.output.write(json_format.MessageToJson(pb))
|
||||||
|
else:
|
||||||
|
args.output.write(text_format.MessageToString(pb).encode('utf_8'))
|
||||||
|
args.input.close()
|
||||||
|
args.output.close()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser('Convert classpaths.proto messages between binary and '
|
||||||
|
'human-readable formats.')
|
||||||
|
parser.add_argument('-f', '--format', default='textproto',
|
||||||
|
help='human-readable format, either json or text(proto), '
|
||||||
|
'defaults to textproto')
|
||||||
|
parser.add_argument('-i', '--input',
|
||||||
|
nargs='?', type=argparse.FileType('rb'), default=sys.stdin.buffer)
|
||||||
|
parser.add_argument('-o', '--output',
|
||||||
|
nargs='?', type=argparse.FileType('wb'),
|
||||||
|
default=sys.stdout.buffer)
|
||||||
|
|
||||||
|
subparsers = parser.add_subparsers()
|
||||||
|
|
||||||
|
parser_encode = subparsers.add_parser('encode',
|
||||||
|
help='convert classpaths protobuf message from '
|
||||||
|
'JSON to binary format',
|
||||||
|
parents=[parser], add_help=False)
|
||||||
|
|
||||||
|
parser_encode.set_defaults(func=encode)
|
||||||
|
|
||||||
|
parser_decode = subparsers.add_parser('decode',
|
||||||
|
help='print classpaths config in JSON format',
|
||||||
|
parents=[parser], add_help=False)
|
||||||
|
parser_decode.set_defaults(func=decode)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
args.func(args)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
19
tools/gen_sdkinfo.py
Normal file
19
tools/gen_sdkinfo.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import sdk_pb2
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
argv = sys.argv[1:]
|
||||||
|
if not len(argv) == 4 or sorted([argv[0], argv[2]]) != ['-o', '-v']:
|
||||||
|
print('usage: gen_sdkinfo -v <version> -o <output-file>')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
for i in range(len(argv)):
|
||||||
|
if sys.argv[i] == '-o':
|
||||||
|
filename = sys.argv[i+1]
|
||||||
|
if sys.argv[i] == '-v':
|
||||||
|
version = int(sys.argv[i+1])
|
||||||
|
|
||||||
|
proto = sdk_pb2.SdkVersion()
|
||||||
|
proto.version = version
|
||||||
|
with open(filename, 'wb') as f:
|
||||||
|
f.write(proto.SerializeToString())
|
||||||
Reference in New Issue
Block a user