Download Pas2JS



propertyicon.png Getting the sources

The Pas2js compiler is - naturally - open source and can be downloaded and used freely. The sources are currently the primary means to get it. The Pas2js compiler is part of Free Pascal. As such, the compiler is present in the utils/pas2js directory of the FPC SVN repo

tipbulbThe latest rtl.js can be found here

The pas2js RTL is still in flux. To enable faster releases, the RTL packages and demos are in a separate repository in SVN: https://svn.freepascal.org/svn/projects/pas2js/trunk

svn co https://svn.freepascal.org/svn/projects/pas2js/trunk pas2js

Update local SVN repository via command line

I'd now like to update this pas2js repository via command line, just cd in to the working copy and do this command line:

svn up pas2js

Build pas2js

You need FPC 3.0.4 or better to compile it. A good FPC source is downloaded at: ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/source/fpc.zip

Change to the directory and build it with:

make clean all

This creates bin/$(TargetCPU)-$(TargetOS)/pas2js (Windows: pas2js.exe). For example on Linux 64bit it creates bin/x86_64-linux/pas2js, while under Windows 64bit it creates bin\x86_64-win\pas2js.exe; under Windows 32bit, it creates bin\i386-win32.

propertyicon.png Releases

Till pas2js is integrated in the main FPC distribution, snapshots will be made available as time permits. The releases contain binaries for Windows (32 and 64bit), Linux (64 bit) and MacOS. The releases are uploaded to [1]

Every version will have a directory with the version number. A list of changes can be found on the Pas2JS Version Changes.

After you download the latest release for your operating system and unpack it in folder of your choice. The example below uses D:\fpc2js\pas2js-windows-1.5.1. Basically, the release contains three folders:

  • bin - contains the compiler as executable (pas2js or pas2js.exe) and library and some utilities.
  • demo - lots of examples
  • packages - the Pascal units of the RTL and other packages.

propertyicon.png Daily Snapshots

Currently, daily snapshots directory contains binaries for Linux (64 bit) for trunk and latest fixes branch. Other OSes (macOS, linux) will be made available as time permits The snapshots are uploaded to Pas2JS Daily Snapshots.

propertyicon.png The pas2js folder

I think it is a good practice to manage, to unzip the pas2js distribution at the fixed location, e.g. D:\fpc2js

Every pas2js version has a directory with the version number. So, inside this main folder, create another two folders; one for pas2js projects and another for the rtl.js.

propertyicon.png pas2js.cfg

After you unzip the pas2js distribution, make sure a simple config file named (pas2js.cfg) lives at pas2js binary and adapt the paths e.g. bin/pas2js.cfg.

tipbulb To let the compiler find the RTL and packages, you need to set up correctly the pas2js.cfg config file. Move the rtl.js file to a folder e.g. D:\FPC2JS\dist,
this file is usually located under pas2js/compiler/utils/pas2js/dist, because it is tightly coupled to the compiler, not to the rtl. From now on, the dependency is not necessary when compiling.

#
# Minimal config file for pas2js compiler
#
# -d is the same as #DEFINE
# -u is the same as #UNDEF
#
# Write always a nice logo ;)
-l

# Display Warnings, Notes and Hints
-vwnh
# If you don't want so much verbosity use
#-vw

-Fu$CfgDir\..\packages\*
-Fu$CfgDir\..\..\dist\

#IFDEF nodejs
-Jirtl.js
#ENDIF

# Put all generated JavaScript into one file
-Jc

# Allow C-operators
-Sc
# end.

propertyicon.png Lazarus Integration of pas2js

tipbulbThe Lazarus integration of pas2js is still under construction, but deep integration with lazarus is planned. For instance, it's on the oven a widget tool named PJ-Suite that claims to use the Delphi/Lazarus and its form designer to create web applications. Just drop components onto a form and set up at the objector inspector, the events and the properties. All of the above is great and it will no doubt give us the same benefits as Delphi/Lazarus developers currently enjoy. The whole point is that building your GUI using RAD is faster.

Rapid application development (RAD) is a development process that allows a developer to quickly proceed from an application design to a fully-functional application by tightly integrating the design portion of application development with the coding/compilation/deployment portion of development.

Lazarus IDE brings the productivity features of a desktop IDE to web applications. Since Lazarus understands the concept of external classes as used by pas2js, the code completion will work! Just take a look how to proceed:

Lazarus Integration of pas2js
Lazarus integration of pas2js