.pas file with `program` keyword should be treated as a project

Issue #68 wontfix
Mr Bee created an issue

Hi,

First of all, I thank you for making OmniPascal works on Mac and Linux, finally. I've been waiting for this for quite a while.

However, it seems that OmniPascal doesn't recognize a simple pascal file as a project, using the program keyword. Not every pascal project is using .lpr or .dpr extension, you know. In fact, OmniPascal should detect a pascal project file not by the extension, but by the program keyword. That's what the program keyword is for. And that's exactly what .lpr or .dpr is doing.

If OmniPascal would support .pas file with program keyword as a project file, please don't make it as strict as unit keyword. I mean, in FPC at least, you may have –for example– a file named project1.pas while the program statement written as program MyFirstProject;. This shouldn't be an error because it will be still compiled just fine. Treat it as a hint would be alright.

I hope this would be supported soon. Thank you.

Regards,

~Bee

Comments (5)

  1. Christopher Wosinski repo owner

    Today OmniPascal is able

    • to list project files (depending on file extensions)
    • to open a project (depending on file extensions)
    • to generate build scripts based on lazbuild for Lazarus projects and msbuild for Delphi projects

    What would it take to support projects in .pas files?

    • The project file picker would have to look into every single .pas file in the workspace in order to know whether it's a unit or a program. That would take a lot of time.
    • The build scripts based on lazbuild dont't work on this kind of project. So there would be a need to provide a third build script type that generates direct calls to the Free Pascal Compiler. That is basically what lazbuild does today.

    To be honest, I don't see any benefit in supporting plain FP projects. In the Free Pascal world I see Lazarus project as the way to go when you want to have convenient build tools. In short: I'm sorry, OmniPascal won't support these projects in the near future.

    But you can create build scripts for your projects manually:

    • Set "omnipascal.createBuildScrípts: true" and reload VSCode
    • Open a .lpr project file with OmniPascal
    • Set "omnipascal.createBuildScrípts: false" and reload VSCode
    • Edit CompileOmniPascalProject.sh so that it calls fpc instead of lazbuild for the project you are working with.

    Now you should be able to work with your FP projects. In case this is too much work for you then consider going over to .lpr and .lpi files for your projects.

  2. Mr Bee reporter

    Alright, I can understand the reasonings. As a workaround, let's make a new file extension .ppr for "pascal project", accompanying the already supported .pp extension for "pascal program". Because I don't want to mess around with the accepted .lpr for "lazarus project" and .dpr for "delphi project", but I still need my plain pascal projects to be recognized.

    Renaming my pascal projects from .pas to .ppr would be my own problem. I can handle it.

    What do you think?

  3. Christopher Wosinski repo owner

    What do you want achieve with opening such a project? Since it can't be compiled with lazbuild OmniPascal won't be able to create a build task for it. So when you open a plain Pascal project OmniPascal would only adjust its internal search path so that units listed in the project's main uses clause are being found first.

    If that is important to you then I think it would make more sense to create a new command like "Load currently opened Pascal project file" that allows you to load a project file regardless its extension. Would that fit your needs?

  4. Mr Bee reporter

    Because I don't use Lazarus, for some reasons. I don't have lazbuild to begin with. I made my own shell script to build my projects. I think "Load currently opened Pascal file as project" command would be fine. Thank you.

    One more thing… is there a way to obtain current project file name? Similar to ${fileBasename} and ${fileBasenameNoExtension} like ${projectFileBasename} and ${projectFileBasenameNoExtension}.

    When I'm using many unit files in a Pascal project, most of the time I'm working on the unit files. If I want to build the project through custom build task, I have to switch the editor to the project file so the task could pick the correct project file to be compiled. I need the task to be able to pick the project file name although the editor doesn't focus on the file, as long as the project file has been determined. Is that possible?

  5. Log in to comment