-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathTclInterp.php
33 lines (25 loc) · 863 Bytes
/
TclInterp.php
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
<?php declare(strict_types=1);
namespace Tkui\Tests;
use Tkui\DotEnv;
use Tkui\System\FFILoader;
use Tkui\TclTk\Interp;
use Tkui\TclTk\Tcl;
use Tkui\System\OSDetection;
trait TclInterp
{
protected Tcl $tcl;
protected Interp $interp;
protected function setUp(): void
{
parent::setUp();
$rootDir = dirname(__DIR__);
$defaultTclH = $rootDir . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'headers' . DIRECTORY_SEPARATOR . 'tcl86.h';
$env = DotEnv::create($rootDir);
$os = OSDetection::detect();
$hFile = $env->getValue('TCL_HEADER', $defaultTclH);
$shared = $env->getValue("{$os->family()}_LIB_TCL", $os->tclSharedLib());
$loader = new FFILoader($hFile, $shared);
$this->tcl = new Tcl($loader->load());
$this->interp = $this->tcl->createInterp();
}
}