antenv.cmd 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. */
  15. '@echo off'
  16. call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  17. call SysLoadFuncs
  18. /* Prepare the parameters for later use */
  19. parse arg argv
  20. mode = ''
  21. args = ''
  22. opts = ''
  23. cp = ''
  24. lcp = ''
  25. do i = 1 to words(argv)
  26. param = word(argv, i)
  27. select
  28. when param='-lcp' then mode = 'l'
  29. when param='-cp' | param='-classpath' then mode = 'c'
  30. when abbrev('-opts', param, 4) then mode = 'o'
  31. when abbrev('-args', param, 4) then mode = 'a'
  32. otherwise
  33. select
  34. when mode = 'a' then args = space(args param, 1)
  35. when mode = 'c' then cp = space(cp param, 1)
  36. when mode = 'l' then lcp = space(lcp param, 1)
  37. when mode = 'o' then opts = space(opts param, 1)
  38. otherwise
  39. say 'Option' param 'ignored'
  40. end
  41. end
  42. end
  43. env="OS2ENVIRONMENT"
  44. antconf = _getenv_('antconf' 'antconf.cmd')
  45. runrc = _getenv_('runrc')
  46. interpret 'call "' || runrc || '"' '"' || antconf || '"' 'ETC'
  47. ANT_HOME = value('ANT_HOME',,env)
  48. JAVA_HOME = value('JAVA_HOME',,env)
  49. classpath = value('CLASSPATH',,env)
  50. classes = stream(JAVA_HOME || "\lib\classes.zip", "C", "QUERY EXISTS")
  51. if classes \= '' then classpath = prepend(classpath classes)
  52. classes = stream(JAVA_HOME || "\lib\tools.jar", "C", "QUERY EXISTS")
  53. if classes \= '' then classpath = prepend(classpath classes)
  54. classpath = prepend(classpath ANT_HOME || '\lib\ant-launcher.jar')
  55. 'SET CLASSPATH=' || classpath
  56. /* Setting classpathes, options and arguments */
  57. envset = _getenv_('envset')
  58. if cp\='' then interpret 'call "' || envset || '"' '"; CLASSPATH"' '"' || cp || '"'
  59. if lcp\='' then interpret 'call "' || envset || '"' '"; LOCALCLASSPATH"' '"' || lcp || '"'
  60. if opts\='' then interpret 'call "' || envset || '"' '"-D ANT_OPTS"' '"' || opts || '"'
  61. if args\='' then interpret 'call "' || envset || '"' '"ANT_ARGS"' '"' || args || '"'
  62. exit 0
  63. addpath: procedure
  64. parse arg path elem
  65. if elem = '' then do
  66. if path\='' & right(path, 1)\=';' then path = path || ';'
  67. return path
  68. end
  69. if substr(path, length(path)) = ';' then glue = ''
  70. else glue = ';'
  71. if pos(translate(elem), translate(path)) = 0 then path = path || glue || elem || ';'
  72. return path
  73. prepend: procedure
  74. parse arg path elem
  75. if elem = '' then do
  76. if path\='' & right(path, 1)\=';' then path = path || ';'
  77. return path
  78. end
  79. if pos(translate(elem), translate(path)) = 0 then path = elem || ';' || path
  80. return path
  81. _getenv_: procedure expose env
  82. parse arg envar default
  83. if default = '' then default = envar
  84. var = value(translate(envar),,env)
  85. if var = '' then var = default
  86. return var