OmniPascal 0.13.0 – Load project, compile and run

Load a project, compile and run

Introducing automatic build script generation

You are now able to load a project file in Visual Studio Code. You can either click the new OmniPascal project indicator in the status bar or execute the new command OmniPascal: Load project. Pick a .dpr, .dpk, .lpr or .lpk file to open it. When it’s done you will see the currently loaded project file in the status bar.

The search path will be adjusted automatically when you open a project file.
If the new setting omnipascal.createBuildScripts is set to true (it’s false by default) then a tasks.json file and a .bat file will be generated as soon as a project is loaded or the currently loaded project file changes. The generated tasks.json defines both a build task and a test task. The build task will simply compile the loaded project while the test task will start the compiled application with the run parameters defined in the .dproj or .lpi file. If there is no .dproj or .lpi file for the project then OmniPascal won’t create a build script. So there are no auto generated build scripts for old Delphi projects.

The generated build scripts rely on MSBuild for Delphi projects and LazBuild for Lazarus projects. OmniPascal needs to know the location of these applications in order to work properly.
The path to MSBuild is defined in the setting omnipascal.msbuildPath. If no path is defined OmniPascal will try to find the path by itself.
The path to LazBuild is be defined in omnipascal.lazbuildPath.

Changes in the OmniPascal settings are not reflected on the fly. You need to restart Visual Studio Code or execute the command Reload Window when you change settings!

IMPORTANT CHANGES
– The settings namespace used for OmniPascal is no longer objectpascal but it’s omnipascal. You need to change the settings in Visual Studio Code. For example: The setting objectpascal.delphiInstallationPath has to be changed to omnipascal.delphiInstallationPath.
– The path to the FreePascal source files is no longer stored in objectpascal.delphiInstallationPath. It’s now stored in omnipascal.freePascalSourcePath.
– FreePascal users need to set omnipascal.defaultDevelopmentEnvironment to FreePascal. The default value is Delphi.

Change log

Features
– Ability to load a project file
– Automatically adjust search path when opening a project file (loaded from .dproj and .lpi files)
– Automatic creation of tasks.json and a build script when loading a project that has a corresponding .dproj or .lpi file
– If DelphiInstallationPath is not defined in the settings then OmniPascal looks for the most recent Delphi installation path itself

Bugfixes
– Fixed visibility of symbols defined in System.pas
– Aliases of full qualified types are now handled properly
– Fixed possible stack overflow when working with a generic class defined in the implementation section
– Fixed random crashes
– Parameterless calls to WriteLn, Write, ReadLn and Read can now be resolved
– Outlining in files with syntax errors works better
– Hints for constants of empty strings are now correct
– Implementations of overloaded methods could not be found when an alias for a parameter type is used in the implementation while the declaration uses the original type name
– Fixed internal error when code completion was requested for objects of a type that could not be resolved
– Fixed broken syntax highlighting for Self, Result and some keywords.

You Might Also Like

19 Comments

  • Bascy

    February 28, 2017

    Sounds like a fanatastic extension of this extension …
    But when I try it, this is the result:

    Running the contributed command:’omnipascal.loadProject’ failed.

    Reply
    • Wosi

      February 28, 2017

      That’s not good. It works fine on multiple machines. Does it help when you uninstall and reinstall the extension? What kind of porject file do you open? Delphi XE or higher? Lazarus?

      Reply
    • Wosi

      February 28, 2017

      Does this error still occur when you have a .pas file open in the editor while attempting to load a project?

      Reply
      • Bascy

        February 28, 2017

        I tried uninstalling and installing, that didnt help.

        I get an error “Command ‘omnipascal.LoadProject’ not found when I start the command from an empty editor, running the command from the Ctrl-Shift-P line.

        I’ll do some more testing this evening

        Reply
        • Wosi

          February 28, 2017

          VScode extensions are not properly initialized when there is no file open. I guess everything will work fine when you open a DPR or PAS file before you try to open a project.

          Reply
  • Bascy

    February 28, 2017

    Another small problem ….
    The compile batch file is calling rsvars.bat without any path. This doesnt work good if Embarcadero is not on the path or you have multiple versions installed. I think the rsvars call should be preceeded by the delphi installation path setting

    Reply
  • Bascy

    February 28, 2017

    a third suggestion ….
    The default build configuration of Rad studio is “Release” and not “Make”

    Is there a way to alter the template from which the compile script is fabricated? That would allow anyone to tailor it ot there own configurations and needs

    Reply
  • Gereksiz

    August 22, 2018

    Why i’m getting this error ? “command ‘omnipascal.loadProject’ not found” (OmniPascal – Open Preview
    0.16.1 installed)

    Reply
    • Wosi

      August 22, 2018

      You probably tried to open a project before the OmniPascal plugin has been activated by VSCode.
      Open a .pas or .dpr file before trying to load a project. That should solve the problem.

      Reply
      • René

        October 25, 2018

        I have the same problem. The OmniPascal plugin is activated. When I open a .pas file and then issue the command Omnipascal: Load project, I Always get the error “command ‘omnipascal.loadProject’ not found”, no matter what I try.
        Any suggestions?

        Reply
        • Wosi

          October 25, 2018

          When you open a .pas file which language mode is displayed at the bottom right? Is it “ObjectPascal”? If not then OmniPascal is not configured to be the default plugin for .pas files thus it never gets activated.
          Do you have other plugins installed that work with .pas files? Try to deactivate them.

          Reply
          • René

            October 25, 2018

            It is ObjectPascal and I have no other extensions installed

          • Wosi

            October 25, 2018

            Hmm..do you see the text “OmniPascal: no project loaded” at the bottom? What do you see when you click on it?

  • dalibro

    September 23, 2018

    Hello,

    I am expreriencing difficulties when trying to load project. I have a .pas file created in Lazarus opened and when I type “Omnipascal : Load Project” in the console, no files show which I could select.
    When running “Run test task”, I get “No test task to run found. Configure Tasks…”

    I’m using Windows 10 64 bit, FPC and Lazarus. I have everything set up correctly.

    Thank you for answering

    Reply
    • Wosi

      September 23, 2018

      OmniPascal is looking for Lazarus project files (.lpr, .lpi). Build and test tasks utilize Lazbuild for compilation.
      So you either need to create a Lazarus project for your .pas file or you need to create VSCode’s tasks.json manually.

      Reply
  • Pablo Ramon P Garay

    October 29, 2018

    Try this. Open the folder where your project is. Open the .dpr file in the editor. F1: OmniPascal -> load project. It will list the .dpr and .dproj project files. Select the appropriate file.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *