Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
MiniEDA
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
MiniEDA
Commits
127a0e19
Commit
127a0e19
authored
Nov 17, 2022
by
lvzhengyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
makes the user-defined tcl cmd seen by Tcl terminal
parent
c0c3a467
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
83 additions
and
6 deletions
+83
-6
README.md
+3
-0
setup.sh
+2
-0
src/MiniEda.cc
+9
-0
src/MiniEda.i
+2
-2
src/MiniEda.tcl
+2
-2
src/cmake/swig_lib.cmake
+1
-1
src/etc/TclEncode.tcl
+0
-0
src/utl/CMakeLists.txt
+1
-0
src/utl/include/utl/Logger.h
+1
-1
src/utl/include/utl/tcl_utl.h
+15
-0
src/utl/src/tcl_utl.cpp
+47
-0
No files found.
README.md
View file @
127a0e19
...
...
@@ -5,6 +5,9 @@
## TODO
*
make TCL to recognize my configured commands
*
cannot find the extern defined char
*
minieda_swig_tcl_inits
*
add OpenDB
*
with swig
...
...
setup.sh
View file @
127a0e19
...
...
@@ -6,3 +6,5 @@ export CMAKE_INCLUDE_PATH="$PWD/pkgs/boost_1_78_0/:$CMAKE_INCLUDE_PATH"
# export CMAKE_LIBRARY_PATH="/workspace/S/lvzhengyang/_install/lib:$CMAKE_LIBRARY_PATH"
export
CMAKE_LIBRARY_PATH
=
"
$PWD
/pkgs/lib"
export
CMAKE_LIBRARY_PATH
=
"
$PWD
/pkgs/boost_1_78_0/stage/lib:
$CMAKE_LIBRARY_PATH
"
export
CMAKE_PREFIX_PATH
=
"
$PWD
/pkgs:
$CMAKE_PREFIX_PATH
"
src/MiniEda.cc
View file @
127a0e19
...
...
@@ -3,6 +3,11 @@
#include "utl/MakeLogger.h"
#include "utl/Logger.h"
#include "utl/tcl_utl.h"
namespace
eda
{
extern
const
char
*
minieda_swig_tcl_inits
[];
}
// Swig uses C linkage for init functions.
extern
"C"
{
...
...
@@ -16,6 +21,8 @@ extern const char* metrics_filename;
namespace
eda
{
using
utl
::
evalTclInit
;
MiniEda
::
MiniEda
()
:
tcl_interp_
(
nullptr
),
logger_
(
nullptr
)
...
...
@@ -59,6 +66,8 @@ void MiniEda::init(Tcl_Interp* interp)
// Init components.
Minieda_swig_Init
(
interp
);
// Import TCL scripts
evalTclInit
(
interp
,
eda
::
minieda_swig_tcl_inits
);
// defined in MakeModuleXX.h
initLogger
(
logger_
,
interp
);
...
...
src/MiniEda.i
View file @
127a0e19
...
...
@@ -50,9 +50,9 @@ using eda::getLogger;
namespace eda {
void
delete_all_memory(
)
void
logger_echo(const char* usr_input
)
{
eda::deleteAllMemory(
);
getLogger()->info(utl::EDA, 1, usr_input
);
}
}
...
...
src/MiniEda.tcl
View file @
127a0e19
proc
delete_all_memory
{
}
{
eda::
delete_all_memory
proc
logger_echo
{
usr_input
}
{
eda::
logger_echo
$usr
_input
}
src/cmake/swig_lib.cmake
View file @
127a0e19
...
...
@@ -130,7 +130,7 @@ function(swig_lib)
set
(
LANG_INIT
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
ARG_NAME
}
-
${
ARG_LANGUAGE
}
InitVar.cc
)
add_custom_command
(
OUTPUT
${
LANG_INIT
}
COMMAND
${
MINIEDA_HOME
}
/etc/TclEncode.tcl
${
LANG_INIT
}
${
ARG_NAME
}
_
${
ARG_LANGUAGE
}
_inits
${
ARG_SCRIPTS
}
COMMAND
${
MINIEDA_HOME
}
/
src/
etc/TclEncode.tcl
${
LANG_INIT
}
${
ARG_NAME
}
_
${
ARG_LANGUAGE
}
_inits
${
ARG_SCRIPTS
}
WORKING_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
DEPENDS
${
ARG_SCRIPTS
}
)
...
...
etc/TclEncode.tcl
→
src/
etc/TclEncode.tcl
View file @
127a0e19
File moved
src/utl/CMakeLists.txt
View file @
127a0e19
...
...
@@ -24,6 +24,7 @@ target_sources(utl
PRIVATE
src/Logger.cpp
src/MakeLogger.cpp
src/tcl_utl.cpp
)
target_include_directories
(
utl
...
...
src/utl/include/utl/Logger.h
View file @
127a0e19
...
...
@@ -64,7 +64,7 @@ namespace utl {
X(IFP) \
X(MPL) \
X(ODB) \
X(
ORD
) \
X(
EDA
) \
X(PAR) \
X(PDN) \
X(PDR) \
...
...
src/utl/include/utl/tcl_utl.h
0 → 100644
View file @
127a0e19
#pragma once
struct
Tcl_Interp
;
namespace
utl
{
// TCL init files are encoded into the string init using the three
// digit decimal equivalent for each ascii character. This function
// unencodes the string and evals it. This packages the TCL init
// files as part of the executable so they don't have to be shipped as
// separate files that have to be located and loaded at run time.
void
evalTclInit
(
Tcl_Interp
*
interp
,
const
char
*
inits
[]);
char
*
unencode
(
const
char
*
inits
[]);
}
// namespace utl
src/utl/src/tcl_utl.cpp
0 → 100644
View file @
127a0e19
#include <tcl.h>
#include <string.h>
#include <stdlib.h>
#include "utl/tcl_utl.h"
namespace
utl
{
void
evalTclInit
(
Tcl_Interp
*
interp
,
const
char
*
inits
[])
{
char
*
unencoded
=
unencode
(
inits
);
if
(
Tcl_Eval
(
interp
,
unencoded
)
!=
TCL_OK
)
{
// Get a backtrace for the error.
Tcl_Eval
(
interp
,
"$errorInfo"
);
const
char
*
tcl_err
=
Tcl_GetStringResult
(
interp
);
fprintf
(
stderr
,
"Error: TCL init script: %s.
\n
"
,
tcl_err
);
fprintf
(
stderr
,
" Try deleting TclInitVar.cc and rebuilding.
\n
"
);
exit
(
0
);
}
delete
[]
unencoded
;
}
char
*
unencode
(
const
char
*
inits
[])
{
size_t
length
=
0
;
for
(
const
char
**
e
=
inits
;
*
e
;
e
++
)
{
const
char
*
init
=
*
e
;
length
+=
strlen
(
init
);
}
char
*
unencoded
=
new
char
[
length
/
3
+
1
];
char
*
u
=
unencoded
;
for
(
const
char
**
e
=
inits
;
*
e
;
e
++
)
{
const
char
*
init
=
*
e
;
size_t
init_length
=
strlen
(
init
);
for
(
const
char
*
s
=
init
;
s
<
&
init
[
init_length
];
s
+=
3
)
{
char
code
[
4
]
=
{
s
[
0
],
s
[
1
],
s
[
2
],
'\0'
};
char
ch
=
atoi
(
code
);
*
u
++
=
ch
;
}
}
*
u
=
'\0'
;
return
unencoded
;
}
}
// namespace utl
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment