em00k/NextBuild

nextbuild.py processes LoadSDBank when commented (NextBuild v7)

j-stroud opened this issue · 5 comments

If I use the LoadSDBank proc and comment it out, it's still processed by nextbuild.py and can raise an error

' LoadSDBank("foo", addr, size, ofs, bank)

e.g. if the filename doesn't exist then
##ERROR - Failed to find file :./data/foo Please make sure this file exist!

em00k commented

I am aware of this and its due to way the python pre-processor parser works.

For now remove the L in LoadSDBank eg

' oadSDBank("foo", addr, size, ofs, bank)

Thanks.
This is how I've attempted a fix for now. Obviously limited to certain use-cases. Let me know if you'd want a PR

@@ -248,13 +248,13 @@ try:
             x = x.replace(")", ",")
             x = x.replace("(", ",")
             # convert to lower case so xl.find() will be case insensitive
-            xl = x.lower()
+            xl = x.lower().strip()
             curline += 1
             # look for SD command
             ldsd_pos = xl.find("loadsdbank,")
             if ldsd_pos != -1:
-                # is it isnt the main SUB
-                if xl.find("sub") == -1:
+                # if it isnt the main SUB or a commented out line
+                if xl.find("sub") == -1 and xl[0] != "'":
                     # get the filename + add the data path
                     partname = x.split('"')[2-1]
                     filename = "./data/" + partname
em00k commented

Thanks - I think I need to also apply the same sort of splicing elsewhere because when you add a comment on any of the lines with with directives it throws an error, eg on the org line.

em00k commented

I've included your fix for LoadSDBank, I've managed to fix the directives a different way - thanks!

thanks!