incdir.bat 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. @echo off
  2. rem tools/incdir.sh
  3. rem
  4. rem Licensed to the Apache Software Foundation (ASF) under one or more
  5. rem contributor license agreements. See the NOTICE file distributed with
  6. rem this work for additional information regarding copyright ownership. The
  7. rem ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. rem "License"); you may not use this file except in compliance with the
  9. rem License. You may obtain a copy of the License at
  10. rem
  11. rem http://www.apache.org/licenses/LICENSE-2.0
  12. rem
  13. rem Unless required by applicable law or agreed to in writing, software
  14. rem distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. rem WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. rem License for the specific language governing permissions and limitations
  17. rem under the License.
  18. rem
  19. rem Handle command line options
  20. set progname=%0
  21. set pathtype=user
  22. :ArgLoop
  23. rem [-d] [-w] [-s] [-h]. [-w] and [-d] Ignored for compatibility with incdir.sh
  24. if "%1"=="-d" goto :NextArg
  25. if "%1"=="-w" goto :NextArg
  26. if "%1"=="-h" goto :Usage
  27. if "%1"=="-s" (
  28. set pathtype=system
  29. goto :NextArg
  30. )
  31. goto :CheckCompiler
  32. :NextArg
  33. shift
  34. goto :ArgLoop
  35. :CheckCompiler
  36. if "%1"=="" (
  37. echo ERROR: Missing compiler name
  38. goto :Usage
  39. )
  40. set ccpath=%1
  41. shift
  42. set compiler=
  43. for /F %%i in ("%ccpath%") do set compiler=%%~ni
  44. if "%1"=="" (
  45. echo ERROR: Missing directory paths
  46. goto :Usage
  47. )
  48. rem Check for some well known, non-GCC Windows native tools that require
  49. rem a special output format as well as special paths
  50. :GetFormat
  51. set fmt=std
  52. if "%compiler%"=="ez8cc" goto :SetZdsFormt
  53. if "%compiler%"=="zneocc" goto :SetZdsFormt
  54. if "%compiler%"=="ez80cc" goto :SetZdsFormt
  55. goto :GeneratePaths
  56. :SetZdsFormt
  57. set fmt=zds
  58. rem Generate the compiler include path directives.
  59. :GeneratePaths
  60. set response=
  61. :DirLoop
  62. if "%1" == "" (
  63. echo %response%
  64. goto :End
  65. )
  66. if "%fmt%"=="zds" goto :GenerateZdsPath
  67. if "%response%"=="" goto :FirstStdPath
  68. if "%pathtype%"=="system" goto :NextStdSystemPath
  69. set response=%response% -I "%1"
  70. goto :EndOfDirLoop
  71. :NextStdSystemPath
  72. set response=%response% -isystem "%1"
  73. goto :EndOfDirLoop
  74. :FirstStdPath
  75. if "%pathtype%"=="system" goto :FirstStdSystemPath
  76. set response=-I "%1"
  77. goto :EndOfDirLoop
  78. :FirstStdSystemPath
  79. set response=-isystem "%1"
  80. goto :EndOfDirLoop
  81. :GenerateZdsPath
  82. if "%response%"=="" goto :FirstZdsPath
  83. set response=%response%;%1
  84. goto :EndOfDirLoop
  85. :FirstZdsPath
  86. if "%pathtype%"=="system" goto :FirstZdsSystemPath
  87. set response=-usrinc:%1
  88. goto :EndOfDirLoop
  89. :FirstZdsSystemPath
  90. set response=-stdinc:%1
  91. :EndOfDirLoop
  92. shift
  93. goto :DirLoop
  94. :Usage
  95. echo %progname% is a tool for flexible generation of include path arguments for a
  96. echo variety of different compilers in a variety of compilation environments
  97. echo USAGE: %progname% [-w] [-d] [-s] [-h] ^<compiler-path^> ^<dir1^> [^<dir2^> [^<dir3^> ...]]
  98. echo Where:
  99. echo ^<compiler-path^>
  100. echo The full path to your compiler
  101. echo ^<dir1^> [^<dir2^> [^<dir3^> ...]]
  102. echo A list of include directories
  103. echo -w, -d
  104. echo For compatibility with incdir.sh (ignored)
  105. echo -s
  106. echo Generate standard, system header file paths instead of normal user
  107. echo header file paths.
  108. echo -h
  109. echo Shows this help text and exits.
  110. :End