You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

antenv.cmd 3.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. Copyright (c) 2003 The Apache Software Foundation. All rights
  3. reserved.
  4. Ant environment
  5. */
  6. call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  7. call SysLoadFuncs
  8. /* Prepare the parameters for later use */
  9. parse arg argv
  10. mode = ''
  11. args = ''
  12. opts = ''
  13. cp = ''
  14. lcp = ''
  15. do i = 1 to words(argv)
  16. param = word(argv, i)
  17. select
  18. when param='-lcp' then mode = 'l'
  19. when param='-cp' | param='-classpath' then mode = 'c'
  20. when abbrev('-opts', param, 4) then mode = 'o'
  21. when abbrev('-args', param, 4) then mode = 'a'
  22. otherwise
  23. select
  24. when mode = 'a' then args = space(args param, 1)
  25. when mode = 'c' then cp = space(cp param, 1)
  26. when mode = 'l' then lcp = space(lcp param, 1)
  27. when mode = 'o' then opts = space(opts param, 1)
  28. otherwise
  29. say 'Option' param 'ignored'
  30. end
  31. end
  32. end
  33. env="OS2ENVIRONMENT"
  34. antconf = _getenv_('antconf' 'antconf.cmd')
  35. runrc = _getenv_('runrc')
  36. interpret 'call "' || runrc || '"' '"' || antconf || '"' 'ETC'
  37. ANT_HOME = value('ANT_HOME',,env)
  38. JAVA_HOME = value('JAVA_HOME',,env)
  39. classpath = value('CLASSPATH',,env)
  40. classes = stream(JAVA_HOME || "\lib\classes.zip", "C", "QUERY EXISTS")
  41. if classes \= '' then classpath = prepend(classpath classes)
  42. classes = stream(JAVA_HOME || "\lib\tools.jar", "C", "QUERY EXISTS")
  43. if classes \= '' then classpath = prepend(classpath classes)
  44. mincp = classpath
  45. call SysFileTree ANT_HOME || '\lib\*.jar', 'jar', 'FO'
  46. do i = 1 to jar.0
  47. nm = filespec('name', jar.i)
  48. if pos('ant-', nm) == 0 then classpath = prepend(classpath jar.i)
  49. end
  50. if length(classpath) > 512 then do
  51. say 'Classpath is too long, switching to the minimal version...'
  52. say '... some tasks will not work'
  53. classpath = mincp
  54. classpath = prepend(classpath ANT_HOME || '\lib\ant.jar')
  55. classpath = prepend(classpath ANT_HOME || '\lib\optional.jar')
  56. end
  57. 'SET CLASSPATH=' || classpath
  58. /* Setting classpathes, options and arguments */
  59. envset = _getenv_('envset')
  60. if cp\='' then interpret 'call "' || envset || '"' '"; CLASSPATH"' '"' || cp || '"'
  61. if lcp\='' then interpret 'call "' || envset || '"' '"; LOCALCLASSPATH"' '"' || lcp || '"'
  62. if opts\='' then interpret 'call "' || envset || '"' '"-D ANT_OPTS"' '"' || opts || '"'
  63. if args\='' then interpret 'call "' || envset || '"' '"ANT_ARGS"' '"' || args || '"'
  64. exit 0
  65. addpath: procedure
  66. parse arg path elem
  67. if elem = '' then do
  68. if path\='' & right(path, 1)\=';' then path = path || ';'
  69. return path
  70. end
  71. if substr(path, length(path)) = ';' then glue = ''
  72. else glue = ';'
  73. if pos(translate(elem), translate(path)) = 0 then path = path || glue || elem || ';'
  74. return path
  75. prepend: procedure
  76. parse arg path elem
  77. if elem = '' then do
  78. if path\='' & right(path, 1)\=';' then path = path || ';'
  79. return path
  80. end
  81. if pos(translate(elem), translate(path)) = 0 then path = elem || ';' || path
  82. return path
  83. _getenv_: procedure expose env
  84. parse arg envar default
  85. if default = '' then default = envar
  86. var = value(translate(envar),,env)
  87. if var = '' then var = default
  88. return var