CodeWarrior Palm Tips

CodeWarrior for Palm is a pretty good tool, at least relative to PRC-Tools, but it has some limitations.

  • Put RCP files at the top of your first segment. If you don’t, your compiles may fail once since RCP files can build H files that the rest of your project probably uses. Unfortunately, even this doesn’t guarantee success. I generally have my scripts attempt to build a project twice as a result: The first time, I ignore the errors.

Command line compiling

I have found cmdide and ide both to not respond well to command line options to run builds. Ben Combee suggested I give com a try. While I have never used COM or VBS before, I found this pretty easy.

I recommend installing cygwin. GNU make makes this a lot easier, and this is one of the easiest ways to get it. If you don’t install cygwin, you’ll need to build your own PRJ= line.

Two more things before we start:

  1. If you use PilRC to generate headers, builds will often fail the first time the structure is created. It seems CodeWarrior doesn’t know what order to build things in. If you recreate your directory each time from a source control system nightly, this will be every time the script runes! The only 100% fool proof method I’ve found for working around this problem is to have the makefile run the build twice and discard/ignore errors the first time. Sometimes the simplest solution is the best…
  2. In my testing, this never worked when Use Default Workspace was on. I’m not sure if this is a bug in the IDE, or a flaw in my script. Since I don’t like this option anyway, I just turned it off.

makefile

First, in the top of my makefile I define two variables:

PRJ = $(shell cygpath -d "$(shell pwd.exe)")

CCP = cscript /b "$(PRJ)\cwbuild.vbs"

The first line uses cygwin to set $(PRJ) to the current path. $(CCP) invokes our Visual Basic Script… more on that later.

When I want to compile a project, I use a sequence like this:



morepalmlib:

	@$(CCP) "$(PRJ)\projects\morepalmos\morepalm.mcp" Debug >> buildlog.txt

	@$(CCP) "$(PRJ)\projects\morepalmos\morepalm.mcp" Release >> buildlog.txt

cwbuild.vbs

Next, the script that ties it all together:

Main

Sub Main

	Dim projectPath

	Dim targetName

	Dim cwApp, cwProj, cwTrg

	Dim trgCollection, trgName

	Dim buildMsgs

	Dim i

	' Create the CodeWarrior Application Object

	Set cwApp = CreateObject("CodeWarrior.CodeWarriorApp")

	' Don't interrupt the build process, take default actions for modal dialogs

	cwApp.AllowUserInteraction = FALSE

	projectPath = WScript.Arguments(0)

	if WScript.Arguments.Count=1 then

		targetName = "*"

	else

		targetName = WScript.Arguments(1)

	end if

	Set cwProj = cwApp.OpenProject( projectPath, TRUE, 0, 1 )

	' Get the target collection

	Set trgCollection = cwProj.Targets

	' For every target, build, log error messages

	if targetName = "*" then

		For i = 0 to trgCollection.Count - 1

			Set cwTrg = trgCollection.Item(i)

			trgName = cwTrg.Name

			BuildTarget cwProj, trgName, buildMsgs

		Next

	else

		BuildTarget cwProj, targetName, buildMsgs

	end if

	cwProj.Close

	' Reset User Interaction Level

	cwApp.AllowUserInteraction = TRUE

End Sub

Sub BuildTarget( cwProj, targetName, buildMsgs )

	Dim errCollection

	Dim errMsg, errCnt

	Dim j

	Dim oStdOut

	Set oStdOut = Wscript.StdOut

	oStdOut.WriteLine "Build report for : " + cwProj.Name + " - " + targetName

	oStdOut.WriteLine "Date : " + CStr(Now)

	cwProj.SetCurrentTarget( targetName )

	cwProj.RemoveObjectCode 0, 1

	Set buildMsgs = cwProj.BuildandWaitToComplete

	Set errCollection = buildMsgs.Errors

	if ( errCollection.Count > 0 ) then

		oStdOut.WriteLine "****** ERRORS:"

		errCnt = errCollection.Count

		For j = 0 to errCnt - 1

			Set errMsg = errCollection.Item(j)

			oStdOut.WriteLine errMsg.MessageText

		Next

	else

		oStdOut.WriteLine "    No Errors."

	end if

		oStdOut.WriteLine ""

End Sub

Comments are closed.