1 /* 2 * Copyright (C) 2017 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 */ 16 17 #ifndef ANDROID_VINTF_ASSEMBLE_VINTF_H 18 #define ANDROID_VINTF_ASSEMBLE_VINTF_H 19 20 #include <fstream> 21 #include <iostream> 22 #include <memory> 23 #include <optional> 24 #include <string> 25 #include <vector> 26 27 #include <aidl/metadata.h> 28 #include <vintf/Version.h> 29 30 namespace android { 31 namespace vintf { 32 33 class AssembleVintf { 34 public: 35 using Ostream = std::unique_ptr<std::ostream>; 36 using Istream = std::unique_ptr<std::istream>; 37 38 static std::unique_ptr<AssembleVintf> newInstance(); 39 40 virtual ~AssembleVintf() = default; 41 virtual bool setHalsOnly() = 0; 42 virtual bool setNoHals() = 0; 43 virtual bool setNoKernelRequirements() = 0; 44 virtual void setOutputMatrix() = 0; 45 virtual bool assemble() = 0; 46 47 bool openOutFile(const std::string& path); 48 bool openInFile(const std::string& path); 49 bool openCheckFile(const std::string& path); 50 bool addKernel(const std::string& kernelArg); 51 52 virtual std::ostream& setOutputStream(Ostream&&) = 0; 53 virtual std::ostream& setErrorStream(Ostream&&) = 0; 54 virtual std::istream& addInputStream(const std::string& name, Istream&&) = 0; 55 virtual std::istream& setCheckInputStream(const std::string& name, Istream&&) = 0; 56 virtual std::istream& addKernelConfigInputStream(const KernelVersion& kernelVer, 57 const std::string& name, Istream&& in) = 0; 58 virtual void setFakeAidlMetadata(const std::vector<AidlInterfaceMetadata>& metadata) = 0; 59 virtual void setFakeAidlUseUnfrozen(const std::optional<bool>& use) = 0; 60 virtual void setFakeEnv(const std::string& key, const std::string& value) = 0; 61 62 protected: 63 virtual bool hasKernelVersion(const KernelVersion&) const = 0; 64 virtual std::string getEnv(const std::string& key) const = 0; 65 virtual std::basic_ostream<char>& err() const = 0; 66 }; 67 68 } // namespace vintf 69 } // namespace android 70 #endif // ANDROID_VINTF_ASSEMBLE_VINTF_H 71