1// Copyright (C) 2024 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 15// Package main generates src to stout from the stdin template using embedded 16// Media Performance Class (MPC) requirements data. 17package main 18 19import ( 20 "flag" 21 "io" 22 "log" 23 "os" 24 25 "cts/test/mediapc/requirements/requirements" 26) 27 28func main() { 29 30 var f string 31 flag.StringVar(&f, "f", "", "The proto binary file containing a RequirementList.") 32 flag.Parse() 33 reqBinary, err := os.ReadFile(f) 34 if err != nil { 35 log.Fatalf("Failed to read requirements file %s: %v", f, err) 36 } 37 req, err := requirements.UnmarshalRequirementList(reqBinary) 38 if err != nil { 39 log.Fatalf("Failed to unmarshal requirements: %v", err) 40 } 41 stdin, err := io.ReadAll(os.Stdin) 42 str := string(stdin) 43 if err != nil { 44 log.Fatalf("Failed to read stdin: %v", err) 45 } 46 err = requirements.Gensrc(str, req, os.Stdout) 47 if err != nil { 48 log.Fatalf("Failed to generate source: %v", err) 49 } 50} 51