Recent

Author Topic: Documentation on compiling project using command line?  (Read 3362 times)

MISV

  • Hero Member
  • *****
  • Posts: 804
Documentation on compiling project using command line?
« on: May 22, 2024, 11:36:02 pm »
What is the best resource for command line usage?

Select project. Select release define. Compile. I do not need much really. I can use this for both Mac and Windows. I need to automate everything because otherwise I will mess up :)

I need to setup a build process bat file or similar on my Mac


TRon

  • Hero Member
  • *****
  • Posts: 3650
Re: Documentation on compiling project using command line?
« Reply #1 on: May 23, 2024, 09:03:23 am »
What is the best resource for command line usage?
This is the best Free Pascal command-line reference information there is.
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

MISV

  • Hero Member
  • *****
  • Posts: 804
Re: Documentation on compiling project using command line?
« Reply #2 on: May 23, 2024, 09:58:49 am »
Thank you. I will check it out.

It is unfortunate there isn't a Lazarus commandline... That could load project and compile


TIP for other

I looked into messages when compiling > right click > about compile project


There one can see all information including a *huge* command line instruction. I will use that start case. I will report back


TRon

  • Hero Member
  • *****
  • Posts: 3650
Re: Documentation on compiling project using command line?
« Reply #3 on: May 23, 2024, 10:02:20 am »
It is unfortunate there isn't a Lazarus commandline... That could load project and compile
oh, but there is. It is that you posted this in the Free Pascal subforum  :)

It is named lazbuild and afaik that is the definitive guide to using it (yes, it is indeed a bit scarce)
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

MISV

  • Hero Member
  • *****
  • Posts: 804
Re: Documentation on compiling project using command line?
« Reply #4 on: May 23, 2024, 10:42:32 am »
Thank you :)

It is actually very close I have gotten it working calling FPC directly...



If all .lib files already has been generated by Lazarus earlier (in my command line script I am actually removing these before building to ensure 100% all of my code gets recompiled with updated defines found in include files.)

Then... it actually compiles the executable on MacOS (one has to change directory to the project directory first if using the command line grabbed from the "Messages > About compile project") and... it appears to run without errors

...

However if I remove .lib files from a shared source directory (not placed in project directory) it stumbles:


Code: Pascal  [Select][+][-]
  1. Hint: (11030) Start of reading config file /Users/myname/TS/LazarusCocoa64/fpc/bin/x86_64-darwin/fpc.cfg
  2. Hint: (11031) End of reading config file /Users/myname/TS/LazarusCocoa64/fpc/bin/x86_64-darwin/fpc.cfg
  3. Free Pascal Compiler version 3.2.2-r0d122c49 [2024/05/11] for x86_64
  4. Copyright (c) 1993-2021 by Florian Klaempfl and others
  5. (1002) Target OS: Darwin for x86_64
  6. (3104) Compiling MyProjectOSX.dpr
  7. (3104) Compiling /Volumes/DiskW/shared-code/MySharedSource Suite/C_SHAREDmsGenericStruct.pas
  8. (3104) Compiling /Volumes/DiskW/shared-code/MySharedSource Suite/UmsSysDeclars.pas
  9. (3104) Compiling /Volumes/DiskW/shared-code/MySharedSource Suite/UmsSysExceptions.pas
  10. UmsSysExceptions.pas(45) Error: (9002) Can't create assembler file: /Volumes/DiskW/projects/MyProject/lib/x86_64-darwin/UmsSysExceptions.s
  11. UmsSysExceptions.pas(45) Error: (1026) Compilation raised exception internally
  12. Fatal: (1024) I/O error: File not open
  13. Error: /Users/myname/TS/LazarusCocoa64/fpc/bin/x86_64-darwin/ppcx64 returned an error exitcode
  14. MyName@MyComp MyProject %
  15.  

Any ideas what to try? Kinda peculiar problem occurs when running commandline and not when Lazarus runs command line. Maybe Lazarus does some preparation I am not yet duplicating fully.



This is the entire unit by the way:

Code: Pascal  [Select][+][-]
  1. unit UmsSysExceptions;
  2. {$I AImsCoreDefines.inc}
  3. interface
  4. uses
  5.   SysUtils
  6.   ;
  7. type
  8.   EmsException = class(Exception);
  9.   EmsNotSupportedInOS = class(EmsException);
  10.   EmsNotSupportedInDevToolVersionOS = class(EmsException);
  11.   EmsParamWrong = class(EmsException);
  12.   EmsParamTypeWrong = class(EmsParamWrong);
  13.   EmsParamOutOfValidRangeError = class(EmsParamWrong);
  14.   EmsParamsOutOfValidRangeError = class(EmsParamWrong);
  15.   EmsParamsMisMatchError = class(EmsException);
  16.   EmsMissingRequiredHandler = class(EmsException);
  17.   EmsPointerRefNotAssigned = class(EmsException);
  18.   EmsValueOutOfValidRangeError = class(EmsException);
  19.   EmsValueOutOfUsualRangeError = class(EmsException);
  20.   EmsValuesMisMatchError = class(EmsException);
  21.   EmsOperationNotPossible = class(EmsException);
  22.   EmsOperationNotPossibleUnknownReason = class(EmsOperationNotPossible);
  23.   EmsNonExpectedError = class(EmsException);
  24.   EmsReturnValueOutOfValidRangeError = class(EmsException);
  25.   EmsReturnValueNotAssignedError = class(EmsException);
  26.   EmsNotTested = class(EmsException);
  27.   EmsNotErrorJustTempTestSeeIfHappensAsItShouldHere = class(EmsException);
  28.   EmsNotErrorJustTempTestSeeIfHappensAsItShouldNotHere = class(EmsException);
  29.   EmsFileExistsNo = class(EmsException);
  30.   EmsFileExistsYes = class(EmsException);
  31.   //--
  32.   EmsProgramStateWrongCKD = class(EmsException); // see unit *CKmsKVT*
  33.   EmsProgramStateWrongMOD = class(EmsException); // see unit *CKmsKVT*
  34.   EmsAppFileHealthIssueKEF = class(EmsException); // see unit *UKmsKE*
  35.  
  36. //------------------------------------------------------------------------------
  37. implementation
  38.  
  39.  
  40. end.
  41.  


As can be seen the declarations are some general ones I use for own purposes.
« Last Edit: May 23, 2024, 02:41:02 pm by MISV »

Thaddy

  • Hero Member
  • *****
  • Posts: 16198
  • Censorship about opinions does not belong here.
Re: Documentation on compiling project using command line?
« Reply #5 on: May 23, 2024, 04:28:27 pm »
There will be still an issue between the different (cross) compilers and options.
I am working on a small utility that shows what a specific compiler or cross-compller actually supports.
Will post it here.

Reason: the number of options available are dependent  on the platform for which the compiler is supposed to compile.
And the way I approached it always get the information from the compiler itself, so it documents more current than the documentation. Will post a bit later....
It basically filters all the -i<x> output. Since that info is taken from the compiler itself, it is always more current about available options.
( main reason: I am almost always on trunk/main )
« Last Edit: May 23, 2024, 04:35:00 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

MISV

  • Hero Member
  • *****
  • Posts: 804
Re: Documentation on compiling project using command line?
« Reply #6 on: May 23, 2024, 08:51:45 pm »
Quick note: In this case both the command line compilation and Lazarus compilation is on Mac (so no cross compilation), so should be 100% the same. I will try experiment. Maybe Lazarus is doing some cleanup before calling the FPC compiler


MISV

  • Hero Member
  • *****
  • Posts: 804
Re: Documentation on compiling project using command line?
« Reply #7 on: May 23, 2024, 10:47:50 pm »
I solved this myself:

Code: Pascal  [Select][+][-]
  1. UmsSysExceptions.pas(45) Error: (9002) Can't create assembler file: /Volumes/DiskW/projects/MyProject/lib/x86_64-darwin/UmsSysExceptions.s

Simply make sure
/Volumes/DiskW/projects/MyProject/lib/x86_64-darwin/
directory exists

...

Now getting other erros, but I am making progress. Hopefully this thread will become useful to other who want to use commandline. (So extremely helpful one can see in Lazarus Message right click menu the entire commandline used.)

Thaddy

  • Hero Member
  • *****
  • Posts: 16198
  • Censorship about opinions does not belong here.
Re: Documentation on compiling project using command line?
« Reply #8 on: May 24, 2024, 08:55:36 am »
Screenshot. almost finished: open the compiler for what you need the options from and it tells you what the options are and what is supported.
I will add the project later today.
You will open the compiler of choice and the program gives you an overview for that specific compiler.
This *should* work for any compiler from the 3.x.x series.
« Last Edit: May 24, 2024, 08:59:07 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11947
  • FPC developer.
Re: Documentation on compiling project using command line?
« Reply #9 on: May 24, 2024, 12:52:31 pm »
What is the best resource for command line usage?
This is the best Free Pascal command-line reference information there is.

If you use the makefiles to build FPC rather than manual invocations, I'd suggest the buildfaq, old as it is.

 

TinyPortal © 2005-2018