Skip to content
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

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from

Conversation

Carbonhell
Copy link

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

@@ -60,6 +60,7 @@ def __init__(self) -> None:
output = ""

if code.find("/proc/main") == -1:
libsDir = Path(os.path.realpath(__file__)) / 'StaticLibs'
Copy link
Owner

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 "'):
Copy link
Owner

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")
Copy link
Owner

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 ../

@PJB3005
Copy link
Owner

PJB3005 commented Jan 23, 2019

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.

@GinjaNinja32
Copy link

All but stars (taken from BS12) and possibly seq (unsure of origin; it reads like my code, but I'm not sure) I wrote myself; I'm happy for you to take them under MIT for use here.

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.

@ondrej008
Copy link

is this still work in progress? @Carbonhell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants