View Issue Details

IDProjectCategoryView StatusLast Update
0015353LazarusOtherpublic2018-01-09 18:43
ReporterChris RordenAssigned ToMattias Gaertner 
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status closedResolutionfixed 
Product Version0.9.28.3 (SVN)Product Build 
Target VersionFixed in Version0.9.31 (SVN) 
Summary0015353: lazbuild feature request
DescriptionHello,
 I would like to specify compiler commands with Lazbuild. For example, to compile OSX programs on 10.6 to run on older versions of of OSX I can do this in the IDE:
 Add to Project / Compiler options / Other / Custom options:
  -k-macosx_version_min -k10.4
  -XR/Developer/SDKs/MacOSX10.4u.sdk/
However, my code is no longer portable, as this will not compile on Linux, Windows. On solution would be to modify Lazbuild to accept compiler options, e.g.
   lazbuild ./dcm2nii/dcm2nii.lpr="-va -k-macosx_version_min -k10.4 -XR/Developer/SDKs/MacOSX10.4u.sdk/"

However, at the moment this does not compile any visual projects (though I saw this mentioned regarding rebuilding the IDE).

Another option: is there a way to do {$IFDEF Darwin} in the Project / Compiler options / Other / Custom options

thanks
TagsNo tags attached.
Fixed in Revision
LazTarget0.99.0
WidgetsetCarbon
Attached Files
  • lazbuild.patch (3,436 bytes)
    Index: ide/lazbuild.lpr
    ===================================================================
    --- ide/lazbuild.lpr	(Revision 27644)
    +++ ide/lazbuild.lpr	(Arbeitskopie)
    @@ -48,6 +48,7 @@
         FBuildIDEOptions: string;
         FBuildRecursive: boolean;
         fCompilerOverride: String;
    +    fCustomOptionsOverride: String;
         fLazarusDirOverride : String;
         fCPUOverride: String;
         fOSOverride: String;
    @@ -135,6 +136,7 @@
         property CPUOverride: String read fCPUOverride write fCPUOverride;
         property CompilerOverride: String read fCompilerOverride write fCompilerOverride;
         property LazarusDirOverride: String read fLazarusDirOverride write fLazarusDirOverride;
    +    property CustomOptionsOverride: String read fCustomOptionsOverride write fCustomOptionsOverride;
       end;
     
     var
    @@ -278,6 +280,7 @@
       Result:=mrCancel;
     end;
     
    +
     function TLazBuildApplication.BuildFile(Filename: string): boolean;
     begin
       Result:=false;
    @@ -330,6 +333,8 @@
         APackage.CompilerOptions.TargetCPU:=CPUOverride;
       if (Length(WidgetSetOverride) <> 0) then
         APackage.CompilerOptions.LCLWidgetType:=WidgetSetOverride;
    +  if (Length(CustomOptionsOverride) <> 0) then
    +    APackage.CompilerOptions.CustomOptions:=CustomOptionsOverride;
     
       CompilePackage(APackage,Flags);
       
    @@ -612,6 +617,8 @@
         Project1.CompilerOptions.TargetCPU:=CPUOverride;
       if (Length(WidgetSetOverride) <> 0) then
         Project1.CompilerOptions.LCLWidgetType:=WidgetSetOverride;
    +  if (Length(CustomOptionsOverride) <> 0) then
    +    Project1.CompilerOptions.CustomOptions:=CustomOptionsOverride;
       MainBuildBoss.SetBuildTarget(Project1.CompilerOptions.TargetOS,
         Project1.CompilerOptions.TargetCPU,Project1.CompilerOptions.LCLWidgetType);
     
    @@ -1057,6 +1064,7 @@
         LongOptions.Add('cpu:');
         LongOptions.Add('compiler:');
         LongOptions.Add('lazarusdir:');
    +    LongOptions.Add('custom-options:');
         ErrorMsg:=RepairedCheckOptions('lBrd',LongOptions,Options,NonOptions);
         if ErrorMsg<>'' then begin
           writeln(ErrorMsg);
    @@ -1122,6 +1130,10 @@
         if HasOption('lazarusdir') then
           LazarusDirOverride := GetOptionValue('lazarusdir');
     
    +    //custom
    +    if HasOption('custom-options') then
    +      CustomOptionsOverride := GetOptionValue('custom-options');
    +
       finally
         Options.Free;
         NonOptions.Free;
    @@ -1183,6 +1195,13 @@
         lisOverrideTheDefaultCompilerEGPpc386Ppcx64PpcppcEtcD, [space]),
                           75, 22)));
       writeln('');
    +  writeln('--custom-options=<options>');
    +  writeln(UTF8ToConsole(BreakString(Format(
    +    lisOverrideTheProjectCustomOptions, [space,
    +    LazConf.GetDefaultTargetOS]),
    +                      75, 22)));
    +
    +  writeln('');
       writeln(LanguageOpt);
       writeln(UTF8ToConsole(BreakString(space+lisOverrideLanguage,75, 22)));
     end;
    Index: ide/lazarusidestrconsts.pas
    ===================================================================
    --- ide/lazarusidestrconsts.pas	(Revision 27644)
    +++ ide/lazarusidestrconsts.pas	(Arbeitskopie)
    @@ -4606,6 +4607,7 @@
       lisOverrideTheDefaultCompilerEGPpc386Ppcx64PpcppcEtcD = '%soverride the '
         +'default compiler. e.g. ppc386 ppcx64 ppcppc etc. default is stored in '
         +'environmentoptions.xml';
    +  lisOverrideTheProjectCustomOptions = '%soverride the custom options passed to fpc';
       lisNo = 'No';
       lisProjectChangedOnDisk = 'Project changed on disk';
       lisTheProjectInformationFileHasChangedOnDisk = 'The project information '
    
    lazbuild.patch (3,436 bytes)

