##
## Cct - ::CctExport
##
## (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 ::CctExport {}
proc ::CctExport::Cfg {} {
return [ list 1 {export internal code} ]
}
if {[ info exists COMPILER_CCT_CFG ]} return
if {![info exists COMPILER_CctExport]} {
lappend auto_path [ file dirname [info script] ]
}
PkgProvide CctExport
package require Cct
package require Config
package require ITMakeLib
proc ::CctExport::ErrorN { args } {
::StdLib::ErrorN {EXPORT ERROR} $args
}
##
## -------------------------------------------------------
## Export
##
namespace eval ::CctExport::Args {
variable ARGS_DEFAULT {-c 0 -t 0 -m 0}
variable VALUE
variable ARGS
array set ARGS {
-c {SetFlag CctExport -c}
-t {SetFlag CctExport -t}
-m {SetFlag CctExport -m}
-h ::CctExport::Args::Help
--help ::CctExport::Args::Help
}
namespace import ::Args::*
}
proc ::CctExport::Args::Help {} {
EnvRead CctExport
::StdLib::StdErr "\nusage: cct \[master option ...\] export \[user-option ...\]"
Print-Cmd %MASTER% Options
::StdLib::StdErr ""
::StdLib::StdErr " user-options :\n"
Print-Flag CctExport -c "C-back-end representation"
Print-Flag CctExport -t "Tcl-back-end representation"
Print-Flag CctExport -m "Meta-Code"
Print-Cmd %MASTER% Default
::StdLib::StdErr ""
::StdLib::StdErr " additional informations :"
::StdLib::StdErr ""
::StdLib::StdErr " 1) expect a valid glob style pattern"
::StdLib::StdErr " for the master \"-t\" option to match"
::StdLib::StdErr " local files"
::StdLib::StdErr ""
exit 1
}
proc ::CctExport::Args::Main {} {
while {1} {
set Val [ GetArg ]
if {[ string equal $Val %%NO%% ]} break
Test-Opt CctExport $Val
Invoke CctExport $Val
}
EnvRead CctExport
}
##
## -------------------------------------------------------
##
proc ::CctExport::mac91ppc { CONFIG } {
package require FileLib
::Config::Main project.cct -dir [ ::Env::Get CMP_DIR ] -cache yes
## new style package names
if {?$} $CONFIG DUMMY OT_PKG OT_MAJOR OT_MINOR ]} {
set OT_PKG $CONFIG
set OT_MAJOR [ ::Config::Get [list PACKAGE:$CONFIG MAJOR] ]
set OT_MINOR [ ::Config::Get [list PACKAGE:$CONFIG MINOR] ]
}
set OT_REL ${OT_MAJOR}.${OT_MINOR}
## 1. create the pch file
set PDIR [ file join export $CONFIG ]
append Str "#if __POWERPC__" \n \
"#pragma precompile_target " \" MW_ $OT_PKG PPC \" \n \
"#else" \n \
"#error POWER-Tcl only supports PPC" \n \
"#endif" \n \
"#include " \" tclMacCommonPch.h \" \n \
"#define VERSION " \" $OT_REL \" \n \
"#define BUILD_" $OT_PKG \n \
"#define OTTARGET_mac91ppc" \n
WriteFile [ file join $PDIR MW_$OT_PKG.pch ] $Str
## 2. create the include directory
set SDIR [::Env::Arch include]
set TDIR [ file join export $CONFIG include ]
file mkdir $TDIR
foreach f {tcl.h tclDecls.h tclInt.h tclIntDecls.h tclIntPlatDecls.h tclMacCommonPch.h tclPlatDecls.h} {
file copy -force [file join $SDIR $f] $TDIR
}
## 3. create xml project template
set Files [ ::Config::Query [list PACKAGE:$CONFIG FILE] ]
WriteFile [ file join $PDIR $OT_PKG.xml ] [ CreateXml $OT_PKG $OT_MAJOR $OT_MINOR $Files ]
WriteFile [ file join $PDIR $OT_PKG.r ] [ CreateRes $OT_PKG $OT_MAJOR $OT_MINOR ]
}
proc ::CctExport::Main {} {
upvar 0 Args::VALUE VALUE
## read the configuration
::Config::Main project.cct
## get the names
::Args::Test-NOT-SET %MASTER% -t
## init
set TGT [ ::Env::Get CCT_TARGET ]
## all packages
foreach PKG [ lsort [ FilterList [ ::Config::Query PACKAGE ] [ ::Args::GetVal %MASTER% -t ] ] ] {
## the package we work on
::Env::Set CMP_CONFIG $PKG
## call TMake
::StdLib::Push STDERR stderr
if { $VALUE(-m) } {
::ITMake::Exec [list -tgt m.exp]
}
if { $VALUE(-t) } {
::ITMake::Exec [list -tgt tcl.exp]
}
if { $VALUE(-c) } {
::ITMake::Exec [list -tgt c.exp]
}
::StdLib::Pop STDERR
## check for special TARGET setup
if { $TGT == "mac91ppc" } { ::CctExport::mac91ppc $PKG }
}
}