Changeset 48


Ignore:
Timestamp:
Jun 24, 2009, 11:04:06 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

configure.cmd: Undo temporary file rename operations we perform when building qmake if we fail and exit the script in the middle.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.cmd

    r47 r48  
    732732     * however they are real functions in the library */
    733733
    734     old_qconfig_h = ""
     734    /* use an "at exit" slot to undo temporary file rename operations since we
     735     * can fail in the middle */
     736    exs = AddAtExitSlot()
     737
    735738    qconfig_h = G.OutPath"\src\corelib\global\qconfig.h"
    736739    qmake_qconfig_h = qconfig_h".qmake"
    737740    if (FileExists(qconfig_h)) then do
    738          old_qconfig_h = qconfig_h
    739          call MoveFile old_qconfig_h, old_qconfig_h".old"
     741        call MoveFile qconfig_h, qconfig_h".old"
     742        /* record undo Move operation */
     743        call PutToAtExitSlot exs, 'call MoveFile "'qconfig_h'.old", "'qconfig_h'"'
    740744    end
    741745
     
    746750
    747751    call MoveFile qmake_qconfig_h, qconfig_h
     752    /* record undo Move operation */
     753    call PutToAtExitSlot exs, 'call MoveFile "'qconfig_h'", "'qmake_qconfig_h'"'
     754
    748755    list.1 = G.OutPath"\include\QtCore\qconfig.h"
    749756    list.2 = G.OutPath"\include\Qt\qconfig.h"
     
    761768
    762769    /* put back original qconfig.h */
    763     call MoveFile qconfig_h, qmake_qconfig_h
    764     if (old_qconfig_h \== "") then
    765         call MoveFile old_qconfig_h".old", old_qconfig_h
     770    call RunAtExitSlot exs
    766771
    767772    /* exit on failure */
     
    23352340 *  @version 1.1
    23362341 */
    2337 /* <<< export to qt.cmd starts */
    23382342AddPathVar: procedure expose (Globals)
    23392343    parse arg name, path, mode, environment
     
    23852389    else call value name, cur
    23862390    return
    2387 /* >>> export to qt.cmd ends */
    23882391
    23892392/**
    23902393 *  Shortcut to AddPathVar(name, path, prepend, 'OS2ENVIRONMENT')
    23912394 */
    2392 /* <<< export to qt.cmd starts */
    23932395AddPathEnv: procedure expose (Globals)
    23942396    parse arg name, path, prepend
    23952397    call AddPathVar name, path, prepend, 'OS2ENVIRONMENT'
    23962398    return
    2397 /* >>> export to qt.cmd ends */
    23982399
    23992400/**
     
    24222423    end
    24232424    return str
     2425
     2426/**
     2427 * Initializes a new "at exit" slot and returns its ID.
     2428 */
     2429AddAtExitSlot: procedure expose (Globals)
     2430    id = 1
     2431    if (symbol('G.AtExit.0') == 'VAR') then
     2432        id = G.AtExit.0 + 1
     2433    G.AtExit.0 = id
     2434    G.AtExit.id = ""
     2435    return id
     2436
     2437/**
     2438 * Puts the REXX code passed in @a aCommand to the "at exit" slot with @a aID.
     2439 * The entire set of commands will be executed upon program termination
     2440 * unless the slot is purged earlier with RunAtExitSlot.
     2441 *
     2442 * Note that the commands will be executed in the order reverse to the order of
     2443 * PutToAtExitSlot calls (i.e. the last put command will be executed first).
     2444 *
     2445 * @param aID       Slot ID to add the command to.
     2446 * @param aCommand  Command to add.
     2447 */
     2448PutToAtExitSlot: procedure expose (Globals)
     2449    parse arg aID, aCommand
     2450    if (G.AtExit.aID == "") then
     2451        G.AtExit.aID = aCommand
     2452    else
     2453        G.AtExit.aID = aCommand"; "G.AtExit.aID
     2454    return
     2455
     2456/**
     2457 * Executes the "at exit" slot with @a aID and purges (removes) it from the
     2458 * collection of slots so that it won't be executed upon program termination.
     2459 *
     2460 * Note that the commands will be executed in the order reverse to the order of
     2461 * PutToAtExitSlot calls (i.e. the last put command will be executed first).
     2462 *
     2463 * @param aID       Slot ID to run.
     2464 */
     2465RunAtExitSlot: procedure expose (Globals)
     2466    parse arg aID
     2467    cmds = G.AtExit.aID
     2468    drop G.AtExit.aID
     2469    /* shorten the list if we are the last (unless called from Done) */
     2470    if (value('G.Done_done') \= 1) then
     2471        if (G.AtExit.0 == aID) then
     2472            G.AtExit.0 = aID - 1
     2473    /* execute commands */
     2474    interpret cmds
     2475    return
    24242476
    24252477/**
     
    24882540    call value 'G.Done_done', 1
    24892541    /* cleanup stuff goes there */
    2490     /* ... */
     2542    if (symbol('G.AtExit.0') == 'VAR') then do
     2543        /* run all AtExit slots */
     2544        do i = 1 to G.AtExit.0
     2545            if (symbol('G.AtExit.'i) == 'VAR') then
     2546                call RunAtExitSlot i
     2547        end
     2548    end
     2549    drop G.AtExit.
    24912550    /* finally, exit */
    24922551    exit code
Note: See TracChangeset for help on using the changeset viewer.