1 // Copyright 2019 The Bazel Authors. All rights reserved.
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 #include <stdio.h>
16 #include <stdlib.h>
17
main(int argc,char ** argv)18 int main(int argc, char** argv) {
19 char* out_path = getenv("OUT");
20 if (!out_path || !*out_path) {
21 fprintf(stderr, "ERROR(" __FILE__ ":%d): envvar OUT is undefined\n",
22 __LINE__);
23 return 1;
24 }
25 FILE* f = fopen(out_path, "wt");
26 if (!f) {
27 fprintf(stderr, "ERROR(" __FILE__ ":%d): could not open output file '%s'\n",
28 __LINE__, out_path);
29 return 1;
30 }
31 for (int i = 1; i < argc; ++i) {
32 fprintf(f, "arg%d=(%s)\n", i, argv[i]);
33 }
34 fclose(f);
35 return 0;
36 }
37