Skip to content

Commit 07525ca

Browse files
committed
Initial .NET Core build. Suppress registry defaults, auto-update, goat mode and STOP with exit code in portable build. Also re-implemented CommandLineParser using Environment.GetCommandLineArgs() instead of XCALL CMDLN. Also worked around a String.Split() compiler bug in portable mode.
1 parent f001daa commit 07525ca

File tree

5 files changed

+106
-107
lines changed

5 files changed

+106
-107
lines changed

CodeGen/CodeGen.dbl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ proc
9898
ok = false
9999
end
100100

101+
.ifndef D_PORTABLE
102+
101103
;;-------------------------------------------------------------------------
102104
;;Is an auto update check scheduled and due?
103105

@@ -223,10 +225,12 @@ proc
223225
end
224226
end
225227

228+
.endc
226229

227230
;;-------------------------------------------------------------------------
228231
;;Just a little fun!
229232

233+
.ifndef D_PORTABLE
230234
if (ok && (CommandLineParser.Parse("goat")))
231235
begin
232236
Console.WriteLine(StringTools.GetGoat(false))
@@ -243,6 +247,7 @@ proc
243247
endtry
244248
ok = false
245249
end
250+
.endc
246251

247252
;;-------------------------------------------------------------------------
248253
;;OK, looks like we're going to be generating some code
@@ -1150,6 +1155,11 @@ proc
11501155
Console.WriteLine()
11511156
end
11521157

1158+
Environment.ExitCode = exitCode
1159+
1160+
.ifndef D_PORTABLE
1161+
;;TODO: Portable doesn't like this right now (11/17)
11531162
stop exitCode
1163+
.endc
11541164

11551165
endmain

CodeGen/UpdateManager.dbl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
;;
4141
;;*****************************************************************************
4242

43+
.ifndef D_PORTABLE
44+
4345
import System
4446
import System.Diagnostics
4547
import System.IO
@@ -270,3 +272,5 @@ namespace CodeGen
270272
endclass
271273

272274
endnamespace
275+
276+
.endc

CodeGenEngine/CodeGenerator.dbl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,17 @@ namespace CodeGen.Engine
102102
;;Make the current version number available in the expander
103103
context.Version = CODEGEN_VERSION
104104

105+
.ifndef D_PORTABLE
105106
;;Is CODEGEN_TPLDIR already set in the environment?
106107
data templateFolder = Environment.GetEnvironmentVariable("CODEGEN_TPLDIR")
107108
if (String.IsNullOrWhiteSpace(templateFolder))
108109
begin
109110
;;No, look in the registry for the value set by InstallShield
110-
data templateFolderFound = false
111-
112111
templateFolder = (String)Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Synergex\CodeGen","TemplatePath","")
113112
if (!String.IsNullOrWhiteSpace(templateFolder)) then
114113
begin
115114
;;Found it
116115
Environment.SetEnvironmentVariable("CODEGEN_TPLDIR",templateFolder.Trim())
117-
templateFolderFound = true
118116
end
119117
else if (Environment.Is64BitProcess)
120118
begin
@@ -124,17 +122,17 @@ namespace CodeGen.Engine
124122
begin
125123
;;Found it
126124
Environment.SetEnvironmentVariable("CODEGEN_TPLDIR",templateFolder.Trim())
127-
templateFolderFound = true
128125
end
129126
end
130127
end
131-
128+
.endc
132129
;;Is CODEGEN_AUTHOR already set in the environment?
133130
data authorName = Environment.GetEnvironmentVariable("CODEGEN_AUTHOR")
134131
if (!String.IsNullOrWhiteSpace(authorName)) then
135132
context.Author = authorName
136133
else
137134
begin
135+
.ifndef D_PORTABLE
138136
;;No, look in the registry for the value set by InstallShield
139137
authorName = (String)Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Synergex\CodeGen","DefaultAuthor","")
140138
if (!String.IsNullOrWhiteSpace(authorName)) then
@@ -146,6 +144,7 @@ namespace CodeGen.Engine
146144
if (!String.IsNullOrWhiteSpace(authorName))
147145
context.Author = authorName
148146
end
147+
.endc
149148
end
150149

151150
;;Is CODEGEN_COMPANY already set in the environment?
@@ -154,6 +153,7 @@ namespace CodeGen.Engine
154153
context.Company = companyName
155154
else
156155
begin
156+
.ifndef D_PORTABLE
157157
;;No, look in the registry for the value set by InstallShield
158158
companyName = (String)Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Synergex\CodeGen","DefaultCompany","")
159159
if (!String.IsNullOrWhiteSpace(companyName)) then
@@ -165,6 +165,7 @@ namespace CodeGen.Engine
165165
if (!String.IsNullOrWhiteSpace(companyName))
166166
context.Company = companyName
167167
end
168+
.endc
168169
end
169170

170171
endmethod

CodeGenEngine/CommandLineParser.dbl

