VirtualBox

Changeset 85823 in vbox


Ignore:
Timestamp:
Aug 18, 2020 3:57:43 PM (4 years ago)
Author:
vboxsync
Message:

configure.vbs,helpers.vbs: Check the YASN, NASM and OpenWatcom versions. Added StrGetFirstLine, StrGetFirstWord, StrStartsWidth and StrStartsWithI to the helpers.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.vbs

    r85814 r85823  
    394394' Generic helper for looking for a tools under g_strPathDev.
    395395'
    396 ' The callback function takes the '.../tools/win.arch/tool/version' dir as
    397 ' argument and returns an 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'
     399function SearchToolsEx(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser, ByRef arrToolsDirs)
    400400   dim strToolsDir, arrDirs, strDir
    401401   SearchToolsEx = ""
     
    403403      arrDirs = GetSubdirsStartingWithRVerSorted(strToolsDir, strVerPrefix)
    404404      for each strDir in arrDirs
    405          SearchToolsEx = fnCallback(strToolsDir & "/" & strDir)
     405         SearchToolsEx = fnCallback(strToolsDir & "/" & strDir, varUser)
    406406         if SearchToolsEx <> "" then
    407407            exit function
     
    412412
    413413'' Search under g_strPathDev for a tool, target arch first.
    414 function SearchTargetTools(strTool, strVerPrefix, ByRef fnCallback)
    415    SearchTargetTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, _
     414function SearchTargetTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser)
     415   SearchTargetTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, _
    416416                                     Array(g_strPathDev & "/win." & g_strTargetArch & "/" & strTool, _
    417417                                           g_strPathDev & "/win.x86/" & strTool, _
     
    420420
    421421'' Search under g_strPathDev for a tool, host arch first.
    422 function SearchHostTools(strTool, strVerPrefix, ByRef fnCallback)
    423    SearchHostTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, _
     422function SearchHostTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser)
     423   SearchHostTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, _
    424424                                   Array(g_strPathDev & "/win." & g_strHostArch & "/" & strTool, _
    425425                                         g_strPathDev & "/win.x86/" & strTool, _
     
    428428
    429429'' Search under g_strPathDev for a tool, common dir first.
    430 function SearchCommonTools(strTool, strVerPrefix, ByRef fnCallback)
    431    SearchCommonTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, _
     430function SearchCommonTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser)
     431   SearchCommonTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, _
    432432                                     Array(g_strPathDev & "/common/" & strTool, _
    433433                                           g_strPathDev & "/win." & g_strHostArch & "/" & strTool, _
     
    13451345'
    13461346sub CheckForYasm(strOptYasm)
    1347    dim strPathYasm
     1347   dim strPathYasm, strVersion
    13481348   PrintHdr "yasm"
    13491349
    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
    13551360
    13561361   if strPathYasm = "" then
     
    13591364   else
    13601365      CfgPrintAssign "PATH_TOOL_YASM", strPathYasm
    1361       PrintResult "yasm", strPathYasm
    1362    end if
    1363 end sub
    1364 
    1365 function CheckForYasmSub(strPathYasm)
     1366      PrintResult "yasm v" & strVersion, strPathYasm
     1367   end if
     1368end sub
     1369
     1370function CheckForYasmSub(strPathYasm, ByRef strVersion)
    13661371   CheckForYasmSub = ""
    13671372   if strPathYasm <> "" then
    13681373      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
    13701390      end if
    13711391   end if
     
    13771397'
    13781398sub CheckForNasm(strOptNasm)
    1379    dim strPathNasm
     1399   dim strPathNasm, strVersion
    13801400   PrintHdr "nasm"
    13811401
    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)
    13871409   if strPathNasm = "" then
    13881410      for each strCandidate in CollectFromProgramItemLinks(GetRef("NasmProgramItemCallback"), strPathNasm)
    1389          strPathNasm = CheckForNasmSub(strCandidate)
     1411         strPathNasm = CheckForNasmSub(strCandidate, strVersion)
    13901412      next
    13911413   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
    13941418
    13951419   if strPathNasm = "" then
     
    13971421   else
    13981422      CfgPrintAssign "PATH_TOOL_NASM", strPathNasm
    1399       PrintResult "nasm", strPathNasm
     1423      PrintResult "nasm v" & strVersion, strPathNasm
    14001424   end if
    14011425end sub
     
    14131437end function
    14141438
    1415 function CheckForNasmSub(strPathNasm)
     1439function CheckForNasmSub(strPathNasm, ByRef strVersion)
    14161440   CheckForNasmSub = ""
    14171441   if strPathNasm <> "" then
    14181442      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
    14201459      end if
    14211460   end if
     
    14271466'
    14281467sub CheckForOpenWatcom(strOptOpenWatcom)
    1429    dim strPathOW, strCandidate
     1468   dim strPathOW, strCandidate, strVersion
    14301469   PrintHdr "OpenWatcom"
    14311470
    1432    strPathOW = CheckForOpenWatcomSub(strOptOpenWatcom)
     1471   strPathOW = CheckForOpenWatcomSub(strOptOpenWatcom, strVersion)
    14331472   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
    14381475   if strPathOW = "" then
    14391476      for each strCandidate in CollectFromProgramItemLinks(GetRef("OpenWatcomProgramItemCallback"), strPathOW)
    1440          if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(strCandidate)
     1477         if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(strCandidate, strVersion)
    14411478      next
    14421479   end if
     1480   if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(EnvGet("WATCOM"), strVersion)
     1481   if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(PathParent(PathStripFilename(Which("wcc386.exe"))), strVersion)
    14431482   if strPathOW = "" and g_blnInternalFirst = false then
    1444       strPathOW = SearchCommonTools("openwatcom", "v", GetRef("CheckForOpenWatcomSub"))
     1483      strPathOW = SearchCommonTools("openwatcom", "v", GetRef("CheckForOpenWatcomSub"), strVersion)
    14451484   end if
    14461485
     
    14531492   CfgPrintAssign "VBOX_WITH_OPEN_WATCOM", "1"
    14541493   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
    14561498end sub
    14571499
     
    14681510end function
    14691511
    1470 function CheckForOpenWatcomSub(strPathOW)
     1512function CheckForOpenWatcomSub(strPathOW, ByRef strVersion)
    14711513   CheckForOpenWatcomSub = ""
    14721514   if strPathOW <> "" then
     
    14851527          and LogFileExists(strPathOW, "h/stdarg.h") _
    14861528         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
    14891546         end if
    14901547      end if
  • trunk/tools/win/vbscript/helpers.vbs

    r85814 r85823  
    566566
    567567
     568''
     569' Returns the first list of the given string.
     570function 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
     579end 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'
     587function 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)
     604end function
     605
     606
     607''
     608' Checks if the string starts with the given prefix (case sensitive).
     609function 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
     615end function
     616
     617
     618''
     619' Checks if the string starts with the given prefix, case insenstive edition.
     620function 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
     626end function
     627
     628
    568629''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    569630'  Helpers: Arrays                                                                                                               '
     
    10511112      if CharIsDigit(Mid(str, i, 1)) <> False then MsgFatal "SelfTest failed: CharIsDigit("&Mid(str, i, 1)&")"
    10521113   next
     1114
    10531115   if StrVersionCompare("1234", "1234") <> 0 then MsgFatal "SelfTest failed: StrVersionCompare #1"
    10541116   if StrVersionCompare("1", "1") <> 0 then MsgFatal "SelfTest failed: StrVersionCompare #2"
     
    10641126   if StrVersionCompare("v1.2.4", "v1.23.4") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #12"
    10651127   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"
     1136end sub
     1137
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette