Skip to content

Commit

Permalink
Merge pull request #442 from QB64-Phoenix-Edition/ext-dep-chk
Browse files Browse the repository at this point in the history
Add external dependencies checks
  • Loading branch information
RhoSigma-QB64 committed Jan 30, 2024
2 parents 5dad21a + 6077e04 commit 4534f28
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ endif
DEP_HTTP := y
DEP_CONSOLE := y
DEP_ZLIB := y
ifeq ($(OS),lnx)
DEP_DATA := y
endif
endif

include $(PATH_INTERNAL_C)/libqb/build.mk
Expand Down
Binary file modified internal/source/data.bin
Binary file not shown.
37 changes: 36 additions & 1 deletion source/ide/ide_methods.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,42 @@ FUNCTION ide2 (ignore)

LOCATE , , 0
clearStatusWindow 0
If NoExeSaved then idecompiled = 0: GOTO mustGenerateExe

'=== BEGIN: checking external dependencies ===
edFF = FREEFILE: edLD = -1
'-----
nul& = SeekBuf&(ExtDepBuf, 0, SBM_BufStart)
IF ReadBufLine$(ExtDepBuf) <> "<<< LISTING DONE >>>" THEN
nul& = SeekBuf&(ExtDepBuf, 0, SBM_BufEnd): edLD = 0
FOR i = 0 TO UBOUND(embedFileList$, 2)
IF embedFileList$(eflFile, i) <> "" AND embedFileList$(eflUsed, i) = "yes" THEN
WriteBufLine ExtDepBuf, _FULLPATH$(embedFileList$(eflFile, i))
END IF
NEXT i
nul& = SeekBuf&(ExtDepBuf, 0, SBM_BufStart)
WriteBufLine ExtDepBuf, "<<< LISTING DONE >>>"
END IF
'-----
WHILE NOT EndOfBuf%(ExtDepBuf)
OPEN "B", #edFF, ReadBufLine$(ExtDepBuf)
edDAT$ = SPACE$(LOF(edFF))
GET #edFF, , edDAT$
CLOSE #edFF
IF edLD THEN DeleteBufLine ExtDepBuf
WriteBufLine ExtDepBuf, RIGHT$("00000000" + HEX$(GetCRC32&(edDAT$)), 8)
WEND
nul& = SeekBuf&(ExtDepBuf, 0, SBM_BufStart)
'-----
OPEN "B", #edFF, tmpdir$ + "extdep.txt"
edDAT$ = SPACE$(LOF(edFF))
GET #edFF, , edDAT$
CLOSE #edFF
IF edDAT$ <> ReadBufRawData$(ExtDepBuf, GetBufLen&(ExtDepBuf)) THEN
idecompiled = 0: GOTO mustGenerateExe
END IF
'=== END: checking external dependencies ===

IF NoExeSaved THEN idecompiled = 0: GOTO mustGenerateExe
IF idecompiled THEN

IF iderunmode = 2 AND _FILEEXISTS(lastBinaryGenerated$) THEN
Expand Down
10 changes: 7 additions & 3 deletions source/qb64pe.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1503,8 +1503,8 @@ MidiSoundFont$ = ""
' Reset embedded files tracking list
REDIM SHARED embedFileList$(3, 10)



'External dependencies buffer
DIM SHARED ExtDepBuf: ExtDepBuf = OpenBuffer%("O", tmpdir$ + "extdep.txt")



Expand Down Expand Up @@ -2134,7 +2134,7 @@ DO

'intercept current expression and pass it through Evaluate_Expression$
'(unless it is a literal string)
Dim tempNum As ParseNum
DIM tempNum AS ParseNum
temp1$ = _TRIM$(Evaluate_Expression$(e$, tempNum))

IF LEFT$(temp1$, 8) = "ERROR - " THEN
Expand Down Expand Up @@ -3361,6 +3361,7 @@ DO

ExeIconSet = linenumber
SetDependency DEPENDENCY_ICON
WriteBufLine ExtDepBuf, _FULLPATH$(ExeIconFile$)
IF CheckingOn THEN WriteBufLine MainTxtBuf, "do{"
WriteBufLine MainTxtBuf, "sub__icon(NULL,NULL,0);"
GOTO finishedline2
Expand Down Expand Up @@ -3425,6 +3426,7 @@ DO
GOTO errmes
END IF
END IF
WriteBufLine ExtDepBuf, _FULLPATH$(MidiSoundFont$)
ELSE
' Constant values, only one for now
SELECT CASE UCASE$(MidiSoundFont$)
Expand All @@ -3433,6 +3435,7 @@ DO

' Clear MidiSoundFont$ to indicate the default should be used
MidiSoundFont$ = ""
WriteBufLine ExtDepBuf, _FULLPATH$("internal/support/default_soundfont.sf2")

