generate_cached_setup.py 1.6 KB

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. from __future__ import print_function
  3. import os
  4. import stat
  5. import sys
  6. # find the import for catkin's python package - either from source space or from an installed underlay
  7. if os.path.exists(os.path.join('/opt/ros/melodic/share/catkin/cmake', 'catkinConfig.cmake.in')):
  8. sys.path.insert(0, os.path.join('/opt/ros/melodic/share/catkin/cmake', '..', 'python'))
  9. try:
  10. from catkin.environment_cache import generate_environment_script
  11. except ImportError:
  12. # search for catkin package in all workspaces and prepend to path
  13. for workspace in '/home/neousys/autoware.ai/install/lanelet2_extension;/home/neousys/autoware.ai/install/vector_map;/home/neousys/autoware.ai/install/amathutils_lib;/home/neousys/autoware.ai/install/vector_map_msgs;/home/neousys/autoware.ai/install/autoware_msgs;/home/neousys/autoware.ai/install/autoware_lanelet2_msgs;/home/neousys/autoware.ai/install/autoware_build_flags;/opt/ros/melodic'.split(';'):
  14. python_path = os.path.join(workspace, 'lib/python2.7/dist-packages')
  15. if os.path.isdir(os.path.join(python_path, 'catkin')):
  16. sys.path.insert(0, python_path)
  17. break
  18. from catkin.environment_cache import generate_environment_script
  19. code = generate_environment_script('/home/neousys/autoware.ai/build/map_file/devel/env.sh')
  20. output_filename = '/home/neousys/autoware.ai/build/map_file/catkin_generated/setup_cached.sh'
  21. with open(output_filename, 'w') as f:
  22. # print('Generate script for cached setup "%s"' % output_filename)
  23. f.write('\n'.join(code))
  24. mode = os.stat(output_filename).st_mode
  25. os.chmod(output_filename, mode | stat.S_IXUSR)