Line 0
Link Here
|
|
|
1 |
/*usr/bin/true; exec rexx "$0" "$@" # REXX program */ |
2 |
/* Translate and compile a NetRexx program */ |
3 |
/* */ |
4 |
/* use as: NetRexxC hello [file2]... */ |
5 |
/* */ |
6 |
/* which will use the NetRexx translator to */ |
7 |
/* translate hello.nrx to hello.java */ |
8 |
/* then will use javac to compile hello.java */ |
9 |
/* */ |
10 |
/* Any OPTIONS keywords, indicated by a prefix '-', */ |
11 |
/* may be added before, after, or between file */ |
12 |
/* specification(s), along with the following extra */ |
13 |
/*flags: */ |
14 |
/* */ |
15 |
/* -run = run class after compilation */ |
16 |
/* -keep = keep the java file after successful */ |
17 |
/* compilation (as xxx.java.keep) */ |
18 |
/* -nocompile = only translate, do not compile */ |
19 |
/* */ |
20 |
/* Multiple programs may be specified; in this case */ |
21 |
/* they are all run (if requested) after all compiles. */ |
22 |
/* */ |
23 |
/* ---------- */ |
24 |
/* 1996.09.02 -- handle Warnings from NetRexxC (rc=1) */ |
25 |
/* 1996.12.14 -- use COM.ibm.netrexx.process */ |
26 |
/* 1998.05.25 -- pass NETREXX_JAVA setting to java.exe */ |
27 |
|
28 |
parse arg args |
29 |
w=wordpos('-run', args) |
30 |
if w>0 then do; run=1; args=delword(args,w,1); end; else run=0 |
31 |
w=wordpos('-nocompile', args) |
32 |
if w>0 then do; noc=1; end; else noc=0 |
33 |
|
34 |
/* ----- Translate & Compile ----- */ |
35 |
parse source system . |
36 |
select /* system-specific options */ |
37 |
when system='OS/2' then do |
38 |
'@echo off' |
39 |
/* Add option -norestart for OS/2s 1.0.2+ java.exe, for better display */ |
40 |
'java -version 2>&1|rxqueue'; parse pull '1.' subv ' ' |
41 |
if subv>=0.2 then javaopts='-norestart'; else javaopts='-noasyncgc' |
42 |
|
43 |
/* Add any options from NETREXX_JAVA environment variable */ |
44 |
nrjava=value('NETREXX_JAVA',,'OS2ENVIRONMENT') |
45 |
if nrjava\='' then javaopts=javaopts nrjava |
46 |
end |
47 |
otherwise |
48 |
/* Add any options from NETREXX_JAVA environment variable */ |
49 |
javaopts=value('NETREXX_JAVA',,'ENVIRONMENT') |
50 |
|
51 |
/* JAVAVM MUST be set to the native jdk 1.1.8 */ |
52 |
/* it might work with a later, native jdk */ |
53 |
/* it will NOT work with a linux jdk */ |
54 |
javavm=value('JAVAVM',,'ENVIRONMENT') |
55 |
if javavm = "" then |
56 |
do |
57 |
say "NetRexx will not function unless: " |
58 |
say "" |
59 |
say " JAVAVM is set to" |
60 |
say "" |
61 |
say " /usr/local/jdk1.1.8/bin/java" |
62 |
say "" |
63 |
say "and" |
64 |
say "" |
65 |
say " CLASSPATH is set to" |
66 |
say "" |
67 |
say " .:/usr/local/jdk1.1.8/lib/classes.zip:/usr/local/jdk1.1.8/lib/NetRexxC.zip" |
68 |
say "" |
69 |
say "or" |
70 |
say "" |
71 |
say " NETREXX_JAVA is set to" |
72 |
say "" |
73 |
say " -classpath <and the above-pathes>" |
74 |
exit |
75 |
end |
76 |
end |
77 |
|
78 |
/* NOTE: This won't work if NetRexx.cmd or nrc is executed from the */ |
79 |
/* same directory as java is located in */ |
80 |
'java -ms4M' javaopts 'COM.ibm.netrexx.process.NetRexxC' args |
81 |
|
82 |
/* ----- Run ----- */ |
83 |
if rc<=1 & run then do |
84 |
if noc then say 'Run option ignored as -nocompile specified' |
85 |
else do |
86 |
do forever /* find the file parameters */ |
87 |
parse var args file args |
88 |
if file='' then leave |
89 |
if left(file,1)='-' then iterate |
90 |
filename=filespec('n', file); parse var filename fn '.' fe |
91 |
/* Now determine the exact case of the class, for java commands */ |
92 |
file=fn'.class' |
93 |
'ls -l' file ' | rxstack' /* use ls to get exact case */ |
94 |
if queued()<>1 then do |
95 |
if queued()=0 then say 'Cannot find file:' file |
96 |
if queued()>1 then do; do queued(); parse pull .; end |
97 |
say 'File "'file'" is not a unique specification' |
98 |
end |
99 |
exit 1; end |
100 |
parse pull file /* is now correct case */ |
101 |
parse var file fn '.' fe |
102 |
say 'Running' fn '...' |
103 |
'java' fn |
104 |
end |
105 |
end |
106 |
end |
107 |
|
108 |
exit rc |
109 |
|