!

! (c) Copyright 2016, Sage Software Canada Ltd. (Ontario, Canada)

 

/*

 * Build information:

! ** @Author Fred McGuirk

 

! ** This class is written to be a "Build Post-Process" listener.

! ** It will create a list of output files (compiled programs) created by the build process and write the list

! ** to the console when the build process is complete.

 */

DEF CLASS "execModifiedFiles"

    LIKE "EventManagerObserver"

 

    ! ** Description to be used for tool on the Contributed Extensions / Tools Preference Page

    LOCAL theDescription$="SCT - Execute modified files in test environment"

 

            ! ** Event notification type: Post Event - Checks for post process events

    LOCAL theNotificationFlag=_pvxConstants'_idePostProcess

 

    ! ** Private property to store the list of files

    LOCAL cProcessedFiles$

 

    ! ** The logic to create a list of files processed by build, and perform an action for each file

    ! ** @ulist

    ! ** Initialize the list of the files when the full build starts

    ! ** In Build Post-Process for each file, add relative path of each output file to the list

    ! ** At end of Full Build, go through the list of files and print relative name to console

    ! ** @ulist_end

    ! ** @param state A reference to an object of class %PvxClass(PvxState)%

    FUNCTION update(initPvxState)                                UPDATE

 

END DEF

 

UPDATE:

    ENTER aPvxState

 

    LOCAL psMajor$, psMinor$, enfState, numFiles

 

    ! Get the Major/Minor codes that identify the current action

    psMajor$=aPvxState'getMajor$(), \

    psMinor$=aPvxState'getMinor$()

 

    ! Get notification state for the event

    enfState=aPvxState'getArgumentValue(_pvxConstants'_iEventNotificationFlag$)

 

    ! handle ALL events

    SWITCH psMajor$ + "|" + psMinor$

 

    ! Full Build - Start

    CASE _pvxConstants'Full_Build$ + "|" + _pvxConstants'Full_Build_Start$

        ! Must initialize data for the new build process

        cProcessedFiles$ = ""

 

        BREAK

 

    ! Full Build - End

    CASE _pvxConstants'Full_Build$ + "|" + _pvxConstants'Full_Build_End$

 

        ! check for alternate START_UP program and execute

        altStartPgm$ = aPvxState'getArgumentValue$(_pvxConstants'_ibAltStartUp$);

        IF NOT(NUL(altStartPgm$)) {

            CALL altStartPgm$, ERR=*NEXT

        }

 

        ! Process all files in the list

        numFiles = pos(","=STP(cProcessedFiles$, 2, ",") + ",", 1, 0)

        DIM theFiles$[1:numFiles]

        READ DATA FROM STP(cProcessedFiles$, 2, ","), SEP="," TO theFiles$[ALL]

 

        ! Use request client class to write a message to the 'Console' view

        aReq=NEW("pvxrequestclient")

 

        FOR aFile = 1 TO numFiles

            aReq'print("Process File: " + theFiles$[aFile])

            ! TODO: What should we do with this file?

        NEXT aFile

 

        ! Clean-up

        cProcessedFiles$ = ""

        DROP OBJECT aReq

 

        BREAK

 

    ! Build a ProvideX program

    CASE _pvxConstants'Incremental_Build$ + "|" + _pvxConstants'BuildType_BuildOne$

    CASE _pvxConstants'Incremental_Build_Alt_Exe$ + "|" + _pvxConstants'BuildType_BuildOne$

        ! Get the arguments from the current action that this logic will use

        eventDestFile$   = aPvxState'getArgumentValue$(_pvxConstants'Dest$)

        projectRootDir$  = aPvxState'getArgumentValue$(_pvxConstants'Project_Root$)

 

        ! Set output folder for project - using fixed value

        projectOutDir$   = projectRootDir$ + dlm + "compiled" + dlm

        ! get relative path for destination file in the output folder

        destFileRelPath$ = MID(eventDestFile$, LEN(projectOutDir$))

 

        ! TODO: Should we check the file extension before adding to the list?

 

        ! Add relative path of output file to the list

        cProcessedFiles$ += TBL(NUL(cProcessedFiles$), ",", "") + destFileRelPath$

 

        BREAK

 

    END SWITCH

 

    RETURN 0

 

END