summaryrefslogtreecommitdiffstats
path: root/src/spdk/dpdk/buildtools/map_to_def.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/spdk/dpdk/buildtools/map_to_def.py
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/dpdk/buildtools/map_to_def.py')
-rw-r--r--src/spdk/dpdk/buildtools/map_to_def.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/spdk/dpdk/buildtools/map_to_def.py b/src/spdk/dpdk/buildtools/map_to_def.py
new file mode 100644
index 000000000..6775b54a9
--- /dev/null
+++ b/src/spdk/dpdk/buildtools/map_to_def.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2019 Intel Corporation
+
+from __future__ import print_function
+import sys
+from os.path import dirname, basename, join, exists
+
+
+def is_function_line(ln):
+ return ln.startswith('\t') and ln.endswith(';\n') and ":" not in ln
+
+
+def main(args):
+ if not args[1].endswith('version.map') or \
+ not args[2].endswith('exports.def'):
+ return 1
+
+# special case, allow override if an def file already exists alongside map file
+ override_file = join(dirname(args[1]), basename(args[2]))
+ if exists(override_file):
+ with open(override_file) as f_in:
+ functions = f_in.readlines()
+
+# generate def file from map file.
+# This works taking indented lines only which end with a ";" and which don't
+# have a colon in them, i.e. the lines defining functions only.
+ else:
+ with open(args[1]) as f_in:
+ functions = [ln[:-2] + '\n' for ln in sorted(f_in.readlines())
+ if is_function_line(ln)]
+ functions = ["EXPORTS\n"] + functions
+
+ with open(args[2], 'w') as f_out:
+ f_out.writelines(functions)
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))