Menu

[r3]: / cmp / TMakeLib / CctExport.tcl  Maximize  Restore  History

Download this file

174 lines (138 with data), 4.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
##
## 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 {![ regexp {^(\w+)(\d+)[.](\d+)?$} $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 }
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.