dpdk/buildtools/map_to_win.py
<<
>>
Prefs
   1#!/usr/bin/env python3
   2# SPDX-License-Identifier: BSD-3-Clause
   3# Copyright(c) 2019 Intel Corporation
   4
   5import sys
   6
   7
   8def is_function_line(ln):
   9    return ln.startswith('\t') and ln.endswith(';\n') and ":" not in ln and "# WINDOWS_NO_EXPORT" not in ln
  10
  11# MinGW keeps the original .map file but replaces per_lcore* to __emutls_v.per_lcore*
  12def create_mingw_map_file(input_map, output_map):
  13    with open(input_map) as f_in, open(output_map, 'w') as f_out:
  14        f_out.writelines([lines.replace('per_lcore', '__emutls_v.per_lcore') for lines in f_in.readlines()])
  15
  16def main(args):
  17    if not args[1].endswith('version.map') or \
  18            not args[2].endswith('exports.def') and \
  19            not args[2].endswith('mingw.map'):
  20        return 1
  21
  22    if args[2].endswith('mingw.map'):
  23        create_mingw_map_file(args[1], args[2])
  24        return 0
  25
  26# generate def file from map file.
  27# This works taking indented lines only which end with a ";" and which don't
  28# have a colon in them, i.e. the lines defining functions only.
  29    else:
  30        with open(args[1]) as f_in:
  31            functions = [ln[:-2] + '\n' for ln in sorted(f_in.readlines())
  32                         if is_function_line(ln)]
  33            functions = ["EXPORTS\n"] + functions
  34
  35    with open(args[2], 'w') as f_out:
  36        f_out.writelines(functions)
  37    return 0
  38
  39
  40if __name__ == "__main__":
  41    sys.exit(main(sys.argv))
  42