Article View: borland.public.delphi.commandlinetools
Article #72Re: Compile dpr files through code instead of IDE
From: ��������
Date: Mon, 26 Sep 2005 07:13
Date: Mon, 26 Sep 2005 07:13
147 lines
6741 bytes
6741 bytes
Wow.... :^)
// and after file (with name of sResultFilePath value) contains output of
dcc32
"File (with name of sResultFilePath value) contains OUTPUT of dcc32" - its
means, what this file CONTAINS LOG OF COMPILE PROCESS, and correct call for
this function like this:
===============
s := 'H:\Delphi 7 Projects\Commad Line test\Project2.dpr';
ExecDcc32(ExtractFilePath(s), '-Q -B', s, 'H:\Delphi 7 Projects\Commad Line
Test\Project2.err');
===============
Dcc32 by DEFAULT create result file H:\Delphi 7 Projects\Commad Line
Test\Project2.EXE
and now you can analyze contents of 'H:\Delphi 7 Projects\Commad Line
Test\Project2.err, what's happened during compile process...
P.S.: And again - sorry for my bad English...
> s := 'H:\Delphi 7 Projects\Commad Line test\Project2.dpr';
> ExecDcc32(ExtractFilePath(s), '-Q -B', s, 'H:\Delphi 7 Projects\Commad
Line
> Test\Project2.exe');
> end;
>
> Venkatesh
>
> "��������" <tolik@protoka.kiev.ua> wrote in message
> news:433422e3$1@newsgroups.borland.com...
> >
> > s := 'D:\MyProj\MyProg.dpk';
> > ExecDcc32(ExtractFilePath(s), '-Q -B', s, sResultFilePath);
> > // and after file (with name of sResultFilePath value) contains output
of
> > dcc32
> >
> > "Venkatesh VT" <venks@vsnl.com> �������/�������� � �������� ���������:
> > news:4333ee55@newsgroups.borland.com...
> > > Can you just give an example of how to call the function
> > > ExecDcc32(const aDccDir, aOptions, aProjectPath,
> > > > aErrorPath: String): Boolean;
> > > I am not too sure what is working catalog?
> > > Venkatesh
> > > "��������" <tolik@protoka.kiev.ua> wrote in message
> > > news:4333a452@newsgroups.borland.com...
> > > > I'm sorry: version with check path NOT WORKING.
> > > > Belove function is right: :) with comments for params...
> > > > Sorry for my bad English...
> > > >
> > > > function ExecDcc32(const aDccDir, aOptions, aProjectPath,
> > > > aErrorPath: String): Boolean;
> > > > //aDccDir : working catalog, which be set, before running dcc32
> > > > //aOptions: dcc32 options. For more information see output of dcc32
> > > without
> > > > params
> > > > //aProjectPath: path to project, which will be compiled. For
example:
> > > > D:\MyProject\MyProg.dpr
> > > > //aErrorPath: filename of file with dcc32 output
> > > > // Returns string containing path to Delphi command line compiler
> > > > function GetCompilerPath: string;
> > > > var
> > > > Reg: TRegistry;
> > > > begin
> > > > Reg := TRegistry.Create;
> > > > try
> > > > with Reg do begin
> > > > RootKey := HKEY_LOCAL_MACHINE;
> > > > OpenKey('\SOFTWARE\Borland\Delphi\5.0', False);
> > > > Result := ExpandFileName(ReadString('RootDir') +
> > > '\bin\dcc32.exe');
> > > > end;
> > > > if AnsiPos(' ', Result) <> 0 then
> > > > Result := ExtractShortPathName(Result);
> > > > finally
> > > > Reg.Free;
> > > > end;
> > > > end;
> > > > var
> > > > CurDir: String;
> > > > DccDir: String;
> > > > StartupInfo: TStartupInfo;
> > > > ProcessInfo: TProcessInformation;
> > > > hStdOut: THandle;
> > > > SecurAtt: TSecurityAttributes;
> > > > ResultCode: Cardinal;
> > > > i: Integer;
> > > > s: String;
> > > > Dcc32Path: String;
> > > > begin
> > > > Result := True;
> > > > DccDir := aDccDir;
> > > > i := Length(DccDir);
> > > > assert(i <> 0);
> > > > if DccDir[i] in ['/','\'] then
> > > > SetLength(DccDir, i - 1);
> > > > CurDir := GetCurrentDir;
> > > > if DccDir <> ''
> > > > then if not SetCurrentDir(DccDir)
> > > > then raise Exception.Create(SCantChangeDir + DccDir);
> > > > try
> > > > hStdOut := INVALID_HANDLE_VALUE;
> > > > try
> > > > with SecurAtt do begin
> > > > nLength := SizeOf(SecurAtt);
> > > > lpSecurityDescriptor := nil;
> > > > bInheritHandle := BOOL(True);
> > > > end;
> > > > hStdOut := CreateFile(PChar(aErrorPath), GENERIC_WRITE, 0,
> > > > @SecurAtt, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
> > > > if hStdOut = INVALID_HANDLE_VALUE then
> > > > raise Exception.Create(SCantCreateFile + aErrorPath);
> > > > ZeroMemory(@StartupInfo, SizeOf(StartupInfo));
> > > > with StartupInfo do begin
> > > > cb := SizeOf(StartupInfo);
> > > > dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
> > > > wShowWindow := SW_HIDE;
> > > > hStdOutput := hStdOut;
> > > > end;
> > > > s := 'dcc32.exe ' + aOptions + ' ' + aProjectPath;
> > > > Dcc32Path := GetCompilerPath;
> > > > if not CreateProcess(PChar(Dcc32Path),
> > > > PChar(s), @SecurAtt, @SecurAtt,
> > > > BOOL(True), 0, nil, PChar(DccDir), StartupInfo, ProcessInfo)
> > then
> > > > raise Exception.Create(SCantCreateProcess + Dcc32Path);
> > > > WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
> > > > ResultCode := 0;
> > > > GetExitCodeProcess(ProcessInfo.hProcess, ResultCode);
> > > > result := ResultCode = 0;
> > > > finally
> > > > if hStdOut <> INVALID_HANDLE_VALUE then
> > > > CloseHandle(hStdOut);
> > > > end;
> > > > finally
> > > > SetCurrentDir(CurDir);
> > > > end;
> > > > end;
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Technical Details
Message-ID:
<43379f64$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<433230bf$1@newsgroups.borland.com> <43326f74@newsgroups.borland.com> <4332c807$1@newsgroups.borland.com> <4333a452@newsgroups.borland.com> <4333ee55@newsgroups.borland.com> <433422e3$1@newsgroups.borland.com> <4334c55d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: ff8f1,aa302c3a422ff9a1 X-Google-Attributes: gidff8f1,public X-Google-Language: ENGLISH,ASCII From: "��������" <tolik@protoka.kiev.ua> Newsgroups: borland.public.delphi.commandlinetools References: <433230bf$1@newsgroups.borland.com> <43326f74@newsgroups.borland.com> <4332c807$1@newsgroups.borland.com> <4333a452@newsgroups.borland.com> <4333ee55@newsgroups.borland.com> <433422e3$1@newsgroups.borland.com> <4334c55d$1@newsgroups.borland.com> Subject: Re: Compile dpr files through code instead of IDE Date: Mon, 26 Sep 2005 10:13:17 +0300 Lines: 149 Organization: ������� X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 80.78.43.100 Message-ID: <43379f64$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1127718756 80.78.43.100 (26 Sep 2005 00:12:36 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail