diff options
author | alexv-smirnov <alex@ydb.tech> | 2023-03-15 19:59:12 +0300 |
---|---|---|
committer | alexv-smirnov <alex@ydb.tech> | 2023-03-15 19:59:12 +0300 |
commit | 056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11 (patch) | |
tree | 4740980126f32e3af7937ba0ca5f83e59baa4ab0 /build/scripts/f2c.py | |
parent | 269126dcced1cc8b53eb4398b4a33e5142f10290 (diff) | |
download | ydb-056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11.tar.gz |
add library/cpp/actors, ymake build to ydb oss export
Diffstat (limited to 'build/scripts/f2c.py')
-rw-r--r-- | build/scripts/f2c.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/build/scripts/f2c.py b/build/scripts/f2c.py new file mode 100644 index 00000000000..7021e1391f1 --- /dev/null +++ b/build/scripts/f2c.py @@ -0,0 +1,58 @@ +import sys +import subprocess +import argparse +import os + + +header = '''\ +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wmissing-braces" +#pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wreturn-type" +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +''' + +footer = ''' +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif +''' + + +def mkdir_p(directory): + if not os.path.exists(directory): + os.makedirs(directory) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('-t', '--tool') + parser.add_argument('-c', '--input') + parser.add_argument('-o', '--output') + + args = parser.parse_args() + tmpdir = args.output + '.f2c' + mkdir_p(tmpdir) + # should parse includes, really + p = subprocess.Popen( + [args.tool, '-w', '-R', '-a', '-I' + os.path.dirname(args.input), '-T' + tmpdir], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) + stdout, stderr = p.communicate(input=open(args.input).read()) + ret = p.wait() + + if ret: + print >>sys.stderr, 'f2c failed: %s, %s' % (stderr, ret) + sys.exit(ret) + + if 'Error' in stderr: + print >>sys.stderr, stderr + + with open(args.output, 'w') as f: + f.write(header) + f.write(stdout) + f.write(footer) |