This file looks large and may slow your browser down if we attempt
to syntax highlight it, so we are showing it without any
pretty colors.
Highlight
it anyway.
| 1 |
#!/usr/bin/env tclsh |
| 2 |
|
| 3 |
package provide TBuild::Clang 0.1 |
| 4 |
package require TBuild |
| 5 |
|
| 6 |
namespace eval TBuild::Clang { |
| 7 |
|
| 8 |
TBuild Set cflags {-Wall} |
| 9 |
|
| 10 |
proc obj {ofile cfile {cflags {}}} { |
| 11 |
TBuild MakeSource cfile |
| 12 |
TBuild MakeTarget ofile |
| 13 |
TBuild Depends $ofile $cfile |
| 14 |
TBuild Set -append $ofile cflags {*}$cflags |
| 15 |
# TODO: make the dependance for .h files |
| 16 |
TBuild Make ::TBuild::Clang::_cc_c $ofile $cfile |
| 17 |
} |
| 18 |
|
| 19 |
proc exe {xfile sfiles {libs {}}} { |
| 20 |
TBuild MakeTarget xfile |
| 21 |
TBuild Depends all $xfile |
| 22 |
set sources [list] |
| 23 |
foreach ofile $sfiles { |
| 24 |
switch -glob -- $ofile { |
| 25 |
*.c { |
| 26 |
set cfile $ofile |
| 27 |
set ofile [string replace $ofile end-1 end .o] |
| 28 |
obj $ofile $cfile |
| 29 |
} |
| 30 |
} |
| 31 |
TBuild MakeGlobal ofile |
| 32 |
TBuild Depends $xfile $ofile |
| 33 |
lappend sources $ofile |
| 34 |
} |
| 35 |
TBuild Set -append $xfile clibs {*}$libs |
| 36 |
TBuild Make ::TBuild::Clang::_cc $xfile {*}$sources |
| 37 |
} |
| 38 |
|
| 39 |
proc _cc_c {target ofile cfile} { |
| 40 |
set cflags [TBuild Get $target cflags] |
| 41 |
TBuild Exec gcc -o $ofile {*}$cflags -c $cfile |
| 42 |
} |
| 43 |
|
| 44 |
proc _cc {target ofile args} { |
| 45 |
set cflags [TBuild Get $target cflags] |
| 46 |
set clibs [TBuild Get $target clibs] |
| 47 |
TBuild Exec gcc -o $ofile {*}$clibs {*}$cflags {*}$args |
| 48 |
} |
| 49 |
|
| 50 |
proc Aliases {{prefix {TBuild Clang}}} { |
| 51 |
return {} |
| 52 |
} |
| 53 |
|
| 54 |
namespace export * |
| 55 |
namespace ensemble create |
| 56 |
|
| 57 |
} |