Rizin
unix-like reverse engineering framework and cli tools
meson_cmake_prefix_dir.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # SPDX-FileCopyrightText: 2021 ret2libc <sirmy15@gmail.com>
4 # SPDX-License-Identifier: LGPL-3.0-only
5 
6 """ Python script to workaround issue mesonbuild/meson#9702
7 (https://github.com/mesonbuild/meson/issues/9702). It returns the relative path
8 of the prefixdir from the cmake directory."""
9 
10 import os
11 import sys
12 
13 
14 def parse():
15  if len(sys.argv) <= 2:
16  print("Usage: {} <prefixdir> <cmakedir>".format(sys.argv[0]))
17  sys.exit(1)
18 
19  prefix_dir = sys.argv[1]
20  cmake_dir = sys.argv[2]
21 
22  return prefix_dir, cmake_dir
23 
24 
25 def main():
26  prefix_dir, cmake_dir = parse()
27 
28  prefix_dir = os.path.abspath(prefix_dir)
29  if not os.path.isabs(cmake_dir):
30  cmake_dir = os.path.abspath(os.path.join(prefix_dir, cmake_dir))
31 
32  # always use linux dir separator, CMake will take care of converting it properly
33  relpath = os.path.relpath(prefix_dir, cmake_dir).replace(os.sep, "/")
34  print("%s" % (relpath,))
35 
36 
37 if __name__ == "__main__":
38  main()
size_t len
Definition: 6502dis.c:15
Definition: regcomp.c:57
int replace(char *string, const char *token, const char *fmt,...)
Definition: tms320_dasm.c:325