|
Comments
|
Today's Top SOA Links
OrcaScript Sybase Techwave 2007: Using OrcaScript with PowerBuilder
How to Automate Your Build Process with or Without Source Control
By: Keith Miller
Aug. 9, 2007 01:15 PM
The best software development project can come to a dead end if you can't build an executable that your end users can run. Luckily, PowerBuilder provides several different ways to generate an executable with a variety of options. Most of these employ the use of the project painter and differ only by how we deploy the project (i.e., development IDE or command line). However, if you want to build your executable with relative pathing like Workspace has or passing-in parameters that change, then Orca-Script is the way to go. If you combine it with a command or batch file, you can automate your build and deploy steps into an unattended and/or scheduled process.
The Background of OrcaScript
Application Setup To make the call to the OrcaScript file easier, we can build a command file that does some simple housecleaning both before and after the build. This includes removing the last build from the .\Executable directory and, once the build is done and successful, removing the exe and pbd files from the .\Source subdirectories. You can see that if the first attempt fails you'd try a second pass with a slightly different build script. This second script is an identical copy of the original except for the Build Application command. Instead of using the "FULL" parameter, you'd use the "INCREMENTAL" parameter. The reason for this is that OrcaScript may fail on the first pass with an application that has a deep inheritance structure for menus (four or more), but will succeed on the second. If you succeed on the first pass, checking the error level ensures that the second OrcaScript call doesn't get executed. You can design your cmd file to accept a parameter to be passed into the OrcaScript for variables that may change build to build. For example, if you wanted to set the version number of the executable so it would show on the version tab under properties on the right-mouse click of the executable, that could be a parameter passed through the command file into the OrcaScript and included in the build. For this example we'll keep it simple and keep everything static. A sample command file can be seen in Listing 1.
Without Source Control Next we need to designate the library search path. This can be done either by using the full path, as a project would do, or a relative path starting at the location of the .cmd file. The problem with using the full path is that every person running the script file must have the same directory structure. The Set LibList command takes a single string of libraries names with paths separated by semicolons. The string should be enclosed in quotes. This is followed by identifying the application object that we're going to use with the Set Application command. This command has two string parameters both enclosed in quotes. The first is the name and path to the application pbl filename and the second is the name of the application object. Once you've identified all of the objects used in the application, you should then regenerate them to make sure they're all synchronized. This is done with the Build Application command. This command has three options: full, incremental, and migrate. Since we're building this executable for a production environment, we need to do a full rebuild of all of the objects, not just the ones that have changed. The next section of the script actually builds the executable and either the pbls or the dlls. It uses the Build Executable command and the Build Library command to do this. We feed the Build Executable command five parameters that represent the following:
• exe Name The Build Library command only takes three parameters as shown in Listing 2. They are the name and path of the pbl file, the name and path of the Resource file to be used when compiling this library, and a flag to designate whether we should create a pbd or dll file. Once the exe and pbd or dll files have been created, there's just one more step - putting a copy of them in the .\Executable directory ready for testing. This is done by using the File Copy command with its two parameters of to and from. Remember that in our case the pbd files will be removed from the source directories by the cmd file if everything compiles and deploys cleanly.
With Source Control In our example, we'll connect to source control but not just point to the Workspace to get the parameters. We'll be using PBNative but this works for any source control system supported by PowerBuilder. Pointing to the Workspace would force everyone who ran this script to have the Workspace file in the same location on the hard drive and named the same. First we will need to set the connection parameters. Using the scc set connection property command we can set the properties for provider, user, logfile, logappend, local project path, project, and the deletion of temporary files. These are the same elements required from the source control tab of the Workspace properties to be able to connect in PowerBuilder. Different source control systems need different parameters so yours may not need all of these but may need a few others. Once all of the parameters are set, we can connect to the source code control provider by issuing the scc connect command. If you are using ClearCase with static views, the latest revision export files already exist locally so there's no need to go to the central repository to retrieve them. You'd simply connect using the offline option: however, most other SCC providers, including PBNative, don't use this option. When using other source code control providers you may just have to issue the scc connect command. After connecting, you point to the target using the refresh all and import only option. This gets the latest version of every object from the source code repository and imports them into the local pbls. You then do a full rebuild just as you did in the script without source control. This is followed by the scc close command before the files are copied to the Executable directory. One other main difference that you'll see in the script (see Listing 3) is that since the target file for the application is registered in the source control, you don't have to specify the application or library search path in the script. Instead, you can specify the target file and derive them from there. This makes it easier when things change.
Conclusion This is just one small part of what OrcaScript can do for a development team. From bootstrapping a new set of pbls from the source code repository, performing a full "Get Latest Version" before the developers sit down in the morning, to doing a full application rebuild to keep your objects in sync before you get to work. The examples have been very simple. By passing in parameters or using parameter files, OrcaScript and the .cmd files used to call them can get very complicated. I've even written a PowerBuilder program that writes an OrcaScript file based on the user's selections from a window and then schedules the task in Windows. Reader Feedback: Page 1 of 1
Your Feedback
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||