Lines changed: 55 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -62,93 +62,70 @@ namespace CodeGen.Engine
6262
required in a_opt ,String ;;Option string to search for
6363
required out a_optvals ,@List<String> ;;Returned option values
6464

65-
.define MAXARGS 256
66-
67-
stack record localData
68-
fstatus ,boolean ;;Function return status
69-
command ,a8192 ;;Whole command line
70-
num_args ,i4 ;;Number of arguments in whole command line
71-
arg_pos ,[MAXARGS] i4 ;;Positions of arguments in whole command line
72-
arg_len ,[MAXARGS] i4 ;;Lengths of arguments in whole command line
73-
current_arg ,i4 ;;Index of current argument being processed
74-
opt_char ,a1 ;;Character that precedes options (- or /)
75-
endrecord
76-
77-
.undefine MAXARGS
78-
7965
proc
80-
init localData
81-
data option_value, String
82-
83-
fstatus = false
8466
a_optvals = new List<String>()
67+
68+
data optionFound = false
69+
data optionCharacter = %option(34) ? "/" : "-"
8570

86-
if (%option(34)) then
87-
opt_char = '/'
88-
else
89-
opt_char = '-'
90-
91-
xcall cmdln(command, num_args, arg_pos, arg_len)
92-
93-
for current_arg from 1 thru num_args
94-
begin
95-
if (arg_pos[current_arg]&&arg_len[current_arg]) then
96-
option_value = command(arg_pos[current_arg]:arg_len[current_arg])
97-
else
98-
option_value = ""
99-
100-
;;Is this the requested option?
101-
if (option_value.eqs.(opt_char+a_opt))
102-
call process_argument
103-
end
104-
105-
mreturn fstatus
106-
107-
process_argument,
108-
109-
;;Found requested option
110-
fstatus = true
111-
112-
;;Process next argument
113-
current_arg += 1
114-
115-
if (arg_pos[current_arg]&&arg_len[current_arg]) then
116-
option_value = command(arg_pos[current_arg]:arg_len[current_arg])
117-
else
118-
option_value = opt_char
119-
120-
;;DO NOT CHANGE THE .ne. OPERATOR to != ... THEY ARE NOT THE SAME THING WITH STRING!
121-
while(option_value.ne.opt_char)
71+
data args = Environment.GetCommandLineArgs()
72+
73+
if (args.Length > 1)
12274
begin
123-
;;Strip leading and trailing quote characters
124-
using option_value select
125-
("'", '"'),
75+
data ix, int
76+
data option_value, String
77+
for ix from 2 thru args.Length
12678
begin
127-
if ((option_value.Length>1)&&(option_value(option_value.Length:1)==option_value(1:1)))
79+
option_value = args[ix]
80+
81+
;;Is this the requested option?
82+
if (option_value.eqs.(optionCharacter+a_opt))
12883
begin
129-
if (option_value.Length>2) then
130-
option_value = option_value(2,option_value.Length-1)
131-
else
132-
option_value = ""
133-
end
134-
end
135-
endusing
84+
;;Found requested option
85+
optionFound = true
13686

137-
;;Add the value to the returned collection
138-
a_optvals.Add(option_value)
139-
140-
;;Process next argument
141-
current_arg+=1
87+
;;Are we out of arguments?
88+
if (ix == args.Length)
89+
exitloop
90+
91+
;;Move on to the next argument
92+
option_value = args[ix+=1]
93+
94+
;;DO NOT CHANGE THE .ne. OPERATOR to != ... THEY ARE NOT THE SAME THING WITH STRING!
95+
while(!option_value.StartsWith(optionCharacter))
96+
begin
97+
;;Strip leading and trailing quote characters
98+
using option_value select
99+
("'", '"'),
100+
begin
101+
if ((option_value.Length>1)&&(option_value(option_value.Length:1)==option_value(1:1)))
102+
begin
103+
if (option_value.Length>2) then
104+
option_value = option_value(2,option_value.Length-1)
105+
else
106+
option_value = ""
107+
end
108+
end
109+
endusing
110+
111+
;;Add the value to the returned collection
112+
a_optvals.Add(option_value)
113+
114+
;;Are we out of arguments?
115+
if (ix == args.Length)
116+
exitloop
142117

143-
if (arg_pos[current_arg]&&arg_len[current_arg]) then
144-
option_value = command(arg_pos[current_arg]:arg_len[current_arg])
145-
else
146-
option_value = opt_char
147-
end
118+
;;Move on to the next argument
119+
option_value = args[ix+=1]
120+
end
148121

149-
;;Adjust counter to stay in correct position in loop
150-
current_arg -= 1
151-
return
122+
;;Adjust counter to stay in correct position in loop
123+
ix -= 1
124+
end
125+
end
126+
end
127+
128+
mreturn optionFound
152129

153130
endmethod
154131

0 commit comments

Comments
 (0)