mklink.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python
  2. #
  3. # Wrapper for symbolic link creation on Windows that works around issues
  4. # with native path conversion. See the component CMakeLists.txt for more details.
  5. #
  6. # Copyright 2018 Espressif Systems (Shanghai) PTE LTD
  7. #
  8. # Licensed under the Apache License, Version 2.0 (the "License");
  9. # you may not use this file except in compliance with the License.
  10. # You may obtain a copy of the License at
  11. #
  12. # http:#www.apache.org/licenses/LICENSE-2.0
  13. #
  14. # Unless required by applicable law or agreed to in writing, software
  15. # distributed under the License is distributed on an "AS IS" BASIS,
  16. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # See the License for the specific language governing permissions and
  18. # limitations under the License.
  19. import os
  20. import argparse
  21. import subprocess
  22. parser = argparse.ArgumentParser()
  23. parser.add_argument("type")
  24. parser.add_argument("link")
  25. parser.add_argument("target")
  26. args = parser.parse_args()
  27. link = os.path.abspath(args.link)
  28. target = os.path.abspath(args.target)
  29. try:
  30. os.makedirs(os.path.dirname(link))
  31. except WindowsError:
  32. pass
  33. mklink_cmd = ["mklink", args.type, link, target]
  34. subprocess.call(mklink_cmd, shell=True)