1#!/bin/bash 2# 3# Copyright 2016 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17# Modifies any import statements (to remove subdir path) 18pushd ${ANDROID_BUILD_TOP}/test/vts 19 20## Modifies import statement in proto files. 21sed -i 's/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/import "ComponentSpecificationMessage.proto";/g' proto/AndroidSystemControlMessage.proto 22sed -i 's/import "test\/vts\/proto\/VtsResourceControllerMessage.proto";/import "VtsResourceControllerMessage.proto";/g' proto/AndroidSystemControlMessage.proto 23sed -i 's/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/import "ComponentSpecificationMessage.proto";/g' proto/VtsProfilingMessage.proto 24sed -i 's/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/import "ComponentSpecificationMessage.proto";/g' proto/VtsFuzzTaskMessage.proto 25sed -i 's/import "test\/vts\/proto\/VtsReportMessage.proto";/import "VtsReportMessage.proto";/g' proto/VtsFuzzTaskMessage.proto 26sed -i 's/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/import "ComponentSpecificationMessage.proto";/g' proto/VtsResourceControllerMessage.proto 27 28## Compiles modified proto files to .py files. 29protoc -I=proto --python_out=proto proto/AndroidSystemControlMessage.proto 30protoc -I=proto --python_out=proto proto/ComponentSpecificationMessage.proto 31protoc -I=proto --python_out=proto proto/VtsProfilingMessage.proto 32protoc -I=proto --python_out=proto proto/VtsFuzzTaskMessage.proto 33protoc -I=proto --python_out=proto proto/VtsResourceControllerMessage.proto 34 35## Restores import statement in proto files. 36sed -i 's/import "ComponentSpecificationMessage.proto";/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/g' proto/AndroidSystemControlMessage.proto 37sed -i 's/import "VtsResourceControllerMessage.proto";/import "test\/vts\/proto\/VtsResourceControllerMessage.proto";/g' proto/AndroidSystemControlMessage.proto 38sed -i 's/import "ComponentSpecificationMessage.proto";/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/g' proto/VtsProfilingMessage.proto 39sed -i 's/import "ComponentSpecificationMessage.proto";/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/g' proto/VtsFuzzTaskMessage.proto 40sed -i 's/import "VtsReportMessage.proto";/import "test\/vts\/proto\/VtsReportMessage.proto";/g' proto/VtsFuzzTaskMessage.proto 41sed -i 's/import "ComponentSpecificationMessage.proto";/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/g' proto/VtsResourceControllerMessage.proto 42 43protoc -I=proto --python_out=proto proto/ComponentSpecificationMessage.proto 44protoc -I=proto --python_out=proto proto/TestSchedulingPolicyMessage.proto 45protoc -I=proto --python_out=proto proto/VtsReportMessage.proto 46 47# Compiles all the python source codes. 48python -m compileall . 49 50popd 51