##
## Cct - ::CctMake
##
## (C) IPN - Ingenieurbuero fuer Praezisionsnumerik
##
## Dipl.-Ing. Andreas Otto
## Ulmenstrasse 3
## D-34289 Zierenberg
## mailto:aotto@t-online.de
## http://tclcompiler.sourceforge.net
##
## Alle Rechte vorbehalten
##
namespace eval ::CctMake {}
proc ::CctMake::Cfg {} {
return [ list 1 {interface to the make tool} ]
}
if {[ info exists COMPILER_CCT_CFG ]} return
PkgProvide CctMake
package require Cct
package require CctCmd
package require Config
package require ITMakeLib
proc ::CctMake::ErrorN { args } {
lappend args {try "cct -h" or "cct make -h" for additional help}
::StdLib::ErrorN {BRASE ERROR} $args
}
##
## -------------------------------------------------------
## Pkg
##
namespace eval ::CctMake::Args {
variable ARGS_DEFAULT {-d 0 -k 0 -s 1 -v 0 -n 0 -ve 0 -p 0 -tgt {NOT SET} -equ {{NOT SET}} -f {package TMakeLib} --list 0}
variable VALUE
variable ARGS
array set ARGS {
-d {SetFlag CctMake -d}
-k {SetFlag CctMake -k}
-s {SetFlag CctMake -s}
-v {SetFlag CctMake -v}
-n {SetFlag CctMake -n}
-ve {SetFlag CctMake -ve}
-p {SetFlag CctMake -p}
--list {SetFlag CctMake --list}
-h ::CctMake::Args::Help
--help ::CctMake::Args::Help
}
namespace import ::Args::*
}
proc ::CctMake::Args::Help {} {
EnvRead CctMake
global argv0 VERSION VERDATE
::StdLib::StdErr "\nusage: cct \[master option ...\] make \[user-option ...\] \[--\] \[var=value]\ \[target ...\]"
::StdLib::StdErr ""
::StdLib::StdErr " construct files based on a rule-file"
::StdLib::StdErr " brasfile - rule-file to use (defaults: Brasfile or brasfile)"
::StdLib::StdErr ""
Print-Flag CctMake -d "show reasoning in addition to normal processing"
Print-Flag CctMake -k "continue as much as possible after an error"
Print-Flag CctMake -n "don't execute any commands (implies -v)"
Print-Flag CctMake -p "print database of rules, then exit"
Print-Flag CctMake -s "don't show anything except error messages"
Print-Flag CctMake -v "show all commands to be executed"
Print-Flag CctMake -ve "use verbose version of exec"
Print-Flag CctMake --list "list all (cct -a pkg --list) packages"
Print-Cmd %MASTER% Default
::StdLib::StdErr {
additional informations :
-- use the rest of the command-line as target list
(necessary, if a target starts with `-')
var=value just before starting to read brasfiles, element var of
the global array env is set to value
target target to be rebuilt (default: the target of the first
rule in brasfile)
}
exit 1
}
proc ::CctMake::Args::Main {} {
set FLAG 1
while {1} {
set Val [ GetArg ]
if {[ string equal $Val %%NO%% ]} break
if {[string match *=* $Val]} {
AppendVal CctMake -equ $Val
} else {
AppendVal CctMake -tgt $Val
}
if {$FLAG && [ IsOpt CctMake $Val ]} {
Test-Opt CctMake $Val
Invoke CctMake $Val
} else {
AppendVal CctMake -tgt $Val
}
}
EnvRead CctMake
}
##
## -------------------------------------------------------
##
proc ::CctMake::Main {} {
global errorInfo
upvar 0 Args::VALUE VALUE
## read the configuration
::Config::Main project.cct
## get the names
::Args::Test-NOT-SET %MASTER% -t
set Names [ FilterList [ ::Config::Query PACKAGE ] [ ::Args::GetVal %MASTER% -t ] ]
## list all names
if { $VALUE(--list) } {
puts $Names
exit 0
}
## does packages are available ?
if {[::CctCmd::NoPkgFound $Names]} return
## loop
::StdLib::Push STDIN stdin STDOUT stdout STDERR stderr ERROR EXIT
foreach Name $Names {
puts "\n\n working on package \"$Name\""
::Env::Set CMP_CONFIG $Name
if {$VALUE(-tgt) == {NOT SET}} { set VALUE(-tgt) help }
::ITMake::Exec [ array get VALUE ]
}
::StdLib::Pop STDIN STDOUT STDERR ERROR
}