Changeset 85823 in vbox
- Timestamp:
- Aug 18, 2020 3:57:43 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.vbs
r85814 r85823 394 394 ' Generic helper for looking for a tools under g_strPathDev. 395 395 ' 396 ' The callback function takes the '.../tools/win.arch/tool/version' dir a s397 ' argument and returnsan non-empty string if it was found suitable.398 ' 399 function SearchToolsEx(strTool, strVerPrefix, ByRef fnCallback, ByRef arrToolsDirs)396 ' The callback function takes the '.../tools/win.arch/tool/version' dir and 397 ' varUser as arguments, returning an non-empty string if it was found suitable. 398 ' 399 function SearchToolsEx(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser, ByRef arrToolsDirs) 400 400 dim strToolsDir, arrDirs, strDir 401 401 SearchToolsEx = "" … … 403 403 arrDirs = GetSubdirsStartingWithRVerSorted(strToolsDir, strVerPrefix) 404 404 for each strDir in arrDirs 405 SearchToolsEx = fnCallback(strToolsDir & "/" & strDir )405 SearchToolsEx = fnCallback(strToolsDir & "/" & strDir, varUser) 406 406 if SearchToolsEx <> "" then 407 407 exit function … … 412 412 413 413 '' Search under g_strPathDev for a tool, target arch first. 414 function SearchTargetTools(strTool, strVerPrefix, ByRef fnCallback )415 SearchTargetTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, _414 function SearchTargetTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser) 415 SearchTargetTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, _ 416 416 Array(g_strPathDev & "/win." & g_strTargetArch & "/" & strTool, _ 417 417 g_strPathDev & "/win.x86/" & strTool, _ … … 420 420 421 421 '' Search under g_strPathDev for a tool, host arch first. 422 function SearchHostTools(strTool, strVerPrefix, ByRef fnCallback )423 SearchHostTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, _422 function SearchHostTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser) 423 SearchHostTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, _ 424 424 Array(g_strPathDev & "/win." & g_strHostArch & "/" & strTool, _ 425 425 g_strPathDev & "/win.x86/" & strTool, _ … … 428 428 429 429 '' Search under g_strPathDev for a tool, common dir first. 430 function SearchCommonTools(strTool, strVerPrefix, ByRef fnCallback )431 SearchCommonTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, _430 function SearchCommonTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser) 431 SearchCommonTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, _ 432 432 Array(g_strPathDev & "/common/" & strTool, _ 433 433 g_strPathDev & "/win." & g_strHostArch & "/" & strTool, _ … … 1345 1345 ' 1346 1346 sub CheckForYasm(strOptYasm) 1347 dim strPathYasm 1347 dim strPathYasm, strVersion 1348 1348 PrintHdr "yasm" 1349 1349 1350 strPathYasm = CheckForYasmSub(strOptYasm) 1351 if strPathYasm = "" then strPathYasm = CheckForYasmSub(PathStripFilename(strOptYasm)) 1352 if strPathYasm = "" and g_blnInternalFirst = true then strPathYasm = SearchHostTools("yasm", "v", GetRef("CheckForYasmSub")) 1353 if strPathYasm = "" then strPathYasm = CheckForYasmSub(PathStripFilename(Which("yasm.exe"))) 1354 if strPathYasm = "" and g_blnInternalFirst = false then strPathYasm = SearchHostTools("yasm", "v", GetRef("CheckForYasmSub")) 1350 strVersion = "" 1351 strPathYasm = CheckForYasmSub(strOptYasm, strVersion) 1352 if strPathYasm = "" then strPathYasm = CheckForYasmSub(PathStripFilename(strOptYasm), strVersion) 1353 if strPathYasm = "" and g_blnInternalFirst = true then 1354 strPathYasm = SearchHostTools("yasm", "v", GetRef("CheckForYasmSub"), strVersion) 1355 end if 1356 if strPathYasm = "" then strPathYasm = CheckForYasmSub(PathStripFilename(Which("yasm.exe")), strVersion) 1357 if strPathYasm = "" and g_blnInternalFirst = false then 1358 strPathYasm = SearchHostTools("yasm", "v", GetRef("CheckForYasmSub"), strVersion) 1359 end if 1355 1360 1356 1361 if strPathYasm = "" then … … 1359 1364 else 1360 1365 CfgPrintAssign "PATH_TOOL_YASM", strPathYasm 1361 PrintResult "yasm ", strPathYasm1362 end if 1363 end sub 1364 1365 function CheckForYasmSub(strPathYasm )1366 PrintResult "yasm v" & strVersion, strPathYasm 1367 end if 1368 end sub 1369 1370 function CheckForYasmSub(strPathYasm, ByRef strVersion) 1366 1371 CheckForYasmSub = "" 1367 1372 if strPathYasm <> "" then 1368 1373 if LogFileExists(strPathYasm, "yasm.exe") then 1369 CheckForYasmSub = UnixSlashes(PathAbs(strPathYasm)) 1374 dim strOutput 1375 if Shell("""" & DosSlashes(strPathYasm & "\yasm.exe") & """ --version", True, strOutput) = 0 then 1376 dim strPreamble : strPreamble = "yasm" 1377 dim strVer : strVer = Trim(StrGetFirstLine(strOutput)) 1378 if StrComp(Left(strVer, Len(strPreamble)), strPreamble, vbTextCompare) = 0 then 1379 strVersion = StrGetFirstWord(Trim(Mid(strVer, Len(strPreamble) + 1))) 1380 if StrVersionCompare(strVersion, "1.3.0") >= 0 and strVersion <> "" then 1381 LogPrint "Found yasm version: " & strVer 1382 CheckForYasmSub = UnixSlashes(PathAbs(strPathYasm)) 1383 else 1384 LogPrint "yasm version is older than 1.3.0: " & strVersion 1385 end if 1386 else 1387 LogPrint "Not yasm: " & strVer 1388 end if 1389 end if 1370 1390 end if 1371 1391 end if … … 1377 1397 ' 1378 1398 sub CheckForNasm(strOptNasm) 1379 dim strPathNasm 1399 dim strPathNasm, strVersion 1380 1400 PrintHdr "nasm" 1381 1401 1382 strPathNasm = CheckForNasmSub(strOptNasm) 1383 if strPathNasm = "" then strPathNasm = CheckForNasmSub(PathStripFilename(strOptNasm)) 1384 if strPathNasm = "" and g_blnInternalFirst = true then strPathNasm = SearchHostTools("nasm", "v", GetRef("CheckForNasmSub")) 1385 if strPathNasm = "" then strPathNasm = CheckForNasmSub(LogRegGetString("HKLM\SOFTWARE\nasm\")) 1386 if strPathNasm = "" then strPathNasm = CheckForNasmSub(LogRegGetString("HKCU\SOFTWARE\nasm\")) 1402 strPathNasm = CheckForNasmSub(strOptNasm, strVersion) 1403 if strPathNasm = "" then strPathNasm = CheckForNasmSub(PathStripFilename(strOptNasm), strVersion) 1404 if strPathNasm = "" and g_blnInternalFirst = true then 1405 strPathNasm = SearchHostTools("nasm", "v", GetRef("CheckForNasmSub"), strVersion) 1406 end if 1407 if strPathNasm = "" then strPathNasm = CheckForNasmSub(LogRegGetString("HKLM\SOFTWARE\nasm\"), strVersion) 1408 if strPathNasm = "" then strPathNasm = CheckForNasmSub(LogRegGetString("HKCU\SOFTWARE\nasm\"), strVersion) 1387 1409 if strPathNasm = "" then 1388 1410 for each strCandidate in CollectFromProgramItemLinks(GetRef("NasmProgramItemCallback"), strPathNasm) 1389 strPathNasm = CheckForNasmSub(strCandidate )1411 strPathNasm = CheckForNasmSub(strCandidate, strVersion) 1390 1412 next 1391 1413 end if 1392 if strPathNasm = "" then strPathNasm = CheckForNasmSub(PathStripFilename(Which("nasm.exe"))) 1393 if strPathNasm = "" and g_blnInternalFirst = false then strPathNasm = SearchHostTools("nasm", "v", GetRef("CheckForNasmSub")) 1414 if strPathNasm = "" then strPathNasm = CheckForNasmSub(PathStripFilename(Which("nasm.exe")), strVersion) 1415 if strPathNasm = "" and g_blnInternalFirst = false then 1416 strPathNasm = SearchHostTools("nasm", "v", GetRef("CheckForNasmSub"), strVersion) 1417 end if 1394 1418 1395 1419 if strPathNasm = "" then … … 1397 1421 else 1398 1422 CfgPrintAssign "PATH_TOOL_NASM", strPathNasm 1399 PrintResult "nasm ", strPathNasm1423 PrintResult "nasm v" & strVersion, strPathNasm 1400 1424 end if 1401 1425 end sub … … 1413 1437 end function 1414 1438 1415 function CheckForNasmSub(strPathNasm )1439 function CheckForNasmSub(strPathNasm, ByRef strVersion) 1416 1440 CheckForNasmSub = "" 1417 1441 if strPathNasm <> "" then 1418 1442 if LogFileExists(strPathNasm, "nasm.exe") then 1419 CheckForNasmSub = UnixSlashes(PathAbs(strPathNasm)) 1443 dim strOutput 1444 if Shell("""" & DosSlashes(strPathNasm & "\nasm.exe") & """ -version", True, strOutput) = 0 then 1445 dim strPreamble : strPreamble = "NASM version" 1446 dim strVer : strVer = Trim(StrGetFirstLine(strOutput)) 1447 if StrComp(Left(strVer, Len(strPreamble)), strPreamble, vbTextCompare) = 0 then 1448 strVersion = StrGetFirstWord(Trim(Mid(strVer, Len(strPreamble) + 1))) 1449 if StrVersionCompare(strVersion, "2.12.0") >= 0 and strVersion <> "" then 1450 LogPrint "Found nasm version: " & strVersion 1451 CheckForNasmSub = UnixSlashes(PathAbs(strPathNasm)) 1452 else 1453 LogPrint "nasm version is older than 2.12.0: " & strVersion 1454 end if 1455 else 1456 LogPrint "Not nasm: " & strVer 1457 end if 1458 end if 1420 1459 end if 1421 1460 end if … … 1427 1466 ' 1428 1467 sub CheckForOpenWatcom(strOptOpenWatcom) 1429 dim strPathOW, strCandidate 1468 dim strPathOW, strCandidate, strVersion 1430 1469 PrintHdr "OpenWatcom" 1431 1470 1432 strPathOW = CheckForOpenWatcomSub(strOptOpenWatcom )1471 strPathOW = CheckForOpenWatcomSub(strOptOpenWatcom, strVersion) 1433 1472 if strPathOW = "" and g_blnInternalFirst = true then 1434 strPathOW = SearchCommonTools("openwatcom", "v", GetRef("CheckForOpenWatcomSub")) 1435 end if 1436 if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(EnvGet("WATCOM")) 1437 if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(PathParent(PathStripFilename(Which("wcc386.exe")))) 1473 strPathOW = SearchCommonTools("openwatcom", "v", GetRef("CheckForOpenWatcomSub"), strVersion) 1474 end if 1438 1475 if strPathOW = "" then 1439 1476 for each strCandidate in CollectFromProgramItemLinks(GetRef("OpenWatcomProgramItemCallback"), strPathOW) 1440 if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(strCandidate )1477 if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(strCandidate, strVersion) 1441 1478 next 1442 1479 end if 1480 if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(EnvGet("WATCOM"), strVersion) 1481 if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(PathParent(PathStripFilename(Which("wcc386.exe"))), strVersion) 1443 1482 if strPathOW = "" and g_blnInternalFirst = false then 1444 strPathOW = SearchCommonTools("openwatcom", "v", GetRef("CheckForOpenWatcomSub") )1483 strPathOW = SearchCommonTools("openwatcom", "v", GetRef("CheckForOpenWatcomSub"), strVersion) 1445 1484 end if 1446 1485 … … 1453 1492 CfgPrintAssign "VBOX_WITH_OPEN_WATCOM", "1" 1454 1493 CfgPrintAssign "PATH_TOOL_OPENWATCOM", strPathOW 1455 PrintResult "OpenWatcom", strPathOW 1494 PrintResult "OpenWatcom v" & strVersion, strPathOW 1495 if StrVersionCompare(strVersion, "2.0") >= 0 then 1496 MsgWarning "We only test building with OpenWatcom 1.9." 1497 end if 1456 1498 end sub 1457 1499 … … 1468 1510 end function 1469 1511 1470 function CheckForOpenWatcomSub(strPathOW )1512 function CheckForOpenWatcomSub(strPathOW, ByRef strVersion) 1471 1513 CheckForOpenWatcomSub = "" 1472 1514 if strPathOW <> "" then … … 1485 1527 and LogFileExists(strPathOW, "h/stdarg.h") _ 1486 1528 then 1487 '' @todo check the version! 1488 CheckForOpenWatcomSub = UnixSlashes(PathAbs(strPathOW)) 1529 ' Some wcl/wcl386 option parsing quirk allows us to specify /whatever 1530 ' and just get the logo text and exit code 0. We use /y as it's a valid option. 1531 dim strOutput 1532 if Shell("""" & DosSlashes(strPathOW & "\binnt\wcl.exe") & """ /y", True, strOutput) = 0 then 1533 dim strPreamble : strPreamble = "Open Watcom C/C++16 Compile and Link Utility Version" 1534 strOutput = StrGetFirstLine(strOutput) 1535 if StrStartsWithI(strOutput, strPreamble) then 1536 strVersion = StrGetFirstWord(Trim(Mid(strOutput, Len(strPreamble) + 1))) 1537 if StrVersionCompare(strVersion, "1.9") >= 0 then 1538 CheckForOpenWatcomSub = UnixSlashes(PathAbs(strPathOW)) 1539 else 1540 LogPrint "OpenWatcom version id older than 1.9: " & strVersion 1541 end if 1542 else 1543 LogPrint "Not OpenWatcom: " & strOutput 1544 end if 1545 end if 1489 1546 end if 1490 1547 end if -
trunk/tools/win/vbscript/helpers.vbs
r85814 r85823 566 566 567 567 568 '' 569 ' Returns the first list of the given string. 570 function StrGetFirstLine(str) 571 dim off 572 off = InStr(1, str, Chr(10)) 573 if off <= 0 then off = InStr(1, str, Chr(13)) 574 if off > 0 then 575 StrGetFirstLine = Mid(str, 1, off) 576 else 577 StrGetFirstLine = str 578 end if 579 end function 580 581 582 '' 583 ' Returns the first word in the given string. 584 ' 585 ' Only recognizes space, tab, newline and carriage return as word separators. 586 ' 587 function StrGetFirstWord(str) 588 dim strSep, offWord, offEnd, offEnd2, strSeparators 589 strSeparators = " " & Chr(9) & Chr(10) & Chr(13) 590 591 ' Skip leading separators. 592 for offWord = 1 to Len(str) 593 if InStr(1, strSeparators, Mid(str, offWord, 1)) < 1 then exit for 594 next 595 596 ' Find the end. 597 offEnd = Len(str) + 1 598 for offSep = 1 to Len(strSeparators) 599 offEnd2 = InStr(offWord, str, Mid(strSeparators, offSep, 1)) 600 if offEnd2 > 0 and offEnd2 < offEnd then offEnd = offEnd2 601 next 602 603 StrGetFirstWord = Mid(str, offWord, offEnd - offWord) 604 end function 605 606 607 '' 608 ' Checks if the string starts with the given prefix (case sensitive). 609 function StrStartsWith(str, strPrefix) 610 if len(str) >= Len(strPrefix) then 611 StrStartsWith = (StrComp(Left(str, Len(strPrefix)), strPrefix, vbBinaryCompare) = 0) 612 else 613 StrStartsWith = false 614 end if 615 end function 616 617 618 '' 619 ' Checks if the string starts with the given prefix, case insenstive edition. 620 function StrStartsWithI(str, strPrefix) 621 if len(str) >= Len(strPrefix) then 622 StrStartsWithI = (StrComp(Left(str, Len(strPrefix)), strPrefix, vbTextCompare) = 0) 623 else 624 StrStartsWithI = false 625 end if 626 end function 627 628 568 629 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 569 630 ' Helpers: Arrays ' … … 1051 1112 if CharIsDigit(Mid(str, i, 1)) <> False then MsgFatal "SelfTest failed: CharIsDigit("&Mid(str, i, 1)&")" 1052 1113 next 1114 1053 1115 if StrVersionCompare("1234", "1234") <> 0 then MsgFatal "SelfTest failed: StrVersionCompare #1" 1054 1116 if StrVersionCompare("1", "1") <> 0 then MsgFatal "SelfTest failed: StrVersionCompare #2" … … 1064 1126 if StrVersionCompare("v1.2.4", "v1.23.4") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #12" 1065 1127 if StrVersionCompare("v10.0.17163", "v10.00.18363") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #13" 1066 end sub 1067 1128 if StrVersionCompare("n 2.15.0", "2.12.0") <= 0 then MsgFatal "SelfTest failed: StrVersionCompare #14" 1129 1130 if StrGetFirstWord("1") <> "1" then MsgFatal "SelfTest: StrGetFirstWord #1" 1131 if StrGetFirstWord(" 1 ") <> "1" then MsgFatal "SelfTest: StrGetFirstWord #2" 1132 if StrGetFirstWord(" 1 2 ") <> "1" then MsgFatal "SelfTest: StrGetFirstWord #3" 1133 if StrGetFirstWord("1 2") <> "1" then MsgFatal "SelfTest: StrGetFirstWord #4" 1134 if StrGetFirstWord("1234 5") <> "1234" then MsgFatal "SelfTest: StrGetFirstWord #5" 1135 if StrGetFirstWord(" ") <> "" then MsgFatal "SelfTest: StrGetFirstWord #6" 1136 end sub 1137
Note:
See TracChangeset
for help on using the changeset viewer.