forked from open-telemetry/opentelemetry-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dll_deps_update.cc
46 lines (38 loc) · 1.5 KB
/
dll_deps_update.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "tools/cpp/runfiles/runfiles.h"
#include <fstream>
#define REPO_NAME "otel_sdk"
int main(int argc, const char* argv[])
{
using bazel::tools::cpp::runfiles::Runfiles;
std::string error;
// For tests it should be CreateforTest
const auto runfiles{ Runfiles::Create(argv[0], BAZEL_CURRENT_REPOSITORY, &error) };
if (runfiles == nullptr) {
fprintf(stderr, "ERROR(%s): %s\n", argv[0], error.c_str());
return 1;
}
const auto input_filename{ runfiles->Rlocation(DEPS_FILE) };
const auto output_filename{ std::string( argv[1] ) };
fprintf(stderr, "Input: [%s]\n", input_filename.c_str() );
fprintf(stderr, "Output: [%s]\n", output_filename.c_str() );
std::fstream input_file;
input_file.open(input_filename, std::ios::in);
if( !input_file.is_open() ) {
fprintf(stderr, "ERROR(%s): Can't open input file %s\n", argv[0], input_filename.c_str() );
return 1;
}
std::fstream output_file;
output_file.open(output_filename, std::ios::out);// | std::ios::binary);
if( !output_file.is_open() ) {
fprintf(stderr, "ERROR(%s): Can't open output file %s\n", argv[0], output_filename.c_str() );
return 1;
}
std::string line;
output_file
<< "# This file has been generated by dll_deps" << '\n'
<< "DLL_DEPS = {" << '\n';
while( std::getline(input_file, line) )
output_file << " Label(\"@" REPO_NAME << line << "\"): None," << '\n';
output_file << "}" << '\n';
return 0;
}