Getting the sourcesThe 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 The 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 lineI'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 pas2jsYou 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. ReleasesTill 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:
Daily SnapshotsCurrently, 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. The pas2js folderI 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. pas2js.cfgAfter 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.
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, # # 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. Lazarus Integration of pas2jsThe 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: |
|