GithubHelp home page GithubHelp logo

libaud / poci Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 161 KB

Pascal Object Compiler Informations, a library for getting compiler informations (CPU, Target, Version...)

Pascal 100.00%

poci's Introduction

Pascal Object Compiler Information (POCI) is a code library. Its objective is to provide all the necessary elements to offer the possibility to know at runtime the compiler, the environment (Delphi, Lazarus, Typhon, the framework version. By generating these at the time of construction.

Using

To use the POCI library, simply include the poci.inc file in the project source file (*.ctpr, *.dpr, .ppr). The instruction is as follows:

{$i poci.inc}

Example :

program POCISample;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  Classes, SysUtils, CustApp
  { you can add units after this };

...

{$i poci.inc}

...

type

  { TPOCISample }

  TPOCISample = class(TCustomApplication)
  protected
    procedure DoRun; override;
  public
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
    procedure WriteHelp; virtual;
  end;

{ TPOCISample }

procedure TPOCISample.DoRun;
var
  ErrorMsg: String;
begin
  // quick check parameters
  ErrorMsg:=CheckOptions('h', 'help');
  if ErrorMsg<>'' then begin
    ShowException(Exception.Create(ErrorMsg));
    Terminate;
    Exit;
  end;

  // parse parameters
  if HasOption('h', 'help') then begin
    WriteHelp;
    Terminate;
    Exit;
  end;

  { add your program here }
  
  { Using POCI constants declared }
  WriteLN(Format('Compiler version : %s', [COMPILER_VERSION]));
  WriteLN(Format('Framework name : %s', [FRAMEWORK_NAME]));
  WriteLN(Format('Framework version : %s', [FRAMEWORK_VERSION]));
  WriteLN(Format('Environment name : %s', [ENVIRONMENT_NAME]));
  WriteLN(Format('Environment version : %s', [ENVIRONMENT_VERSION]));
  
  // stop program loop
  Terminate;
end;

constructor TPOCISample.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
  StopOnException:=True;
end;

destructor TPOCISample.Destroy;
begin
  inherited Destroy;
end;

procedure TPOCISample.WriteHelp;
begin
  { add your help code here }
  writeln('Usage: ', ExeName, ' -h');
end;

var
  Application: TPOCISample;
begin
  Application:=TPOCISample.Create(nil);
  Application.Title:='POCI Sample';
  Application.Run;
  Application.Free;
end.

Remarks

Ideally for the easiest use, it is better to have the files placed in an inclusion directory (Include) common to your projects. Access is relative. For example:

..\..\Include, on Windows ;

../../Include, on Linux.

poci's People

Contributors

libaud avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.