Builder - The Build Process

Initiate Build Process

There are several ways to initiate the build process... this includes:

The Build Process

In any case, the actual process that occurs is the same...

For each file in the list to build

  1. Execute each registered pre-process observer for the build process
  2. If file is a tokenized ProvideX program, convert to text file; skip remainder or process
  3. Do incremental build for file...
  4. Execute each registered post-process observer for the build process

A Simple Example Observer

The show_text.pvc class is simple observer that will output messages to the console view during the build prcess. This observer will be triggered during the build pre-process and the build post-process.

! showtext.pvc
! ** This observer will place a short text message on the console view.
def class "showtext"  
    like "EventManagerObserver"

    ! Override values for description / NotificationFlag
    local theDescription$="Show message in Console."
    local theNotificationFlag=_pvxConstants'_idePrePostProcess

    ! ** The logic to "print" text to the Console view
    ! ** @param state A reference to an object of class %PvxClass(PvxState)%
    function update(initPvxState)              update
end def

update:
enter aPvxState 
    local psMajor$,psMinor$,enfState,aReq,procPfx$

    psMajor$=aPvxState'getMajor$(), \
    psMinor$=aPvxState'getMinor$()

    /* This observer is for build event only; all other events will be ignored. */
    if (psMajor$=_pvxConstants'Incremental_Build$ \
            or psMajor$=_pvxConstants'Incremental_Build_Alt_Exe$) \
        and psMinor$=_pvxConstants'BuildType_BuildOne$ {

        enfState=aPvxState'getArgumentValue(_pvxConstants'_iEventNotificationFlag$)

        switch enfState
        case _pvxConstants'_idePreProcess
            procPfx$="pre"
            break
        case _pvxConstants'_idePostProcess
            procPfx$="post"
            break
        end switch

        ! Use request client class to write a message to the 'Console' view
        aReq=new("pvxrequestclient")
        aReq'print("ShowText: A "+procPfx$+"-process message to the console")
        drop object aReq
    }
return 0
end

Reading Source Files

All observer actions that need to read a source file should use the program_reader class as shown in the following sample code:

	! Create a new instance of the ProgramReader for the source file
	aReader=new("program_reader",theSourceFile$)
	
	while not(aReader'getEOF())
		! Get the next source file line
		aLine$=aReader'read$()
		! logic to process the program line
	wend 
	drop object aReader

What should not be attempted by an observer during the build process?

An observer cannot change the original source file - this will trigger a new build process. Any modifications to source files should be implemented in a contributed tool to avoid a run-away build process caused by continuously changing source files.