build_c.tcl 1.81 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
package provide build_c 0.1 

lappend auto_path .
namespace eval build_c {
    
    # Graphical name of the operation
    proc getLabel {} {
        return "Build the system (in C)"
    }
    
    # Name of the application this script can be used with
    # shall be either InterfaceView or DeploymentView
    proc getApplication {} {
        return "InterfaceView"
    }
    
    # Names of  the object this script can be used on
    # FIXME - it should be active all the time
    proc getApplyTo {} {
Arnaud Schach's avatar
Arnaud Schach committed
20
        return [list "allContext" ]
21 22 23 24 25
    }
    
    # List of way to manage output in the Framework
    # Could be an empty list or one or both of 'dialogBox' and 'statusBar'
    proc getOutputManagement {} {
26 27
		## Ticket mantis 0000625
        return [list statusBar dialogBoxOnError]
28 29 30 31 32 33 34 35 36 37 38
    }
    
    proc build_c { args } {
        set params [lindex $args 0]
        set aadlFilePath [Parameter::getParameter $params aadlFilePath]
        set aadlId [Parameter::getParameter $params id]
        return [build_internal $aadlFilePath $aadlId]
    }
    
    # synchronous call
    proc build_internal { aadlFilePath aadlId } {    
39
		## Ticket mantis 0000625
40 41 42 43
        set initialPath [pwd]
        cd [file dirname $aadlFilePath]
        set msg ""
        set ::env(ORCHESTRATOR_OPTIONS) "-p"
44 45 46 47 48 49 50
        set scriptPath [auto_execok "taste-build-system"]
        if { $scriptPath != "" } {
			set errNumb [catch { exec -ignorestderr {*}$scriptPath 2>@1 } errMsg]
		} else {
			set errNumb -1
			set errMsg "Unknown command taste-build-system."
		}
51
        if { $errNumb == 0 } {
52
           set msg [list "Everything went fine!" ]
53
        } else {
54
           set msg [list "Some errors were reported: $errMsg" ]
55 56 57 58 59 60 61 62
        }
        unset ::env(ORCHESTRATOR_OPTIONS)
                
        cd $initialPath
        return [list $errNumb $msg]
    } 
    
}