Relative blitz.mod/incbin url usage
GWRon opened this issue · 0 comments
"Scaremonger" ("si") wrote in the discord channel:
I've been digging about in the bmk source code to figure out whats causing my issue and have tracked it down to where the lua code "bmk_compileC" generated by TBMKCommand calls TBMK.MultiSys() in the bmk_ng.bmx file. Hats off to Brucey and/or Mark; that code is very inspirational, but I am now stuck.
To duplicate my issue, create a folder structure like this:
mytest
mytest/bin
mytest/bin/images
Copy a ".png" file into the images folder and rename it "test.png" (Size and content doesn't matter).
Create these two files in mytest:
test_from_root.bmx
SuperStrict
Import brl.blitz
Incbin "bin/images/test.png"
Global img:TImage = LoadImage( "incbin::bin/images/test.png" )
Print(img.height+","+img.width)
test_from_folder.bmx
SuperStrict
Import brl.blitz
Include "bin/images.bmx"
Print(img.height+","+img.width)
Create this file in mytest/bin:
images.bmx
Incbin "images/test.png"
Global img:TImage = LoadImage( "incbin::images/test.png" )
When you run "test_from_root.bmx" it works fine, but "test_from_folder.bmx" fails with fatal error: brl.mod/blitz.mod/incbin/incbin.h: No such file or directory
During compile, both apps create "mytest/.bmx/test_from_folder.bmx.debug.linux.x64.incbin2.c" which look something like this:
#define INCBIN_PREFIX _ib
#define INCBIN_STYLE INCBIN_STYLE_SNAKE
#include "brl.mod/blitz.mod/incbin/incbin.h"
// FILE : "images/test.png" a895b73a2290f5f1
// ----
INCBIN(_bb_main_1, "/home/si/dev/mytest/bin/images/test.png")
The compiler is failing on the line that reads #include "brl.mod/blitz.mod/incbin/incbin.h" , however I checked and that file exists.
The Lua script "bmk_compileC", runs TBMK.MultiSys()
which is located in bmk_ng.bmx with the following parameters (cmd,src,obj)
before failing:
cmd: gcc -w -DBMX_NG -fno-strict-aliasing -fpie -fno-exceptions -c -O3 -msse3 -s -g -o /home/si/dev/mytest/.bmx/test-from-folder.bmx.debug.linux.x64.incbin2.o /home/si/dev/mytest/.bmx/test-from-folder.bmx.debug.linux.x64.incbin2.c
src: /home/si/dev/mytest/.bmx/test-from-folder.bmx.debug.linux.x64.incbin2.c
obj: /home/si/dev/mytest/.bmx/test-from-folder.bmx.debug.linux.x64.incbin2.o
At the time TBMK.MultiSys()
is called, the current directory is "/home/si/dev/mytest/.bmx" and it looks like gcc is not being passed the correct path to look for the header file(s).
If you create "/home/si/dev/mytest/.bmx/brl.mod/blitz.mod/incbin/incbin.h", then the compiler progresses, but fails on another missing file, so it does seem to point to a relative path problem...