Relationships

related to 0017277 resolvedJuha Manninen A few extra flags for lazbuild 

Activities

Dmitry Boyarintsev

2009-12-15 22:37

developer   ~0033119

Last edited: 2009-12-15 22:39

do you suggest platform specific compiler options?
for now you can use different project (.lpi) file (with different options), while the code of the project would remain the same

LinuxPrj.lpi -> Prj.lpr
DarwinPrj.lpi -> Prj.lpr
WinPrj.lpi -> Prj.lpr

Andreas Schneider

2009-12-18 14:59

reporter   ~0033172

I think what the reporter means (and what I would also prefer) is a lazbuild parameter that allows the pass-through of additional params to the underlying fpc. Something like lazbuild --opt="-XX -CX -Xs" project.lpi

2010-10-11 00:22

 

lazbuild.patch (3,436 bytes)
Index: ide/lazbuild.lpr
===================================================================
--- ide/lazbuild.lpr	(Revision 27644)
+++ ide/lazbuild.lpr	(Arbeitskopie)
@@ -48,6 +48,7 @@
     FBuildIDEOptions: string;
     FBuildRecursive: boolean;
     fCompilerOverride: String;
+    fCustomOptionsOverride: String;
     fLazarusDirOverride : String;
     fCPUOverride: String;
     fOSOverride: String;
@@ -135,6 +136,7 @@
     property CPUOverride: String read fCPUOverride write fCPUOverride;
     property CompilerOverride: String read fCompilerOverride write fCompilerOverride;
     property LazarusDirOverride: String read fLazarusDirOverride write fLazarusDirOverride;
+    property CustomOptionsOverride: String read fCustomOptionsOverride write fCustomOptionsOverride;
   end;
 
 var
@@ -278,6 +280,7 @@
   Result:=mrCancel;
 end;
 
+
 function TLazBuildApplication.BuildFile(Filename: string): boolean;
 begin
   Result:=false;
@@ -330,6 +333,8 @@
     APackage.CompilerOptions.TargetCPU:=CPUOverride;
   if (Length(WidgetSetOverride) <> 0) then
     APackage.CompilerOptions.LCLWidgetType:=WidgetSetOverride;
+  if (Length(CustomOptionsOverride) <> 0) then
+    APackage.CompilerOptions.CustomOptions:=CustomOptionsOverride;
 
   CompilePackage(APackage,Flags);
   
@@ -612,6 +617,8 @@
     Project1.CompilerOptions.TargetCPU:=CPUOverride;
   if (Length(WidgetSetOverride) <> 0) then
     Project1.CompilerOptions.LCLWidgetType:=WidgetSetOverride;
+  if (Length(CustomOptionsOverride) <> 0) then
+    Project1.CompilerOptions.CustomOptions:=CustomOptionsOverride;
   MainBuildBoss.SetBuildTarget(Project1.CompilerOptions.TargetOS,
     Project1.CompilerOptions.TargetCPU,Project1.CompilerOptions.LCLWidgetType);
 
@@ -1057,6 +1064,7 @@
     LongOptions.Add('cpu:');
     LongOptions.Add('compiler:');
     LongOptions.Add('lazarusdir:');
+    LongOptions.Add('custom-options:');
     ErrorMsg:=RepairedCheckOptions('lBrd',LongOptions,Options,NonOptions);
     if ErrorMsg<>'' then begin
       writeln(ErrorMsg);
@@ -1122,6 +1130,10 @@
     if HasOption('lazarusdir') then
       LazarusDirOverride := GetOptionValue('lazarusdir');
 
+    //custom
+    if HasOption('custom-options') then
+      CustomOptionsOverride := GetOptionValue('custom-options');
+
   finally
     Options.Free;
     NonOptions.Free;
@@ -1183,6 +1195,13 @@
     lisOverrideTheDefaultCompilerEGPpc386Ppcx64PpcppcEtcD, [space]),
                       75, 22)));
   writeln('');
+  writeln('--custom-options=<options>');
+  writeln(UTF8ToConsole(BreakString(Format(
+    lisOverrideTheProjectCustomOptions, [space,
+    LazConf.GetDefaultTargetOS]),
+                      75, 22)));
+
+  writeln('');
   writeln(LanguageOpt);
   writeln(UTF8ToConsole(BreakString(space+lisOverrideLanguage,75, 22)));
 end;
Index: ide/lazarusidestrconsts.pas
===================================================================
--- ide/lazarusidestrconsts.pas	(Revision 27644)
+++ ide/lazarusidestrconsts.pas	(Arbeitskopie)
@@ -4606,6 +4607,7 @@
   lisOverrideTheDefaultCompilerEGPpc386Ppcx64PpcppcEtcD = '%soverride the '
     +'default compiler. e.g. ppc386 ppcx64 ppcppc etc. default is stored in '
     +'environmentoptions.xml';
+  lisOverrideTheProjectCustomOptions = '%soverride the custom options passed to fpc';
   lisNo = 'No';
   lisProjectChangedOnDisk = 'Project changed on disk';
   lisTheProjectInformationFileHasChangedOnDisk = 'The project information '
lazbuild.patch (3,436 bytes)

Benito van der Zander

2010-10-11 00:22

reporter   ~0041713

I added a patch for this behaviour

Benito van der Zander

2010-10-11 00:27

reporter   ~0041714

It adds an parameter to override the custom options of the project, so it has no effect if you compile the IDE with it.
It would be more consistent if the new option would also set the Lazarus ExtraOptions, and the old "--build-ide=<options>" would be marked as deprecated.

Zeljan Rikalo

2010-11-19 22:18

developer   ~0043278

Isn't this fixed by build modes ? You can create different build modes with different targets and add specific options.
(if I correctly understood your explanation).

Vincent Snijders

2010-11-19 22:23

manager   ~0043279

Build modes solve part of the problem, but are not capable of adding ad hoc parameters.

Felipe Monteiro de Carvalho

2011-10-02 16:43

developer   ~0052361

I consider that build modes are enough to consider the issue fixed. The original reporter can reopen if he is still not satisfied.

Chris Rorden

2018-01-09 18:43

reporter   ~0105589

Fixed.

Issue History

Date Modified Username Field Change
2009-12-15 22:31 Chris Rorden New Issue
2009-12-15 22:31 Chris Rorden Widgetset => Carbon
2009-12-15 22:37 Dmitry Boyarintsev Note Added: 0033119
2009-12-15 22:39 Dmitry Boyarintsev Note Edited: 0033119
2009-12-17 14:27 Vincent Snijders LazTarget => -
2009-12-17 14:27 Vincent Snijders Assigned To => Mattias Gaertner
2009-12-17 14:27 Vincent Snijders Status new => acknowledged
2009-12-17 14:28 Vincent Snijders Assigned To Mattias Gaertner =>
2009-12-18 14:59 Andreas Schneider Note Added: 0033172
2010-10-11 00:22 Benito van der Zander File Added: lazbuild.patch
2010-10-11 00:22 Benito van der Zander Note Added: 0041713
2010-10-11 00:27 Benito van der Zander Note Added: 0041714
2010-10-29 12:14 Vincent Snijders Relationship added related to 0017277
2010-10-29 12:14 Vincent Snijders LazTarget - => 0.9.30
2010-10-29 12:14 Vincent Snijders Assigned To => Mattias Gaertner
2010-10-29 12:14 Vincent Snijders Status acknowledged => assigned
2010-10-29 12:14 Vincent Snijders Target Version => 0.9.30
2010-11-19 22:18 Zeljan Rikalo Note Added: 0043278
2010-11-19 22:18 Zeljan Rikalo Status assigned => feedback
2010-11-19 22:23 Vincent Snijders Note Added: 0043279
2010-12-12 21:33 Vincent Snijders LazTarget 0.9.30 => 0.99.0
2010-12-12 21:33 Vincent Snijders Status feedback => assigned
2010-12-12 21:33 Vincent Snijders Target Version 0.9.30 => 0.99.0
2011-10-02 16:43 Felipe Monteiro de Carvalho Status assigned => resolved
2011-10-02 16:43 Felipe Monteiro de Carvalho Fixed in Version => 0.9.31 (SVN)
2011-10-02 16:43 Felipe Monteiro de Carvalho Resolution open => fixed
2011-10-02 16:43 Felipe Monteiro de Carvalho Note Added: 0052361
2018-01-09 18:43 Chris Rorden Note Added: 0105589
2018-01-09 18:43 Chris Rorden Status resolved => closed