-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP]Adds support for static dm libraries #19
base: v2
Are you sure you want to change the base?
Conversation
@@ -60,6 +60,7 @@ def __init__(self) -> None: | |||
output = "" | |||
|
|||
if code.find("/proc/main") == -1: | |||
libsDir = Path(os.path.realpath(__file__)) / 'StaticLibs' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're gonna want to do Path(...).parent
.
@@ -68,6 +69,10 @@ def __init__(self) -> None: | |||
continue | |||
|
|||
lines[index] = "\t" + line | |||
if line.find('#include "'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend using regex and finditer
so you can make the parsing easier and allow multiple files.
@@ -68,6 +69,10 @@ def __init__(self) -> None: | |||
continue | |||
|
|||
lines[index] = "\t" + line | |||
if line.find('#include "'): | |||
library = line[10:-1]; # Fetch the library name within the "" | |||
libToCopy = libsDir.glob(library+".dm") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should sanitize to make sure the path is actually in there and there's no hackery with like ../
So here's a fun problem: The benchmark code you pulled from Ginja's bot is licensed under AGPL. My bot is MIT. On one side you can ignore this because who cares on the other it's kinda iffy. |
All but There are some additional changes in GinjaNinja32/bot32@8bf6510 that I've pointed Carbonhell to; BENCHT, BENCHTK, and BENCHTM I'm likewise happy for you to use under MIT. |
is this still work in progress? @Carbonhell |
Adds support for users to use the #include directive to include libraries within the bot StaticLibs folder. While building the output, the code will intercept #include directives, attempt to find the library itself, and copy it over to the temp project folder.
Untested as for now. Also includes the first library, utils.dm, containing some helper procs and most important, some defines to calculate processing time easily, courtesy of GinjaNinja32: https://github.com/GinjaNinja32/bot32/blob/dev/dm/util.dm