Skip to content

Commit

Permalink
Merge pull request QB64-Phoenix-Edition#470 from a740g/llvm-mingw-fixes
Browse files Browse the repository at this point in the history
DATA fixes
  • Loading branch information
a740g committed Mar 25, 2024
2 parents cae5949 + 4d771e3 commit ab23b0f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 54 deletions.
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,10 @@ ifeq ($(OS),win)
endif
endif

ifneq ($(filter y,$(DEP_DATA)),)
EXE_OBJS += $(PATH_INTERNAL_TEMP)/data.o
endif

ifneq ($(filter y,$(DEP_EMBED)),)
EXE_OBJS += $(PATH_INTERNAL_TEMP)/embedded.o
endif


QBLIB := $(PATH_INTERNAL_C)/$(QBLIB_NAME).o

$(QBLIB): $(PATH_INTERNAL_C)/libqb.cpp
Expand All @@ -408,9 +403,6 @@ ifeq ($(OS),osx)
$(CXX) $(CXXFLAGS) $< -c -o $@
endif

$(PATH_INTERNAL_TEMP)/data.o: $(PATH_INTERNAL_TEMP)/data.bin
$(OBJCOPY) -Ibinary $(OBJCOPY_FLAGS) $< $@

$(PATH_INTERNAL_TEMP)/embedded.o: $(PATH_INTERNAL_TEMP)/embedded.cpp
$(CXX) $(CXXFLAGS) $< -c -o $@