CASE ELSE
a$ = "Unrecognized Soundfont option " + AddQuotes$(MidiSoundFont$)
Expand Down Expand Up @@ -11385,6 +11388,7 @@ DO
IF try = 2 THEN f$ = a$
IF _FILEEXISTS(f$) THEN
qberrorhappened = -2 '***
WriteBufLine ExtDepBuf, _FULLPATH$(f$)
OPEN f$ FOR BINARY AS #fh
qberrorhappened2: '***
IF qberrorhappened = -2 THEN EXIT FOR '***
Expand Down
18 changes: 18 additions & 0 deletions source/utilities/s-buffer/simplebuffer.bm
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,24 @@ MID$(simplebuffer_array$(buf& + 1), 5, 4) = MKL$(cbl&& + chg&)
MID$(simplebuffer_array$(buf& + 1), 13, 4) = MKL$(-1)
END SUB

'---------------------------------------------------------------------
SUB DeleteBufLine (handle%)
'--- option _explicit requirements ---
DIM buf&, cur&, cbl&&, brc$, brl%, eol&, chg&
'--- prepare values ---
buf& = handle% * 106
cur& = GetBufPos&(handle%): cbl&& = GetBufLen&(handle%)
brc$ = BufEolSeq$(handle%): brl% = LEN(brc$)
'--- find next line break ---
eol& = INSTR(cur&, simplebuffer_array$(buf& + 0), brc$)
IF eol& = 0 OR eol& > cbl&& THEN eol& = cbl&& + 1: brl% = 0
chg& = (eol& + brl%) - cur&
'--- delete from buffer ---
MID$(simplebuffer_array$(buf& + 0), cur&) = MID$(simplebuffer_array$(buf& + 0), eol& + brl%, cbl&& - (eol& + brl%) + 1)
MID$(simplebuffer_array$(buf& + 1), 5, 4) = MKL$(cbl&& - chg&)
IF chg& > 0 THEN MID$(simplebuffer_array$(buf& + 1), 13, 4) = MKL$(-1)
END SUB

'---------------------------------------------------------------------
FUNCTION ReadBufRawData$ (handle%, size&) 'size change intended
'--- option _explicit requirements ---
Expand Down
59 changes: 59 additions & 0 deletions source/utilities/strings.bas
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,62 @@ FUNCTION str2i64$ (v&&)
str2i64$ = LTRIM$(RTRIM$(STR$(v&&)))
END FUNCTION

