Home | History | Annotate | Download | only in script
      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)
     18 pushd ${ANDROID_BUILD_TOP}/test/vts
     19 
     20 ## Modifies import statement in proto files.
     21 sed -i 's/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/import "ComponentSpecificationMessage.proto";/g' proto/AndroidSystemControlMessage.proto
     22 sed -i 's/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/import "ComponentSpecificationMessage.proto";/g' proto/VtsProfilingMessage.proto
     23 sed -i 's/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/import "ComponentSpecificationMessage.proto";/g' proto/VtsFuzzTaskMessage.proto
     24 sed -i 's/import "test\/vts\/proto\/VtsReportMessage.proto";/import "VtsReportMessage.proto";/g' proto/VtsFuzzTaskMessage.proto
     25 
     26 ## Compiles modified proto files to .py files.
     27 protoc -I=proto --python_out=proto proto/AndroidSystemControlMessage.proto
     28 protoc -I=proto --python_out=proto proto/ComponentSpecificationMessage.proto
     29 protoc -I=proto --python_out=proto proto/VtsProfilingMessage.proto
     30 protoc -I=proto --python_out=proto proto/VtsFuzzTaskMessage.proto
     31 
     32 ## Restores import statement in proto files.
     33 sed -i 's/import "ComponentSpecificationMessage.proto";/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/g' proto/AndroidSystemControlMessage.proto
     34 sed -i 's/import "ComponentSpecificationMessage.proto";/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/g' proto/VtsProfilingMessage.proto
     35 sed -i 's/import "ComponentSpecificationMessage.proto";/import "test\/vts\/proto\/ComponentSpecificationMessage.proto";/g' proto/VtsFuzzTaskMessage.proto
     36 sed -i 's/import "VtsReportMessage.proto";/import "test\/vts\/proto\/VtsReportMessage.proto";/g' proto/VtsFuzzTaskMessage.proto
     37 
     38 protoc -I=proto --python_out=proto proto/ComponentSpecificationMessage.proto
     39 protoc -I=proto --python_out=proto proto/TestSchedulingPolicyMessage.proto
     40 protoc -I=proto --python_out=proto proto/VtsReportMessage.proto
     41 
     42 # Compiles all the python source codes.
     43 python -m compileall .
     44 
     45 popd
     46