mirror of
https://github.com/utmapp/gfxstream.git
synced 2026-12-01 22:13:31 -10:00
Bug: b/366231094 Test: build Change-Id: I9b72334b54ceda98c22537716bbfc33596f55d89
59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
/*
|
|
* Copyright (C) 2021 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include <google/protobuf/text_format.h>
|
|
|
|
#include <fstream>
|
|
#include <string>
|
|
|
|
#include "GraphicsDetector.h"
|
|
#include "GraphicsDetector.pb.h"
|
|
|
|
namespace {
|
|
|
|
bool WriteToFile(const std::string& filename, const std::string& contents) {
|
|
std::ofstream ofs(filename);
|
|
if (!ofs.is_open()) {
|
|
return false;
|
|
}
|
|
ofs << contents;
|
|
ofs.close();
|
|
return !ofs.fail();
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int main(int argc, char* argv[]) {
|
|
const auto availability = ::gfxstream::DetectGraphicsAvailability();
|
|
|
|
std::string availabilityString;
|
|
if (!google::protobuf::TextFormat::PrintToString(availability, &availabilityString)) {
|
|
std::cerr << "Failed to convert availability to string." << std::endl;
|
|
return -1;
|
|
}
|
|
|
|
if (argc > 1) {
|
|
const std::string filename = argv[1];
|
|
if (!WriteToFile(filename, availabilityString)) {
|
|
std::cerr << "Failed to write to '" << filename << "'.";
|
|
return -1;
|
|
}
|
|
} else {
|
|
std::cout << availabilityString << std::endl;
|
|
}
|
|
|
|
return 0;
|
|
} |