Lines Matching refs:std
41 static const std::string gConfigPrefix = "android-base-";
42 static const std::string gConfigSuffix = ".config";
43 static const std::string gBaseConfig = "android-base.config";
51 NamedIstream(const std::string& name, std::unique_ptr<std::istream>&& stream) in NamedIstream()
52 : mName(name), mStream(std::move(stream)) {} in NamedIstream()
53 const std::string& name() const { return mName; } in name()
54 std::istream& stream() { return *mStream; } in stream()
58 std::string mName;
59 std::unique_ptr<std::istream> mStream;
66 using Condition = std::unique_ptr<KernelConfig>;
67 using ConditionedConfig = std::pair<Condition, std::vector<KernelConfig> /* configs */>;
70 void setFakeEnv(const std::string& key, const std::string& value) { mFakeEnv[key] = value; } in setFakeEnv()
72 std::string getEnv(const std::string& key) const { in getEnv()
78 return envValue != nullptr ? std::string(envValue) : std::string(); in getEnv()
82 std::vector<std::string> getEnvList(const std::string& key) const { in getEnvList()
83 std::vector<std::string> ret; in getEnvList()
94 bool getFlag(const std::string& key, T* value, bool log = true) const { in getFlag()
95 std::string envValue = getEnv(key); in getFlag()
98 std::cerr << "Warning: " << key << " is missing, defaulted to " << (*value) << "." in getFlag()
99 << std::endl; in getFlag()
105 std::cerr << "Cannot parse " << envValue << "." << std::endl; in getFlag()
118 bool getFlagIfUnset(const std::string& envKey, T* out) const { in getFlagIfUnset()
123 std::string envStrValue = getEnv(envKey); in getFlagIfUnset()
126 std::cerr << "Cannot parse " << envValue << "." << std::endl; in getFlagIfUnset()
134 std::cerr << "Cannot override existing value " << *out << " with " << envKey in getFlagIfUnset()
135 << " (which is " << envValue << ")." << std::endl; in getFlagIfUnset()
146 bool getBooleanFlag(const std::string& key) const { return getEnv(key) == std::string("true"); } in getBooleanFlag()
148 size_t getIntegerFlag(const std::string& key, size_t defaultValue = 0) const { in getIntegerFlag()
149 std::string envValue = getEnv(key); in getIntegerFlag()
155 std::cerr << "Error: " << key << " must be a number." << std::endl; in getIntegerFlag()
161 static std::string read(std::basic_istream<char>& is) { in read()
162 std::stringstream ss; in read()
169 static bool isCommonConfig(const std::string& path) { in isCommonConfig()
176 static bool isConditionalConfig(const std::string& path) { in isConditionalConfig()
186 static bool isExtraCommonConfig(const std::string& path) { in isExtraCommonConfig()
191 static Condition generateCondition(const std::string& path) { in generateCondition()
196 std::string sub = fname.substr(gConfigPrefix.size(), in generateCondition()
210 std::cerr << "'" << fname << "' (in " << path in generateCondition()
213 << std::endl; in generateCondition()
217 return std::make_unique<KernelConfig>(std::move(sub), Tristate::YES); in generateCondition()
220 static bool parseFileForKernelConfigs(std::basic_istream<char>& stream, in parseFileForKernelConfigs()
221 std::vector<KernelConfig>* out) { in parseFileForKernelConfigs()
225 std::cerr << parser.error(); in parseFileForKernelConfigs()
232 config.first = std::move(configPair.first); in parseFileForKernelConfigs()
234 std::cerr << "Unknown value type for key = '" << config.first << "', value = '" in parseFileForKernelConfigs()
242 static bool parseFilesForKernelConfigs(std::vector<NamedIstream>* streams, in parseFilesForKernelConfigs()
243 std::vector<ConditionedConfig>* out) { in parseFilesForKernelConfigs()
252 std::cerr << "Failed to generate common configs for file " in parseFilesForKernelConfigs()
262 std::cerr << "Failed to generate conditional configs for file " in parseFilesForKernelConfigs()
267 std::vector<KernelConfig> kernelConfigs; in parseFilesForKernelConfigs()
269 out->emplace_back(std::move(condition), std::move(kernelConfigs)); in parseFilesForKernelConfigs()
274 std::cerr << "No " << gBaseConfig << " is found in these paths:" << std::endl; in parseFilesForKernelConfigs()
276 std::cerr << " " << namedStream.name() << std::endl; in parseFilesForKernelConfigs()
281 out->insert(out->begin(), std::move(commonConfig)); in parseFilesForKernelConfigs()
285 std::basic_ostream<char>& out() const { return mOutRef == nullptr ? std::cout : *mOutRef; } in out()
290 std::string error; in checkDualFile()
292 std::cerr << "Not compatible: " << error << std::endl; in checkDualFile()
299 using HalManifests = std::vector<HalManifest>;
300 using CompatibilityMatrices = std::vector<CompatibilityMatrix>;
303 void outputInputs(const std::vector<M>& inputs) { in outputInputs()
304 out() << "<!--" << std::endl; in outputInputs()
305 out() << " Input:" << std::endl; in outputInputs()
308 out() << " " << base::Basename(e.fileName()) << std::endl; in outputInputs()
311 out() << "-->" << std::endl; in outputInputs()
320 std::cerr << "Warning: multiple --kernel is specified when building device manifest. " in setDeviceManifestKernel()
321 << "Only the first one will be used." << std::endl; in setDeviceManifestKernel()
328 std::cerr << "Warning: multiple config files are specified in --kernel when building " in setDeviceManifestKernel()
329 << "device manfiest. Only the first one will be used." << std::endl; in setDeviceManifestKernel()
335 std::cerr << parser.error(); in setDeviceManifestKernel()
340 auto kernel_info = std::make_optional<KernelInfo>(); in setDeviceManifestKernel()
343 std::string error; in setDeviceManifestKernel()
345 std::cerr << error << "\n"; in setDeviceManifestKernel()
353 std::string error; in assembleHalManifest()
356 const std::string& path = it->fileName(); in assembleHalManifest()
363 std::cerr << "Inconsistent FCM Version in HAL manifests:" << std::endl in assembleHalManifest()
365 << halManifest->level() << std::endl in assembleHalManifest()
367 << std::endl; in assembleHalManifest()
373 std::cerr << "File \"" << path << "\" cannot be added: " << error << std::endl; in assembleHalManifest()
394 halManifest->framework.mVendorNdks.emplace_back(std::move(v)); in assembleHalManifest()
398 halManifest->framework.mSystemSdk.mVersions.emplace(std::move(v)); in assembleHalManifest()
407 std::cerr << "FATAL ERROR: cannot generate a compatible matrix: " << error in assembleHalManifest()
408 << std::endl; in assembleHalManifest()
427 std::cerr << "Cannot parse check file as a compatibility matrix: " << error in assembleHalManifest()
428 << std::endl; in assembleHalManifest()
442 std::vector<ConditionedConfig> conditionedConfigs; in assembleFrameworkCompatibilityMatrixKernels()
447 MatrixKernel kernel(KernelVersion{pair.first}, std::move(conditionedConfig.second)); in assembleFrameworkCompatibilityMatrixKernels()
449 kernel.mConditions.push_back(std::move(*conditionedConfig.first)); in assembleFrameworkCompatibilityMatrixKernels()
450 std::string error; in assembleFrameworkCompatibilityMatrixKernels()
451 if (!matrix->addKernel(std::move(kernel), &error)) { in assembleFrameworkCompatibilityMatrixKernels()
452 std::cerr << "Error:" << error << std::endl; in assembleFrameworkCompatibilityMatrixKernels()
472 if (!res.ok()) std::cerr << "Warning: " << res.error() << std::endl; in setDeviceFcmVersion()
482 std::cerr << "Warning: Shipping FCM Version is inferred from Shipping API level. " in setDeviceFcmVersion()
483 << "Declare Shipping FCM Version in device manifest directly." << std::endl; in setDeviceFcmVersion()
486 std::cerr << "Error: Shipping FCM Version cannot be inferred from Shipping API " in setDeviceFcmVersion()
489 << std::endl; in setDeviceFcmVersion()
497 std::cerr << "Warning: Shipping FCM Version cannot be inferred, because:" << std::endl in setDeviceFcmVersion()
498 << " (1) It is not explicitly declared in device manifest;" << std::endl in setDeviceFcmVersion()
499 << " (2) PRODUCT_ENFORCE_VINTF_MANIFEST is set to true;" << std::endl in setDeviceFcmVersion()
500 << " (3) PRODUCT_SHIPPING_API_LEVEL is undefined." << std::endl in setDeviceFcmVersion()
501 << "Assuming 'unspecified' Shipping FCM Version. " << std::endl in setDeviceFcmVersion()
503 << std::endl; in setDeviceFcmVersion()
518 std::string error; in assembleCompatibilityMatrix()
520 std::unique_ptr<HalManifest> checkManifest; in assembleCompatibilityMatrix()
521 std::unique_ptr<CompatibilityMatrix> builtMatrix; in assembleCompatibilityMatrix()
524 checkManifest = std::make_unique<HalManifest>(); in assembleCompatibilityMatrix()
527 std::cerr << "Cannot parse check file as a HAL manifest: " << error << std::endl; in assembleCompatibilityMatrix()
537 std::cerr << error << std::endl; in assembleCompatibilityMatrix()
545 std::cerr << "Hard-coded <vendor-ndk> version in device compatibility matrix (" in assembleCompatibilityMatrix()
548 << "from BOARD_VNDK_VERSION '" << vndkVersion << "'" << std::endl; in assembleCompatibilityMatrix()
551 valueInMatrix = VendorNdk{std::move(vndkVersion)}; in assembleCompatibilityMatrix()
555 matrix->device.mSystemSdk.mVersions.emplace(std::move(v)); in assembleCompatibilityMatrix()
565 std::cerr << "Warning: No Target FCM Version for device. Assuming \"" in assembleCompatibilityMatrix()
568 << std::endl; in assembleCompatibilityMatrix()
575 std::cerr << error << std::endl; in assembleCompatibilityMatrix()
584 std::set<Version> sepolicyVersions; in assembleCompatibilityMatrix()
593 std::cerr << "Error: unknown sepolicy version '" << s << "' specified by " in assembleCompatibilityMatrix()
631 AssembleStatus tryAssemble(const std::string& schemaName, AssembleFunc assemble, in tryAssemble()
632 std::string* error) { in tryAssemble()
633 std::vector<Schema> schemas; in tryAssemble()
640 schemas.emplace_back(std::move(schema)); in tryAssemble()
644 const std::string& fileName = it->name(); in tryAssemble()
647 std::cerr << "File \"" << fileName << "\" is not a valid " << firstType << " " in tryAssemble()
649 << schemaName << "). Error: " << *error << std::endl; in tryAssemble()
653 std::cerr << "File \"" << fileName << "\" is a " << additionalSchema.type() << " " in tryAssemble()
655 << " is expected)." << std::endl; in tryAssemble()
659 schemas.emplace_back(std::move(additionalSchema)); in tryAssemble()
665 using std::placeholders::_1; in assemble()
667 std::cerr << "Missing input file." << std::endl; in assemble()
671 std::string manifestError; in assemble()
673 "manifest", std::bind(&AssembleVintfImpl::assembleHalManifest, this, _1), in assemble()
680 std::string matrixError; in assemble()
683 std::bind(&AssembleVintfImpl::assembleCompatibilityMatrix, this, _1), &matrixError); in assemble()
687 std::cerr << "Input file has unknown format." << std::endl in assemble()
688 << "Error when attempting to convert to manifest: " << manifestError << std::endl in assemble()
690 << std::endl; in assemble()
694 std::ostream& setOutputStream(Ostream&& out) override { in setOutputStream()
695 mOutRef = std::move(out); in setOutputStream()
699 std::istream& addInputStream(const std::string& name, Istream&& in) override { in addInputStream()
700 auto it = mInFiles.emplace(mInFiles.end(), name, std::move(in)); in addInputStream()
704 std::istream& setCheckInputStream(const std::string& name, Istream&& in) override { in setCheckInputStream()
705 mCheckFile = NamedIstream(name, std::move(in)); in setCheckInputStream()
713 std::istream& addKernelConfigInputStream(const KernelVersion& kernelVer, in addKernelConfigInputStream()
714 const std::string& name, Istream&& in) override { in addKernelConfigInputStream()
716 auto it = kernel.emplace(kernel.end(), name, std::move(in)); in addKernelConfigInputStream()
731 std::cerr << "Error: Cannot set --hals-only with --no-hals." << std::endl; in setHalsOnly()
743 std::cerr << "Error: Cannot set --hals-only with --no-hals." << std::endl; in setNoHals()
758 std::vector<NamedIstream> mInFiles;
764 std::map<KernelVersion, std::vector<NamedIstream>> mKernels;
765 std::map<std::string, std::string> mFakeEnv;
769 bool AssembleVintf::openOutFile(const std::string& path) { in openOutFile()
770 return static_cast<std::ofstream&>(setOutputStream(std::make_unique<std::ofstream>(path))) in openOutFile()
774 bool AssembleVintf::openInFile(const std::string& path) { in openInFile()
775 return static_cast<std::ifstream&>(addInputStream(path, std::make_unique<std::ifstream>(path))) in openInFile()
779 bool AssembleVintf::openCheckFile(const std::string& path) { in openCheckFile()
780 return static_cast<std::ifstream&>( in openCheckFile()
781 setCheckInputStream(path, std::make_unique<std::ifstream>(path))) in openCheckFile()
785 bool AssembleVintf::addKernel(const std::string& kernelArg) { in addKernel()
788 std::cerr << "Unrecognized --kernel option '" << kernelArg << "'" << std::endl; in addKernel()
793 std::cerr << "Unrecognized kernel version '" << tokens.front() << "'" << std::endl; in addKernel()
797 std::cerr << "Multiple --kernel for " << kernelVer << " is specified." << std::endl; in addKernel()
802 static_cast<std::ifstream&>( in addKernel()
803 addKernelConfigInputStream(kernelVer, *it, std::make_unique<std::ifstream>(*it))) in addKernel()
806 std::cerr << "Cannot open file '" << *it << "'." << std::endl; in addKernel()
813 std::unique_ptr<AssembleVintf> AssembleVintf::newInstance() { in newInstance()
814 return std::make_unique<AssembleVintfImpl>(); in newInstance()