Skip to content
Gilles QUERRET edited this page Apr 3, 2015 · 12 revisions

Quick start

Step 1 : first build.xml file (aka Hello, world!)

Let's assume ANT and PCT are correctly installed (see manual). We'll create a new Progress project in a directory called, say, MyProject. As a good practice, we'll separate sources from build files : let's say we'll have a subdirectory called src for sources, and a subdirectory called build for build files.

We'll now create one or more procedures in the src subdir. For example, in MyProject/src/test.p :

MESSAGE "This is a test file".

And now, in MyProject/build.xml :

<?xml version="1.0" encoding="utf-8"?>
<project name="MyProject" default="build" basedir=".">

<property environment="env" />

<taskdef resource="PCT.properties" classpath="${env.PCT_HOME}/lib/PCT.jar" />

<target name="build" description="Builds source files">
  <mkdir dir="build"/>
  <PCTCompile destDir="build" dlcHome="${env.DLC}">
    <fileset dir="src">
      <include name="*.p" />
    </fileset>
  </PCTCompile>
</target>
</project>

Open a shell, define two environment variables, DLC and PCT_HOME, pointing to Progress base directory and PCT base directory. Ant also assumes that ANT_HOME, JAVA_HOME are defined, but that's part of Ant installation. Then cd to the MyProject directory, and then type ant build. You should get the following :

Buildfile: build.xml

build:
    [mkdir] Created dir: /home/justus/MyProject/build
[PCTCompile] PCTCompile - Progress Code Compiler
[PCTCompile] 1 file(s) compiled

BUILD SUCCESSFUL
Total time: 1 seconds

And you should have a subdir called build, containing a test.r file.

A few words on this :

Line 4 tells Ant to load environment variables so that they could be accessed with ${env.VARIABLE_NAME} : useful for DLC and PCT_HOME... Line 6 tells Ant to load the mapping between tasks name (e.g. PCTCompile) and Java class files (e.g. com.phenix.pct.PCTCompile) : this is mandatory to have a working PCT. Lines 10 to 14 tells PCT to compile every .p file in the src directory, and then put them in the destDir directory. Download the sample

Step 2 : adding a database

We'll create a subdir called db, containing the database dump file (called db.df). Just create this file :

ADD TABLE "MyTable"
  AREA "Schema Area"
  DUMP-NAME "MyTable"

ADD FIELD "Fld1" OF "MyTable" AS character 

ADD FIELD "Fld2" OF "MyTable" AS character 

ADD INDEX "MyTable-PK" ON "MyTable" 
  AREA "Schema Area"
  UNIQUE
  PRIMARY
  INDEX-FIELD "Fld1" ASCENDING 

This should create a really simple table, with two fields, and a primary unique index.

Now, we'll create a new procedure, called src/test2.p :

CREATE MyTable.
ASSIGN MyTable.Fld1 = "ABC"
       MyTable.Fld2 = "DEF".

Now, add the following line after line 8 of the previous build.xml :

<PCTCreateBase dbName="db" destDir="db" schemaFile="db/db.df" dlcHome="${env.DLC}"/>

and this one after line 10 :

<PCTConnection dbName="db" dbDir="db" singleUser="true"/>

Now run Ant build from the shell prompt. You should get the following :

Buildfile: build.xml

build:
[PCTCreateBase] procopy source session begin for justus on batch. (451)

[PCTCreateBase] Formatting extents:
[PCTCreateBase]    size                area name   path name
[PCTCreateBase]       4    Primary Recovery Area /home/justus/MyProject/db/db.b1 00:00:00
[PCTCreateBase]       4              Schema Area /home/justus/MyProject/db/db.d1 00:00:00

[PCTCreateBase] Copying /opt/dlc10/empty8 to db... (6715)

[PCTCreateBase] Start writing data blocks. (6718)
[PCTCreateBase] 14:23:21 10 Percent complete.
[PCTCreateBase] 14:23:21 20 Percent complete.
[PCTCreateBase] 14:23:21 30 Percent complete.
[PCTCreateBase] 14:23:21 40 Percent complete.
[PCTCreateBase] 14:23:21 50 Percent complete.
[PCTCreateBase] 14:23:21 60 Percent complete.
[PCTCreateBase] 14:23:21 70 Percent complete.
[PCTCreateBase] 14:23:21 80 Percent complete.
[PCTCreateBase] 14:23:21 90 Percent complete.
[PCTCreateBase] 14:23:21 100 Percent complete.
[PCTCreateBase] 239 blocks copied. (6720)

[PCTCreateBase] ...Copy complete. (6722)
[PCTCreateBase] procopy source session end. (334)
[PCTCreateBase] Database copied from /opt/dlc10/empty8. (1365)
[PCTCompile] PCTCompile - Progress Code Compiler
[PCTCompile] 2 file(s) compiled

BUILD SUCCESSFUL
Total time: 7 seconds

Running ant build a second time will give you this :

Buildfile: build.xml

build:
[PCTCompile] PCTCompile - Progress Code Compiler
[PCTCompile] 0 file(s) compiled

BUILD SUCCESSFUL
Total time: 1 seconds

Step 3 : dealing with propath

Imagine you'd like to work with PDFInclude : it would be a good idea to separate your own source code from PDFInclude source code, so that upgrading to a newer version would just be a drop of the new source files. So in project tree, you add a pdfinc-src directory, and include {pdfinc.i} in your programs. How to add this dir to your propath ? Quite simple, just add a propath directive in you PCTCompile task (line 9) :

<propath>
  <pathelement location="pdfinc-src"/>
</propath>

Compile as usual, using ant build, then execute build/test3.r : you should get

Message from pdfinc.i
Message from test3.p

Step 4 : dealing with ADM2 and customs

When working with ADM2, it's really a good idea to have your own copy in your project, so that you can upgrade your Progress version without upgrading your ADM2 version. Here is how I proceed : in my project tree, I create two subdirectories, called ade and ade-custom. The first one contains everything I import directly from Progress directory, and is only modified when I upgrade ADM2 version, the second one contains my own customizations.

Here is the target to compile the standard ADM2 :

  <target name="build-ade" description="Standard ADM2">
    <mkdir dir="build-ade" />
    <PCTCreateBase dbName="db" destDir="db" schemaFile="ade/temp-db.df" dlcHome="${env.DLC}" />
    <PCTCompile destDir="build-ade" dlcHome="${env.DLC}">
      <fileset dir="ade/src">
        <include name="adm2/**/*.p" />
        <include name="adm2/**/*.w" />
        <exclude name="adm2/template/**" />
      </fileset>
      <PCTConnection dbName="temp-db" dbDir="base/temp-db" singleUser="${singleUser}" />
      <propath>
        <pathelement location="ade" />
        <pathelement location="ade/src" />
      </propath>
    </PCTCompile>
    <copy toDir="ade">
      <fileset dir="ade/src">
        <include name="adm2/image/**" />
        <include name="adm2/template/**" />
      </fileset>
    </copy>
  </target>

And the target to compile your customized version of ADM2 :

  <target name="build-ade-custom" depends="build-ade" description="Customized ADM2">
    <mkdir dir="build-ade-custom" />
    <PCTCompile destDir="build-ade-custom" dlcHome="${env.DLC}">
      <fileset dir="ade/src">
        <include name="adm2/*.p" />
        <include name="adm2/*.w" />
      </fileset>
      <fileset dir="ade-custom/src">
        <include name="adm2/**/*.p" />
        <include name="adm2/**/*.w" />
        <exclude name="adm2/template/**" />
      </fileset>
      <PCTConnection dbName="temp-db" dbDir="base/temp-db" singleUser="${singleUser}" />
      <propath>
        <pathelement location="ade-custom" />
        <pathelement location="ade" />
        <pathelement location="ade/src" />
      </propath>
    </PCTCompile>
    <copy toDir="build-ade-custom">
      <fileset dir="ade-custom/src">
        <include name="adm2/image/**" />
        <include name="adm2/template/**" />
      </fileset>
    </copy>
  </target>

Step 5 : let's proxygen...

We'll here explain how to use the Java proxygen. Using .Net and DLL proxygen should work identically.

In the provided example, we're using a Progress 10.0A XPXG file, but 9.1 PXG files are OK too.

Warning : 10.1 XPXG files don't work for now ; 10.1 doesn't accept relative paths anymore, which is really annoying...

Declaring a proxygen task is simple :

  <PCTProxygen workingDirectory="src" srcFile="src/MyApp.xpxg" dlcHome="${env.DLC}" />

Which gives the following result :

pxg:
[PCTProxygen] Batch ProxyGen, Version Progress 10.0A
[PCTProxygen] Generating Proxies...
[PCTProxygen] Proxy Generation Succeeded.
[PCTProxygen] For details see the log file  ..\build-pxg\MyProduct.log
Clone this wiki locally