Changeset 6 for trunk/UInstance.pas


Ignore:
Timestamp:
Feb 4, 2011, 9:45:01 AM (13 years ago)
Author:
chronos
Message:
  • Modified: Source selection separated to single form.
  • Added: Starting compiler and IDE with updated paths in configuration files.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UInstance.pas

    r5 r6  
    77uses
    88  Classes, SysUtils, USource, Contnrs, Process, Forms, Controls,
    9   FileUtil;
     9  FileUtil, Dialogs;
    1010
    1111type
     
    1414  TInstance = class
    1515  private
     16    function GetCompiled: Boolean;
    1617    function GetDownloaded: Boolean;
    1718  public
    1819    Id: Integer;
    1920    Name: string;
    20     Compiled: Boolean;
    2121    IDESource: TSource;
    2222    IDERevision: string;
     
    2727    procedure Build;
    2828    procedure Start;
     29    procedure UpdateLazarusConfig;
     30    procedure UpdateFPCConfig;
    2931    function GetPath: string;
    3032    property Downloaded: Boolean read GetDownloaded;
     33    property Compiled: Boolean read GetCompiled;
    3134  end;
    3235
     
    5659{ TInstance }
    5760
     61function TInstance.GetCompiled: Boolean;
     62begin
     63  Result := FileExistsUTF8(GetPath + DirectorySeparator + FPCSource.ProjectShortName +
     64    DirectorySeparator + 'bin' + DirectorySeparator +
     65    MainForm.Platform + DirectorySeparator + FPCSource.GetExecutableFile);
     66  if Assigned(IDESource) then Result := Result and
     67    FileExistsUTF8(GetPath + DirectorySeparator + IDESource.ProjectShortName +
     68    DirectorySeparator + IDESource.GetExecutableFile);
     69end;
     70
    5871function TInstance.GetDownloaded: Boolean;
    5972begin
     
    6578procedure TInstance.Build;
    6679begin
    67   OperationProgressForm.Environment := 'path=' + //GetEnvironmentVariable('PATH') + ';' +
    68     MainForm.GetBinUtilsDir;
     80  (*OperationProgressForm.Environment := 'path=' + MainForm.GetBinUtilsDir;
    6981  OperationProgressForm.Path := GetPath + DirectorySeparator + FPCSource.ProjectShortName;
    70   OperationProgressForm.CommandLine :=
    71     '"' + MainForm.GetBinUtilsDir + DirectorySeparator + 'make.exe" clean all PP="' +
    72     MainForm.GetBinUtilsDir + '"';
     82  OperationProgressForm.CommandLine := 'make all PP="' +
     83    MainForm.GetBinUtilsDir + DirectorySeparator + 'fpc"';
    7384  OperationProgressForm.ShowModal;
    7485
     86  OperationProgressForm.Environment := 'path=' + MainForm.GetBinUtilsDir;
    7587  OperationProgressForm.Path := GetPath + DirectorySeparator + FPCSource.ProjectShortName;
    76   OperationProgressForm.CommandLine :=
    77     '"' + MainForm.GetBinUtilsDir + DirectorySeparator + 'make.exe" install PREFIX="' +
     88  OperationProgressForm.CommandLine := 'make install PREFIX="' +
    7889    GetPath + DirectorySeparator + FPCSource.ProjectShortName + '"' +
    79     ' PP="' + MainForm.GetBinUtilsDir + '"';
     90    ' PP="' + MainForm.GetBinUtilsDir + DirectorySeparator + 'fpc"';
    8091  OperationProgressForm.ShowModal;
     92  *)
    8193
    8294  if Assigned(IDESource) then begin
     95    OperationProgressForm.Environment := 'path=' + MainForm.GetBinUtilsDir;
    8396    OperationProgressForm.Path := GetPath + DirectorySeparator + IDESource.ProjectShortName;
    8497    OperationProgressForm.CommandLine :=
    85       '"' + MainForm.GetBinUtilsDir + DirectorySeparator + 'make.exe" bigideclean bigide OPT="-Xg"';
     98      'make bigideclean bigide OPT="-Xg"';
    8699    OperationProgressForm.ShowModal;
    87100  end;
     
    94107  if Assigned(IDESource) then
    95108  try
     109    UpdateFPCConfig;
     110    UpdateLazarusConfig;
    96111    Process := TProcess.Create(nil);
    97112    Process.CurrentDirectory := GetPath + DirectorySeparator + IDESource.ProjectShortName;
    98     Process.CommandLine := IDESource.GetExecutableFile;
     113    Process.CommandLine := GetPath + DirectorySeparator + IDESource.ProjectShortName +
     114      DirectorySeparator + IDESource.GetExecutableFile + ' --primary-config-path=' +
     115      GetPath + DirectorySeparator + IDESource.ProjectShortName +
     116      DirectorySeparator + 'config';
    99117    Process.Execute;
    100118  finally
    101119    Process.Free;
     120  end;
     121end;
     122
     123procedure TInstance.UpdateLazarusConfig;
     124var
     125  Config: TStringList;
     126begin
     127  try
     128    Config := TStringList.Create;
     129    Config.LoadFromFile(MainForm.GetBaseDir + DirectorySeparator +
     130      MainForm.TemplateDir + DirectorySeparator + 'environmentoptions.xml');
     131    Config.Text := StringReplace(Config.Text, '%FPCDir%', GetPath + DirectorySeparator + FPCSource.ProjectShortName, [rfReplaceAll]);
     132    Config.Text := StringReplace(Config.Text, '%BaseDir%', MainForm.GetBaseDir, [rfReplaceAll]);
     133    Config.Text := StringReplace(Config.Text, '%LazarusDir%', GetPath + DirectorySeparator + IDESource.ProjectShortName, [rfReplaceAll]);
     134    Config.Text := StringReplace(Config.Text, '%FPCPlatform%', MainForm.Platform, [rfReplaceAll]);
     135    Config.Text := StringReplace(Config.Text, '%Temp%', GetEnvironmentVariableUTF8('Temp'), [rfReplaceAll]);
     136    Config.SaveToFile(GetPath + DirectorySeparator + IDESource.ProjectShortName +
     137      DirectorySeparator + 'config' + DirectorySeparator + 'environmentoptions.xml');
     138  finally
     139    Config.Free;
     140  end;
     141end;
     142
     143procedure TInstance.UpdateFPCConfig;
     144var
     145  Config: TStringList;
     146begin
     147  try
     148    Config := TStringList.Create;
     149    Config.LoadFromFile(MainForm.GetBaseDir + DirectorySeparator +
     150      MainForm.TemplateDir + DirectorySeparator + 'fpc.cfg');
     151    Config.Text := StringReplace(Config.Text, '$(FPCDir)', GetPath +
     152      DirectorySeparator + FPCSource.ProjectShortName, [rfReplaceAll]);
     153    Config.SaveToFile(GetPath + DirectorySeparator + FPCSource.ProjectShortName +
     154      DirectorySeparator + 'bin' + DirectorySeparator +
     155      MainForm.Platform + DirectorySeparator + 'fpc.cfg');
     156  finally
     157    Config.Free;
    102158  end;
    103159end;
Note: See TracChangeset for help on using the changeset viewer.