'
' Build the CRC32 checksum of a string message
'
FUNCTION GetCRC32& (MsgData$)
STATIC lut~&()
'--- option _explicit requirements ---
DIM i%, crc~&, i&
'--- init lookup table on first call ---
$CHECKING:OFF
REDIM _PRESERVE lut~&(0 TO 255)
IF lut~&(1) = 0 THEN
RESTORE GetCRC32_LookupTable
FOR i% = 0 TO 255: READ lut~&(i%): NEXT i%
END IF
'--- compute CRC32 ---
crc~& = &HFFFFFFFF
FOR i& = 1 TO LEN(MsgData$)
crc~& = ((crc~& \ 256) XOR lut~&((crc~& XOR ASC(MsgData$, i&)) AND 255))
NEXT i&
$CHECKING:ON
'--- set result & cleanup ---
GetCRC32& = (crc~& XOR &HFFFFFFFF)
EXIT FUNCTION
'--------------------
GetCRC32_LookupTable:
DATA &H00000000,&H77073096,&HEE0E612C,&H990951BA,&H076DC419,&H706AF48F,&HE963A535,&H9E6495A3
DATA &H0EDB8832,&H79DCB8A4,&HE0D5E91E,&H97D2D988,&H09B64C2B,&H7EB17CBD,&HE7B82D07,&H90BF1D91
DATA &H1DB71064,&H6AB020F2,&HF3B97148,&H84BE41DE,&H1ADAD47D,&H6DDDE4EB,&HF4D4B551,&H83D385C7
DATA &H136C9856,&H646BA8C0,&HFD62F97A,&H8A65C9EC,&H14015C4F,&H63066CD9,&HFA0F3D63,&H8D080DF5
DATA &H3B6E20C8,&H4C69105E,&HD56041E4,&HA2677172,&H3C03E4D1,&H4B04D447,&HD20D85FD,&HA50AB56B
DATA &H35B5A8FA,&H42B2986C,&HDBBBC9D6,&HACBCF940,&H32D86CE3,&H45DF5C75,&HDCD60DCF,&HABD13D59
DATA &H26D930AC,&H51DE003A,&HC8D75180,&HBFD06116,&H21B4F4B5,&H56B3C423,&HCFBA9599,&HB8BDA50F
DATA &H2802B89E,&H5F058808,&HC60CD9B2,&HB10BE924,&H2F6F7C87,&H58684C11,&HC1611DAB,&HB6662D3D
DATA &H76DC4190,&H01DB7106,&H98D220BC,&HEFD5102A,&H71B18589,&H06B6B51F,&H9FBFE4A5,&HE8B8D433
DATA &H7807C9A2,&H0F00F934,&H9609A88E,&HE10E9818,&H7F6A0DBB,&H086D3D2D,&H91646C97,&HE6635C01
DATA &H6B6B51F4,&H1C6C6162,&H856530D8,&HF262004E,&H6C0695ED,&H1B01A57B,&H8208F4C1,&HF50FC457
DATA &H65B0D9C6,&H12B7E950,&H8BBEB8EA,&HFCB9887C,&H62DD1DDF,&H15DA2D49,&H8CD37CF3,&HFBD44C65
DATA &H4DB26158,&H3AB551CE,&HA3BC0074,&HD4BB30E2,&H4ADFA541,&H3DD895D7,&HA4D1C46D,&HD3D6F4FB
DATA &H4369E96A,&H346ED9FC,&HAD678846,&HDA60B8D0,&H44042D73,&H33031DE5,&HAA0A4C5F,&HDD0D7CC9
DATA &H5005713C,&H270241AA,&HBE0B1010,&HC90C2086,&H5768B525,&H206F85B3,&HB966D409,&HCE61E49F
DATA &H5EDEF90E,&H29D9C998,&HB0D09822,&HC7D7A8B4,&H59B33D17,&H2EB40D81,&HB7BD5C3B,&HC0BA6CAD
DATA &HEDB88320,&H9ABFB3B6,&H03B6E20C,&H74B1D29A,&HEAD54739,&H9DD277AF,&H04DB2615,&H73DC1683
DATA &HE3630B12,&H94643B84,&H0D6D6A3E,&H7A6A5AA8,&HE40ECF0B,&H9309FF9D,&H0A00AE27,&H7D079EB1
DATA &HF00F9344,&H8708A3D2,&H1E01F268,&H6906C2FE,&HF762575D,&H806567CB,&H196C3671,&H6E6B06E7
DATA &HFED41B76,&H89D32BE0,&H10DA7A5A,&H67DD4ACC,&HF9B9DF6F,&H8EBEEFF9,&H17B7BE43,&H60B08ED5
DATA &HD6D6A3E8,&HA1D1937E,&H38D8C2C4,&H4FDFF252,&HD1BB67F1,&HA6BC5767,&H3FB506DD,&H48B2364B
DATA &HD80D2BDA,&HAF0A1B4C,&H36034AF6,&H41047A60,&HDF60EFC3,&HA867DF55,&H316E8EEF,&H4669BE79
DATA &HCB61B38C,&HBC66831A,&H256FD2A0,&H5268E236,&HCC0C7795,&HBB0B4703,&H220216B9,&H5505262F
DATA &HC5BA3BBE,&HB2BD0B28,&H2BB45A92,&H5CB36A04,&HC2D7FFA7,&HB5D0CF31,&H2CD99E8B,&H5BDEAE1D
DATA &H9B64C2B0,&HEC63F226,&H756AA39C,&H026D930A,&H9C0906A9,&HEB0E363F,&H72076785,&H05005713
DATA &H95BF4A82,&HE2B87A14,&H7BB12BAE,&H0CB61B38,&H92D28E9B,&HE5D5BE0D,&H7CDCEFB7,&H0BDBDF21
DATA &H86D3D2D4,&HF1D4E242,&H68DDB3F8,&H1FDA836E,&H81BE16CD,&HF6B9265B,&H6FB077E1,&H18B74777
DATA &H88085AE6,&HFF0F6A70,&H66063BCA,&H11010B5C,&H8F659EFF,&HF862AE69,&H616BFFD3,&H166CCF45
DATA &HA00AE278,&HD70DD2EE,&H4E048354,&H3903B3C2,&HA7672661,&HD06016F7,&H4969474D,&H3E6E77DB
DATA &HAED16A4A,&HD9D65ADC,&H40DF0B66,&H37D83BF0,&HA9BCAE53,&HDEBB9EC5,&H47B2CF7F,&H30B5FFE9
DATA &HBDBDF21C,&HCABAC28A,&H53B39330,&H24B4A3A6,&HBAD03605,&HCDD70693,&H54DE5729,&H23D967BF
DATA &HB3667A2E,&HC4614AB8,&H5D681B02,&H2A6F2B94,&HB40BBE37,&HC30C8EA1,&H5A05DF1B,&H2D02EF8D
END FUNCTION

0 comments on commit 4534f28

Please sign in to comment.