gdbus-codegen 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env python3
  2. # GDBus - GLib D-Bus Library
  3. #
  4. # Copyright (C) 2008-2011 Red Hat, Inc.
  5. #
  6. # SPDX-License-Identifier: LGPL-2.1-or-later
  7. #
  8. # This library is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU Lesser General Public
  10. # License as published by the Free Software Foundation; either
  11. # version 2.1 of the License, or (at your option) any later version.
  12. #
  13. # This library is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. # Lesser General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Lesser General
  19. # Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  20. #
  21. # Author: David Zeuthen <davidz@redhat.com>
  22. import os
  23. import sys
  24. srcdir = os.getenv('UNINSTALLED_GLIB_SRCDIR', None)
  25. filedir = os.path.dirname(__file__)
  26. if srcdir is not None:
  27. path = os.path.join(srcdir, 'gio', 'gdbus-2.0')
  28. elif os.path.basename(filedir) == 'bin':
  29. # Make the prefix containing gdbus-codegen 'relocatable' at runtime by
  30. # adding /some/prefix/bin/../share/glib-2.0 to the python path
  31. path = os.path.join(filedir, '..', 'share', 'glib-2.0')
  32. else:
  33. # Assume that the modules we need are in the current directory and add the
  34. # parent directory to the python path.
  35. path = os.path.join(filedir, '..')
  36. # Canonicalize, then do further testing
  37. path = os.path.abspath(path)
  38. # If the above path detection failed, use the hard-coded datadir. This can
  39. # happen when, for instance, bindir and datadir are not in the same prefix or
  40. # on Windows where we cannot make any guarantees about the directory structure.
  41. #
  42. # In these cases our installation cannot be relocatable, but at least we should
  43. # be able to find the codegen module.
  44. if not os.path.isfile(os.path.join(path, 'codegen', 'codegen_main.py')):
  45. path = os.path.join('/home/arkos/repo/arkos/arkrt/ark.display.graphics/prebuilts/x86_64/share', 'glib-2.0')
  46. sys.path.insert(0, path)
  47. from codegen import codegen_main
  48. sys.exit(codegen_main.codegen_main())