+ compile time variables can be given on the command line

git-svn-id: trunk@923 -
This commit is contained in:
olle 2005-08-22 19:34:54 +00:00
parent bf505f4d12
commit 2a5e6d7b92
2 changed files with 39 additions and 2 deletions

View File

@ -603,8 +603,13 @@ begin
'd' :
if more <> '' then
def_system_macro(more);
begin
l:=Pos(':=',more);
if l>0 then
set_system_compvar(Copy(more,1,l-1),Copy(more,l+2,255))
else
def_system_macro(more);
end;
'D' :
begin
include(initglobalswitches,cs_link_deffile);

View File

@ -227,6 +227,7 @@ interface
{Name can be given in any case (it will be converted to upper case).}
procedure def_system_macro(const name : string);
procedure set_system_macro(const name, value : string);
procedure set_system_compvar(const name, value : string);
procedure undef_system_macro(const name : string);
{*** symtable stack ***}
@ -2321,6 +2322,37 @@ implementation
mac.defined:=true;
end;
procedure set_system_compvar(const name, value : string);
var
mac : tmacro;
s: string;
begin
if name = '' then
internalerror(2004121201);
s:= upper(name);
mac:=tmacro(search_macro(s));
if not assigned(mac) then
begin
mac:=tmacro.create(s);
mac.is_compiler_var:=true;
if macrosymtablestack.symtabletype=localmacrosymtable then
macrosymtablestack.insert(mac)
else
macrosymtablestack.next.insert(mac)
end
else
begin
mac.is_compiler_var:=true;
if assigned(mac.buftext) then
freemem(mac.buftext,mac.buflen);
end;
Message2(parser_c_macro_set_to,mac.name,value);
mac.buflen:=length(value);
getmem(mac.buftext,mac.buflen);
move(value[1],mac.buftext^,mac.buflen);
mac.defined:=true;
end;
procedure undef_system_macro(const name : string);
var
mac : tmacro;