Expand Down
1 change: 0 additions & 1 deletion docs/build-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ These flags controls whether certain dependencies are compiled in or not. All of
| `DEP_FONT` | Enables various `_FONT` related support. |
| `DEP_DEVICEINPUT` | Enables game controller input support. |
| `DEP_ZLIB` | Adds `_DEFLATE` and `_INFLATE` support. |
| `DEP_DATA` | Compiles in data produced via `DATA` statements. |
| `DEP_EMBED` | Compiles in data embedded via `$EMBED` statements. |
| `DEP_CONSOLE` | On Windows, this gives the program console support (graphical support is still allowed) |
| `DEP_CONSOLE_ONLY` | Same as `DEP_CONSOLE`, but also removes GLUT and graphics support. |
Expand Down
8 changes: 4 additions & 4 deletions setup_mingw.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ rem MINGW_DIR is actually the internal directory name inside the zip / 7z file
rem It needs to be updated whenever the toolchains are updated
if "%ARCH%" == "ARM" (
if %BITS% == 64 (
set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-ucrt-aarch64.zip"
set MINGW_DIR=llvm-mingw-20231128-ucrt-aarch64
set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20240320/llvm-mingw-20240320-ucrt-aarch64.zip"
set MINGW_DIR=llvm-mingw-20240320-ucrt-aarch64
) else (
set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-ucrt-armv7.zip"
set MINGW_DIR=llvm-mingw-20231128-ucrt-armv7
set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20240320/llvm-mingw-20240320-ucrt-armv7.zip"
set MINGW_DIR=llvm-mingw-20240320-ucrt-armv7
)
set MINGW_TEMP_FILE=temp.zip
) else (
Expand Down
65 changes: 24 additions & 41 deletions source/qb64pe.bas
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,14 @@ IF INSTR(_OS$, "[LINUX]") THEN os$ = "LNX"
DIM SHARED MacOSX AS LONG
IF INSTR(_OS$, "[MACOSX]") THEN MacOSX = 1

DIM SHARED inline_DATA
IF MacOSX OR INSTR(_OS$, "[ARM]") THEN inline_DATA = 1

DIM SHARED BATCHFILE_EXTENSION AS STRING
BATCHFILE_EXTENSION = ".bat"
IF os$ = "LNX" THEN BATCHFILE_EXTENSION = ".sh"
IF MacOSX THEN BATCHFILE_EXTENSION = ".command"


DIM inlinedatastr(255) AS STRING
DIM inlinedatastr(0 TO 255) AS STRING
FOR i = 0 TO 255
inlinedatastr(i) = str2$(i) + ","
NEXT
Expand Down Expand Up @@ -440,7 +438,7 @@ END IF
'255 A qb error happened in the IDE (compiler->ide)
' note: detected by the fact that ideerror was not set to 0
' [255]
'$include:'./utilities/hash.bi'
'$INCLUDE:'./utilities/hash.bi'

TYPE Label_Type
State AS _UNSIGNED _BYTE '0=label referenced, 1=label created
Expand Down Expand Up @@ -11961,42 +11959,28 @@ IF DataOffset = 0 THEN

ELSE

IF inline_DATA = 0 THEN
IF os$ = "WIN" THEN
IF OS_BITS = 32 THEN
x$ = CHR$(0): WriteBufRawData DataBinBuf, x$
WriteBufLine GlobTxtBuf, "extern " + CHR$(34) + "C" + CHR$(34) + "{"
WriteBufLine GlobTxtBuf, "extern char *binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;"
WriteBufLine GlobTxtBuf, "}"
WriteBufLine GlobTxtBuf, "uint8 *data=(uint8*)&binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;"
ELSE
x$ = CHR$(0): WriteBufRawData DataBinBuf, x$
WriteBufLine GlobTxtBuf, "extern " + CHR$(34) + "C" + CHR$(34) + "{"
WriteBufLine GlobTxtBuf, "extern char *_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;"
WriteBufLine GlobTxtBuf, "}"
WriteBufLine GlobTxtBuf, "uint8 *data=(uint8*)&_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;"
END IF
END IF
IF os$ = "LNX" THEN
x$ = CHR$(0): WriteBufRawData DataBinBuf, x$
WriteBufLine GlobTxtBuf, "extern " + CHR$(34) + "C" + CHR$(34) + "{"
WriteBufLine GlobTxtBuf, "extern char *_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;"
WriteBufLine GlobTxtBuf, "}"
WriteBufLine GlobTxtBuf, "uint8 *data=(uint8*)&_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;"
END IF
ELSE
'inline data
ff = OpenBuffer%("B", tmpdir$ + "data.bin")
x$ = ReadBufRawData$(ff, GetBufLen&(ff))
x2$ = "uint8 inline_data[]={"
FOR i = 1 TO LEN(x$)
x2$ = x2$ + inlinedatastr$(ASC(x$, i))
NEXT
x2$ = x2$ + "0};"
WriteBufLine GlobTxtBuf, x2$
WriteBufLine GlobTxtBuf, "uint8 *data=&inline_data[0];"
x$ = "": x2$ = ""
END IF
'inline data
ff = OpenBuffer%("B", tmpdir$ + "data.bin")
x$ = ReadBufRawData$(ff, GetBufLen&(ff))

idsL = LEN(inlinedatastr(255))
xL = LEN(x$)

x2$ = SPACE$(xL * idsL) ' pre-allocate buffer

x2Ofs = 1
FOR i = 1 TO xL
MID$(x2$, x2Ofs, idsL) = inlinedatastr(ASC(x$, i))
x2Ofs = x2Ofs + idsL
NEXT

WriteBufLine GlobTxtBuf, "uint8 inline_data[]={"
WriteBufLine GlobTxtBuf, x2$
WriteBufLine GlobTxtBuf, "0};"
WriteBufLine GlobTxtBuf, "uint8 *data=&inline_data[0];"

x$ = "": x2$ = ""

END IF

IF Debug THEN PRINT #9, "Beginning generation of code for saving/sharing common array data..."
Expand Down Expand Up @@ -12600,7 +12584,6 @@ IF DEPENDENCY(DEPENDENCY_SCREENIMAGE) THEN makedeps$ = makedeps$ + " DEP_SCREENI
IF DEPENDENCY(DEPENDENCY_LOADFONT) THEN makedeps$ = makedeps$ + " DEP_FONT=y"
IF DEPENDENCY(DEPENDENCY_DEVICEINPUT) THEN makedeps$ = makedeps$ + " DEP_DEVICEINPUT=y"
IF DEPENDENCY(DEPENDENCY_ZLIB) THEN makedeps$ = makedeps$ + " DEP_ZLIB=y"
IF inline_DATA = 0 AND DataOffset THEN makedeps$ = makedeps$ + " DEP_DATA=y"
IF DEPENDENCY(DEPENDENCY_EMBED) THEN makedeps$ = makedeps$ + " DEP_EMBED=y"
IF ConsoleOn THEN makedeps$ = makedeps$ + " DEP_CONSOLE=y"
IF ExeIconSet OR VersionInfoSet THEN makedeps$ = makedeps$ + " DEP_ICON_RC=y"
Expand Down

0 comments on commit ab23b0f

Please sign in to comment.