VirtualBox

Changeset 85824 in vbox


Ignore:
Timestamp:
Aug 18, 2020 9:24:38 PM (4 years ago)
Author:
vboxsync
Message:

configure.vbs,helpers.vbs: Added options for appending & prepending extra 'tools' and 'Program Files' directories to search for tools and libs, extending and adjusting checker functions accordingly. Added ArrayFindString[I], ArrayPrepend, ArrayRemove and ArrayToString. Reworte ArrayAppend to work ByRef.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.vbs

    r85823 r85824  
    5353
    5454' kBuild stuff.
    55 dim g_strPathkBuild, g_strPathkBuildBin, g_strPathDev
     55dim g_strPathkBuild, g_strPathkBuildBin, g_strPathDev, g_arrPathDev
    5656g_strPathkBuild = ""
    5757g_strPathkBuildBin = ""
    5858g_strPathDev = ""
     59g_arrPathDev = Array(":placeholder:")
    5960
    6061dim g_strTargetArch, g_StrTargetArchWin
     
    411412end function
    412413
    413 '' Search under g_strPathDev for a tool, target arch first.
     414'' Search under g_strPathDev for a tool, target arch only.
    414415function SearchTargetTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser)
    415    SearchTargetTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, _
    416                                      Array(g_strPathDev & "/win." & g_strTargetArch & "/" & strTool, _
    417                                            g_strPathDev & "/win.x86/" & strTool, _
    418                                            g_strPathDev & "/win.amd64/" & strTool))
     416   dim i
     417   redim arrToolsDirs(ArraySize(g_arrPathDev) - 1)
     418   for i = 0 to UBound(g_arrPathDev)
     419      arrToolsDirs(i) = g_arrPathDev(i) & "/win." & g_strTargetArch & "/" & strTool
     420   next
     421   SearchTargetTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, arrToolsDirs)
     422end function
     423
     424'' Search under g_strPathDev for a tool, target arch and alternative arches.
     425function SearchTargetPlusTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser)
     426   dim i
     427   redim arrToolsDirs(ArraySize(g_arrPathDev)*3 - 1)
     428   for i = 0 to UBound(g_arrPathDev)
     429      arrToolsDirs(i*3 + 0) = g_arrPathDev(i) & "/win." & g_strTargetArch & "/" & strTool
     430      arrToolsDirs(i*3 + 1) = g_arrPathDev(i) & "/win.x86/" & strTool
     431      arrToolsDirs(i*3 + 2) = g_arrPathDev(i) & "/win.amd64/" & strTool
     432   next
     433   SearchTargetPlusTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, arrToolsDirs)
    419434end function
    420435
    421436'' Search under g_strPathDev for a tool, host arch first.
    422437function SearchHostTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser)
    423    SearchHostTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, _
    424                                    Array(g_strPathDev & "/win." & g_strHostArch & "/" & strTool, _
    425                                          g_strPathDev & "/win.x86/" & strTool, _
    426                                          g_strPathDev & "/win.amd64/" & strTool))
     438   dim i
     439   redim arrToolsDirs(ArraySize(g_arrPathDev) * 3 - 1)
     440   for i = 0 to UBound(g_arrPathDev)
     441      arrToolsDirs(i*3 + 0) = g_arrPathDev(i) & "/win." & g_strHostArch & "/" & strTool
     442      arrToolsDirs(i*3 + 1) = g_arrPathDev(i) & "/win.x86/" & strTool
     443      arrToolsDirs(i*3 + 2) = g_arrPathDev(i) & "/win.amd64/" & strTool
     444   next
     445   SearchHostTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, arrToolsDirs)
    427446end function
    428447
    429448'' Search under g_strPathDev for a tool, common dir first.
    430449function SearchCommonTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser)
    431    SearchCommonTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, _
    432                                      Array(g_strPathDev & "/common/" & strTool, _
    433                                            g_strPathDev & "/win." & g_strHostArch & "/" & strTool, _
    434                                            g_strPathDev & "/win.x86/" & strTool, _
    435                                            g_strPathDev & "/win.amd64/" & strTool))
     450   dim i
     451   redim arrToolsDirs(ArraySize(g_arrPathDev) * 4 - 1)
     452   for i = 0 to UBound(g_arrPathDev)
     453      arrToolsDirs(i*4 + 0) = g_arrPathDev(i) & "/win.common/" & strTool
     454      arrToolsDirs(i*4 + 1) = g_arrPathDev(i) & "/win." & g_strTargetArch & "/" & strTool
     455      arrToolsDirs(i*4 + 2) = g_arrPathDev(i) & "/win.x86/" & strTool
     456      arrToolsDirs(i*4 + 3) = g_arrPathDev(i) & "/win.amd64/" & strTool
     457   next
     458   SearchCommonTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, arrToolsDirs)
    436459end function
    437460
     
    661684      end if
    662685   end if
     686   g_arrPathDev(ArrayFindString(g_arrPathDev, ":placeholder:")) = g_strPathDev
    663687
    664688   '
     
    950974
    951975   public function checkInternal
    952       check g_strPathDev & "/win.amd64/vcc/v14.2",  ""
    953       check g_strPathDev & "/win.amd64/vcc/v14.1",  ""
    954       check g_strPathDev & "/win.amd64/vcc/v14.0",  ""
    955       check g_strPathDev & "/win.amd64/vcc/v10sp1", ""
    956       check g_strPathDev & "/win.x86/vcc/v10sp1",   ""
     976      dim strPathDev
     977      for each strPathDev in g_arrPathDev : check strPathDev & "/win.amd64/vcc/v14.2",  "" : next
     978      for each strPathDev in g_arrPathDev : check strPathDev & "/win.amd64/vcc/v14.2",  "" : next
     979      for each strPathDev in g_arrPathDev : check strPathDev & "/win.amd64/vcc/v14.1",  "" : next
     980      for each strPathDev in g_arrPathDev : check strPathDev & "/win.amd64/vcc/v14.0",  "" : next
     981      for each strPathDev in g_arrPathDev : check strPathDev & "/win.amd64/vcc/v10sp1", "" : next
     982      for each strPathDev in g_arrPathDev : check strPathDev & "/win.x86/vcc/v10sp1",   "" : next
    957983      checkInternal = m_blnFound
    958984   end function
     
    9851011'
    9861012sub CheckForPlatformSDK(strOptSDK)
    987    dim strPathPSDK, str
     1013   dim strPathPSDK, strVersion, strSubKey, str, strHkey
    9881014   PrintHdr "Windows Platform SDK (recent)"
    9891015
    990    strPathPSDK = ""
     1016   '
     1017   ' Search for it.
     1018   '
    9911019
    9921020   ' Check the supplied argument first.
    993    str = strOptSDK
    994    if str <> "" then
    995       if CheckForPlatformSDKSub(str) then strPathPSDK = str
    996    end if
     1021   strPathPSDK = CheckForPlatformSDKSub(strOptSDK, strVersion)
    9971022
    9981023   ' The tools location (first).
    999    if strPathPSDK = "" And g_blnInternalFirst then
    1000       str = g_strPathDev & "/win.x86/sdk/v7.1"
    1001       if CheckForPlatformSDKSub(str) then strPathPSDK = str
    1002    end if
    1003 
    1004    if strPathPSDK = "" And g_blnInternalFirst then
    1005       str = g_strPathDev & "/win.x86/sdk/v8.0"
    1006       if CheckForPlatformSDKSub(str) then strPathPSDK = str
    1007    end if
     1024   if strPathPSDK = "" and g_blnInternalFirst = true then strPathPSDK = SearchTargetPlusTools("sdk", "v7.1", GetRef("CheckForPlatformSDKSub"), strVersion)
     1025   if strPathPSDK = "" and g_blnInternalFirst = true then strPathPSDK = SearchTargetPlusTools("sdk", "v8.0", GetRef("CheckForPlatformSDKSub"), strVersion)
    10081026
    10091027   ' Look for it in the environment
    1010    str = EnvGet("MSSdk")
    1011    if strPathPSDK = "" And str <> "" then
    1012       if CheckForPlatformSDKSub(str) then strPathPSDK = str
    1013    end if
    1014 
    1015    str = EnvGet("Mstools")
    1016    if strPathPSDK = "" And str <> "" then
    1017       if CheckForPlatformSDKSub(str) then strPathPSDK = str
    1018    end if
     1028   if strPathPSDK = "" then  strPathPSDK = CheckForPlatformSDKSub(EnvGet("MSSdk"), strVersion)
     1029   if strPathPSDK = "" then  strPathPSDK = CheckForPlatformSDKSub(EnvGet("Mstools"), strVersion)
    10191030
    10201031   ' Check if there is one installed with the compiler.
    1021    if strPathPSDK = "" And str <> "" then
    1022       str = g_strPathVCC & "/PlatformSDK"
    1023       if CheckForPlatformSDKSub(str) then strPathPSDK = str
    1024    end if
     1032   if strPathPSDK = "" then  strPathPSDK = CheckForPlatformSDKSub(g_strPathVCC & "/PlatformSDK", strVersion)
    10251033
    10261034   ' Check the registry next (ASSUMES sorting).
    1027    arrSubKeys = RegEnumSubKeysRVerSorted("HKLM", "SOFTWARE\Microsoft\Microsoft SDKs\Windows")
    1028    for each strSubKey in arrSubKeys
    1029       str = LogRegGetString("HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")
    1030       if strPathPSDK = "" And str <> "" then
    1031          if CheckForPlatformSDKSub(str) then strPathPSDK = str
    1032       end if
    1033    Next
    1034    arrSubKeys = RegEnumSubKeysRVerSorted("HKCU", "SOFTWARE\Microsoft\Microsoft SDKs\Windows")
    1035    for each strSubKey in arrSubKeys
    1036       str = LogRegGetString("HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")
    1037       if strPathPSDK = "" And str <> "" then
    1038          if CheckForPlatformSDKSub(str) then strPathPSDK = str
    1039       end if
    1040    Next
     1035   if strPathPSDK = "" then
     1036      for each strHkey in Array("HKLM", "HKCU")
     1037         for each strSubKey in RegEnumSubKeysRVerSorted(strHkey, "SOFTWARE\Microsoft\Microsoft SDKs\Windows")
     1038            str = LogRegGetString(strHkey & "\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")
     1039            strPathPSDK = CheckForPlatformSDKSub(str, strVersion)
     1040            if strPathPSDK <> "" then exit for
     1041         next
     1042         if strPathPSDK <> "" then exit for
     1043      next
     1044   end if
    10411045
    10421046   ' The tools location (post).
    1043    if (strPathPSDK = "") And (g_blnInternalFirst = False) then
    1044       str = g_strPathDev & "/win.x86/sdk/v7.1"
    1045       if CheckForPlatformSDKSub(str) then strPathPSDK = str
    1046    end if
    1047 
    1048    if (strPathPSDK = "") And (g_blnInternalFirst = False) then
    1049       str = g_strPathDev & "/win.x86/sdk/v8.0"
    1050       if CheckForPlatformSDKSub(str) then strPathPSDK = str
    1051    end if
     1047   if strPathPSDK = "" and g_blnInternalFirst = false then strPathPSDK = SearchTargetPlusTools("sdk", "v7.1", GetRef("CheckForPlatformSDKSub"), strVersion)
     1048   if strPathPSDK = "" and g_blnInternalFirst = false then strPathPSDK = SearchTargetPlusTools("sdk", "v8.0", GetRef("CheckForPlatformSDKSub"), strVersion)
    10521049
    10531050   ' Give up.
     
    10611058   '
    10621059   strPathPSDK = UnixSlashes(PathAbs(strPathPSDK))
    1063    CfgPrintAssign "PATH_SDK_WINPSDK" & g_strVerPSDK, strPathPSDK
    1064    CfgPrintAssign "VBOX_WINPSDK",  "WINPSDK" & g_strVerPSDK
     1060   CfgPrintAssign "PATH_SDK_WINPSDK" & strVersion, strPathPSDK
     1061   CfgPrintAssign "VBOX_WINPSDK",  "WINPSDK" & strVersion
    10651062
    10661063   PrintResult "Windows Platform SDK", strPathPSDK
    1067    PrintResultMsg "Windows Platform SDK version", g_strVerPSDK
     1064   PrintResultMsg "Windows Platform SDK version", strVersion
     1065   g_strVerPSDK  = strVersion
    10681066   g_strPathPSDK = strPathPSDK
    10691067end sub
    10701068
    10711069'' Checks if the specified path points to a usable PSDK.
    1072 function CheckForPlatformSDKSub(strPathPSDK)
     1070function CheckForPlatformSDKSub(strPathPSDK, ByRef strVersion)
    10731071   dim strOutput
    1074    CheckForPlatformSDKSub = False
    1075    LogPrint "trying: strPathPSDK=" & strPathPSDK
    1076    if    LogFileExists(strPathPSDK, "include/Windows.h") _
    1077     And  LogFileExists(strPathPSDK, "lib/Kernel32.Lib") _
    1078     And  LogFileExists(strPathPSDK, "lib/User32.Lib") _
    1079     And  LogFileExists(strPathPSDK, "bin/rc.exe") _
    1080     And  Shell("""" & DosSlashes(strPathPSDK & "/bin/rc.exe") & """" , True, strOutput) <> 0 _
     1072   CheckForPlatformSDKSub = ""
     1073   if strPathPSDK <> "" then
     1074      LogPrint "Trying: strPathPSDK=" & strPathPSDK
     1075      if   LogFileExists(strPathPSDK, "include/Windows.h") _
     1076       and LogFileExists(strPathPSDK, "lib/Kernel32.Lib") _
     1077       and LogFileExists(strPathPSDK, "lib/User32.Lib") _
     1078       and LogFileExists(strPathPSDK, "bin/rc.exe") _
     1079       and Shell("""" & DosSlashes(strPathPSDK & "/bin/rc.exe") & """" , True, strOutput) <> 0 _
    10811080      then
    1082       if InStr(1, strOutput, "Resource Compiler Version 6.2.") > 0 then
    1083          g_strVerPSDK = "80"
    1084          CheckForPlatformSDKSub = True
    1085       elseif InStr(1, strOutput, "Resource Compiler Version 6.1.") > 0 then
    1086          g_strVerPSDK = "71"
    1087          CheckForPlatformSDKSub = True
     1081         if InStr(1, strOutput, "Resource Compiler Version 6.2.") > 0 then
     1082            strVersion = "80"
     1083            CheckForPlatformSDKSub = UnixSlashes(PathAbs(strPathPSDK))
     1084         elseif InStr(1, strOutput, "Resource Compiler Version 6.1.") > 0 then
     1085            strVersion = "71"
     1086            CheckForPlatformSDKSub = UnixSlashes(PathAbs(strPathPSDK))
     1087         end if
    10881088      end if
    10891089   end if
     
    11041104   strSDK10Version = ""
    11051105   strPathSDK10 = CheckForSDK10Sub(strOptSDK10, strSDK10Version)
    1106    if strPathSDK10 = "" and g_blnInternalFirst = True  then strPathSDK10 = CheckForSDK10ToolsSub(strSDK10Version)
     1106   if strPathSDK10 = "" and g_blnInternalFirst = true then
     1107      strPathSDK10 = SearchTargetPlusTools("sdk", "v10.", GetRef("CheckForSDK10Sub"), strSDK10Version)
     1108   end if
     1109
    11071110   if strPathSDK10 = "" then
    11081111      str = LogRegGetString("HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots\KitsRoot10")
     
    11151118      next
    11161119   end if
    1117    if strPathSDK10 = "" and g_blnInternalFirst = False then strPathSDK10 = CheckForSDK10ToolsSub()
     1120   if strPathSDK10 = "" and g_blnInternalFirst = true then
     1121      strPathSDK10 = SearchTargetPlusTools("sdk", "v10.", GetRef("CheckForSDK10Sub"), strSDK10Version)
     1122   end if
    11181123
    11191124   if strPathSDK10 = "" then
     
    11331138   g_strPathSDK10 = strPathSDK10
    11341139end sub
    1135 
    1136 '' Checks the tools directory.
    1137 function CheckForSDK10ToolsSub(ByRef strSDK10Version)
    1138    dim arrToolsDirs, strToolsDir, arrDirs, strDir
    1139    CheckForSDK10ToolSub = ""
    1140    arrToolsDirs = Array(g_strPathDev & "/win." & g_strTargetArch & "/sdk", _
    1141                         g_strPathDev & "/win.x86/sdk", g_strPathDev & "/win.amd64/sdk")
    1142    for each strToolsDir in arrToolsDirs
    1143       arrDirs = GetSubdirsStartingWithRVerSorted(strToolsDir, "v10.")
    1144       for each strDir in arrDirs
    1145          CheckForSDK10ToolsSub = CheckForSDK10Sub(strToolsDir & "/" & strDir, strSDK10Version)
    1146          if CheckForSDK10ToolsSub <> "" then
    1147             exit function
    1148          end if
    1149       next
    1150    next
    1151 end function
    11521140
    11531141'' Checks if the specified path points to a usable Windows 10 SDK/WDK.
     
    12051193   ' Find the DDK.
    12061194   '
    1207    strPathDDK = ""
    1208    ' The specified path.
    1209    if strPathDDK = "" And strOptDDK <> "" then
    1210       if CheckForWinDDKSub(strOptDDK, True) then strPathDDK = strOptDDK
    1211    end if
     1195   strPathDDK = CheckForWinDDKSub(strOptDDK, True)
    12121196
    12131197   ' The tools location (first).
    1214    if strPathDDK = "" And g_blnInternalFirst then
    1215       str = g_strPathDev & "/win.x86/ddk/7600.16385.1"
    1216       if CheckForWinDDKSub(str, False) then strPathDDK = str
     1198   if strPathDDK = "" and g_blnInternalFirst = true then
     1199      for each str in g_arrPathDev
     1200         strPathDDK = CheckForWinDDKSub(str & "/win.x86/ddk/7600.16385.1", False)
     1201         if strPathDDK <> "" then exit for
     1202      next
    12171203   end if
    12181204
    12191205   ' Check the environment
    1220    str = EnvGet("DDK_INC_PATH")
    1221    if strPathDDK = "" And str <> "" then
    1222       str = PathParent(PathParent(str))
    1223       if CheckForWinDDKSub(str, True) then strPathDDK = str
    1224    end if
    1225 
    1226    str = EnvGet("BASEDIR")
    1227    if strPathDDK = "" And str <> "" then
    1228       if CheckForWinDDKSub(str, True) then strPathDDK = str
    1229    end if
     1206   if strPathDDK = "" then strPathDDK = CheckForWinDDKSub(PathParent(PathParent(EnvGet("DDK_INC_PATH"))), True)
     1207   if strPathDDK = "" then strPathDDK = CheckForWinDDKSub(EnvGet("BASEDIR"), True)
    12301208
    12311209   ' Some array constants to ease the work.
     
    12341212
    12351213   ' Windows 7 WDK.
    1236    arrLocations = array()
    1237    for each strSoftwareKey in arrSoftwareKeys
    1238       for each strSubKey in RegEnumSubKeysFull("HKLM", strSoftwareKey & "\Microsoft\KitSetup\configured-kits")
    1239          for each strSubKey2 in RegEnumSubKeysFull("HKLM", strSubKey)
    1240             str = LogRegGetString("HKLM\" & strSubKey2 & "\setup-install-location")
    1241             if str <> "" then
    1242                arrLocations = ArrayAppend(arrLocations, PathAbsLong(str))
    1243             end if
     1214   if strPathDDK = "" then
     1215      arrLocations = array()
     1216      for each strSoftwareKey in arrSoftwareKeys
     1217         for each strSubKey in RegEnumSubKeysFull("HKLM", strSoftwareKey & "\Microsoft\KitSetup\configured-kits")
     1218            for each strSubKey2 in RegEnumSubKeysFull("HKLM", strSubKey)
     1219               str = LogRegGetString("HKLM\" & strSubKey2 & "\setup-install-location")
     1220               if str <> "" then
     1221                  arrLocations = ArrayAppend(arrLocations, PathAbsLong(str))
     1222               end if
     1223            next
    12441224         next
    12451225      next
    1246    next
    1247    arrLocations = ArrayRVerSortStrings(arrLocations)
    1248 
    1249    ' Check the locations we've gathered.
    1250    for each str in arrLocations
    1251       if strPathDDK = "" then
    1252          if CheckForWinDDKSub(str, True) then strPathDDK = str
    1253       end if
    1254    next
     1226      arrLocations = ArrayRVerSortStrings(arrLocations)
     1227
     1228      ' Check the locations we've gathered.
     1229      for each str in arrLocations
     1230         strPathDDK = CheckForWinDDKSub(str, True)
     1231         if strPathDDK <> "" then exit for
     1232      next
     1233   end if
    12551234
    12561235   ' The tools location (post).
    1257    if (strPathDDK = "") And (g_blnInternalFirst = False) then
    1258       str = g_strPathDev & "/win.x86/ddk/7600.16385.1"
    1259       if CheckForWinDDKSub(str, False) then strPathDDK = str
     1236   if strPathDDK = "" and g_blnInternalFirst = false then
     1237      for each str in g_arrPathDev
     1238         strPathDDK = CheckForWinDDKSub(str & "/win.x86/ddk/7600.16385.1", False)
     1239         if strPathDDK <> "" then exit for
     1240      next
    12601241   end if
    12611242
     
    12781259'' Quick check if the DDK is in the specified directory or not.
    12791260function CheckForWinDDKSub(strPathDDK, blnCheckBuild)
    1280    dim strOutput
    1281    CheckForWinDDKSub = False
    1282    LogPrint "trying: strPathDDK=" & strPathDDK & " blnCheckBuild=" & blnCheckBuild
    1283    if   LogFileExists(strPathDDK, "inc/api/ntdef.h") _
    1284     And LogFileExists(strPathDDK, "lib/win7/i386/int64.lib") _
    1285     And LogFileExists(strPathDDK, "lib/wlh/i386/int64.lib") _
    1286     And LogFileExists(strPathDDK, "lib/wnet/i386/int64.lib") _
    1287     And LogFileExists(strPathDDK, "lib/wxp/i386/int64.lib") _
    1288     And Not LogFileExists(strPathDDK, "lib/win8/i386/int64.lib") _
    1289     And LogFileExists(strPathDDK, "bin/x86/rc.exe") _
    1290       then
    1291       if Not blnCheckBuild then
    1292          CheckForWinDDKSub = True
    1293       '' @todo Find better build check.
    1294       elseif Shell("""" & DosSlashes(strPathDDK & "/bin/x86/rc.exe") & """" , True, strOutput) <> 0 _
    1295          And InStr(1, strOutput, "Resource Compiler Version 6.1.") > 0 then
    1296          CheckForWinDDKSub = True
     1261   CheckForWinDDKSub = ""
     1262   if strPathDDK <> "" then
     1263      dim strOutput
     1264      LogPrint "Trying: strPathDDK=" & strPathDDK & " blnCheckBuild=" & blnCheckBuild
     1265      if   LogFileExists(strPathDDK, "inc/api/ntdef.h") _
     1266       And LogFileExists(strPathDDK, "lib/win7/i386/int64.lib") _
     1267       And LogFileExists(strPathDDK, "lib/wlh/i386/int64.lib") _
     1268       And LogFileExists(strPathDDK, "lib/wnet/i386/int64.lib") _
     1269       And LogFileExists(strPathDDK, "lib/wxp/i386/int64.lib") _
     1270       And Not LogFileExists(strPathDDK, "lib/win8/i386/int64.lib") _
     1271       And LogFileExists(strPathDDK, "bin/x86/rc.exe") _
     1272         then
     1273         if Not blnCheckBuild then
     1274            CheckForWinDDKSub = strPathDDK
     1275         '' @todo Find better build check.
     1276         elseif Shell("""" & DosSlashes(strPathDDK & "/bin/x86/rc.exe") & """" , True, strOutput) <> 0 _
     1277            and InStr(1, strOutput, "Resource Compiler Version 6.1.") > 0 _
     1278         then
     1279            CheckForWinDDKSub = strPathDDK
     1280         end if
    12971281      end if
    12981282   end if
     
    13041288'
    13051289sub CheckForMidl(strOptMidl)
    1306    dim strMidl
     1290   dim strMidl, str
    13071291   PrintHdr "Midl.exe"
    13081292
     
    13211305   if strMidl = "" then strMidl = CheckForMidlSub(g_strPathDDK   & "/bin/x86/Midl.exe")
    13221306   if strMidl = "" then strMidl = CheckForMidlSub(g_strPathDDK   & "/bin/Midl.exe")
    1323    if strMidl = "" then strMidl = CheckForMidlSub(g_strPathDev   & "/win.x86/bin/Midl.exe")
     1307   if strMidl = "" then
     1308      for each str in g_arrPathDev
     1309         strMidl = CheckForMidlSub(str & "/win." & g_strHostArchWin & "/bin/Midl.exe")
     1310         if strMidl <> "" then exit for
     1311         strMidl = CheckForMidlSub(str & "/win.x86/bin/Midl.exe")
     1312         if strMidl <> "" then exit for
     1313      next
     1314   end if
    13241315
    13251316   if strMidl = "" then
     
    15541545'
    15551546sub CheckForlibSDL(strOptlibSDL)
    1556    dim strPathlibSDL, str
     1547   dim strPathLibSDL, strVersion
    15571548   PrintHdr "libSDL"
    15581549
     
    15601551   ' Try find some SDL library.
    15611552   '
    1562 
    1563    ' First, the specific location.
    1564    strPathlibSDL = ""
    1565    if (strPathlibSDL = "") And (strOptlibSDL <> "") then
    1566       if CheckForlibSDLSub(strOptlibSDL) then strPathlibSDL = strOptlibSDL
    1567    end if
    1568 
    1569    ' The tools location (first).
    1570    if (strPathlibSDL = "") And (g_blnInternalFirst = True) then
    1571       str = g_strPathDev & "/win." & g_strTargetArch & "/libsdl"
    1572       if HasSubdirsStartingWith(str, "v") then
    1573          PrintResult "libSDL", str & "/v* (auto)"
    1574          exit sub
    1575       end if
    1576    end if
    1577 
    1578    ' Poke about in the path.
    1579    if strPathlibSDL = "" then
    1580       str = WhichEx("LIB", "SDLmain.lib")
    1581       if str = "" then str = Which("..\lib\SDLmain.lib")
    1582       if str = "" then str = Which("SDLmain.lib")
    1583       if str <> "" then
    1584          str = PathParent(PathStripFilename(str))
    1585          if CheckForlibSDLSub(str) then strPathlibSDL = str
    1586       end if
    1587    end if
    1588 
    1589    if strPathlibSDL = "" then
    1590       str = Which("SDL.dll")
    1591       if str <> "" then
    1592          str = PathParent(PathStripFilename(str))
    1593          if CheckForlibSDLSub(str) then strPathlibSDL = str
    1594       end if
    1595    end if
    1596 
    1597    ' The tools location (post).
    1598    if (strPathlibSDL = "") And (g_blnInternalFirst = False) then
    1599       str = g_strPathDev & "/win." & g_strTargetArch & "/libsdl"
    1600       if HasSubdirsStartingWith(str, "v") then
    1601          PrintResult "libSDL", str & "/v* (auto)"
    1602          exit sub
    1603       end if
     1553   strPathLibSDL = CheckForLibSDLSub(strOptlibSDL, strVersion)
     1554   if strPathlibSDL = "" and g_blnInternalFirst = true then
     1555      strPathLibSDL = SearchTargetTools("libsdl", "v", GetRef("CheckForLibSDLSub"), strVersion)
     1556   end if
     1557
     1558   ' Poke about in the LIB and PATH env.vars.
     1559   if strPathlibSDL = "" then strPathLibSDL = CheckForlibSDLSub(PathParent(PathStripFilename(WhichEx("LIB", "SDLmain.lib"))), strVersion)
     1560   if strPathlibSDL = "" then strPathLibSDL = CheckForlibSDLSub(PathParent(PathStripFilename(Which("..\lib\SDLmain.lib"))), strVersion)
     1561   if strPathlibSDL = "" then strPathLibSDL = CheckForlibSDLSub(PathParent(PathStripFilename(Which("SDLmain.lib"))), strVersion)
     1562   if strPathlibSDL = "" then strPathLibSDL = CheckForlibSDLSub(PathParent(PathStripFilename(Which("SDL.dll"))), strVersion)
     1563
     1564   ' The tools again.
     1565   if strPathlibSDL = "" and g_blnInternalFirst = false then
     1566      strPathLibSDL = SearchTargetTools("libsdl", "v", GetRef("CheckForLibSDLSub"), strVersion)
    16041567   end if
    16051568
     
    16221585
    16231586'' Checks if the specified path points to an usable libSDL or not.
    1624 function CheckForlibSDLSub(strPathlibSDL)
    1625    CheckForlibSDLSub = False
    1626    LogPrint "trying: strPathlibSDL=" & strPathlibSDL
    1627    if   LogFileExists(strPathlibSDL, "lib/SDL.lib") _
    1628     And LogFileExists(strPathlibSDL, "lib/SDLmain.lib") _
    1629     And LogFileExists(strPathlibSDL, "lib/SDL.dll") _
    1630     And LogFileExists(strPathlibSDL, "include/SDL.h") _
    1631     And LogFileExists(strPathlibSDL, "include/SDL_syswm.h") _
    1632     And LogFileExists(strPathlibSDL, "include/SDL_version.h") _
     1587function CheckForLibSDLSub(strPathlibSDL, strVersion)
     1588   CheckForlibSDLSub = ""
     1589   if strPathLibSDL <> "" then
     1590      LogPrint "Trying: strPathLibSDL=" & strPathLibSDL
     1591      if   LogFileExists(strPathLibSDL, "lib/SDL.lib") _
     1592       and LogFileExists(strPathLibSDL, "lib/SDLmain.lib") _
     1593       and LogFileExists(strPathLibSDL, "lib/SDL.dll") _
    16331594      then
    1634       CheckForlibSDLSub = True
     1595         dim strIncSub : strIncSub = "include"
     1596         if DirExists(strPathlibSDL & "/include/SDL") then strIncSub = "include/SDL"
     1597         if   LogFileExists(strPathLibSDL, strIncSub & "/SDL.h") _
     1598          and LogFileExists(strPathLibSDL, strIncSub & "/SDL_syswm.h") _
     1599          and LogFileExists(strPathLibSDL, strIncSub & "/SDL_version.h") _
     1600         then
     1601            strVersion = ""
     1602            CheckForLibSDLSub = strPathLibSDL
     1603         end if
     1604      end if
    16351605   end if
    16361606end function
     
    18651835'
    18661836sub CheckForQt(strOptQt5, strOptInfix)
    1867    dim strPathQt5, strInfixQt5, arrFolders, arrVccInfixes, strVccInfix
     1837   dim strPathQt5, strInfixQt5, arrFolders, arrVccInfixes, strVccInfix, strPathDev
    18681838   PrintHdr "Qt5"
    18691839
     
    18721842   '
    18731843   LogPrint "Checking for user specified path of Qt5 ... "
    1874    strPathQt5 = ""
    1875    if strOptQt5 <> "" then
    1876       strPathQt5 = CheckForQt5Sub(UnixSlashes(strOptQt5), strOptInfix, strInfixQt5)
    1877    end if
    1878 
    1879    if strPathQt = "" then
     1844   strPathQt5 = CheckForQt5Sub(UnixSlashes(strOptQt5), strOptInfix, strInfixQt5)
     1845   if strPathQt5 = "" and g_blnInternalFirst = true then strPathQt5 = CheckForQt5Internal(strOptInfix, strInfixQt5)
     1846   if strPathQt5 = "" then
    18801847      '
    18811848      ' Collect links from "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC"
     
    19191886
    19201887   ' Check the dev tools - prefer ones matching the compiler.
    1921    if strPathQt5 = "" then
    1922       LogPrint "Testing tools dir (" & g_strPathDev & "/win." & g_strTargetArch & "/qt/v5*) ..."
    1923       arrFolders = GetSubdirsStartingWithVerSorted(g_strPathDev & "/win." & g_strTargetArch & "/qt", "v5")
    1924       arrVccInfixes = Array(LCase(g_strVCCVersion), Left(LCase(g_strVCCVersion), Len(g_strVCCVersion) - 1), "")
    1925       for each strVccInfix in arrVccInfixes
    1926          for i = UBound(arrFolders) to LBound(arrFolders) step -1
    1927             if strVccInfix = "" or InStr(1, LCase(arrFolders(i)), strVccInfix) > 0 then
    1928                strPathQt5 = CheckForQt5Sub(g_strPathDev & "/win." & g_strTargetArch & "/qt/" & arrFolders(i), strOptInfix, strInfixQt5)
    1929                if strPathQt5 <> "" then exit for
    1930             end if
    1931          next
    1932          if strPathQt5 <> "" then exit for
    1933       next
    1934    end if
     1888   if strPathQt5 = "" and g_blnInternalFirst = false then strPathQt5 = CheckForQt5Internal(strOptInfix, strInfixQt5)
    19351889
    19361890   '
     
    19511905end sub
    19521906
     1907function CheckForQt5Internal(strOptInfix, ByRef strInfixQt5)
     1908   dim strPathDev, arrFolders, arrVccInfixes, strVccInfix, i
     1909   CheckForQt5Internal = ""
     1910   for each strPathDev in g_arrPathDev
     1911      LogPrint "Testing tools dir (" & strPathDev & "/win." & g_strTargetArch & "/qt/v5*) ..."
     1912      arrFolders = GetSubdirsStartingWithVerSorted(strPathDev & "/win." & g_strTargetArch & "/qt", "v5")
     1913      arrVccInfixes = Array(LCase(g_strVCCVersion), Left(LCase(g_strVCCVersion), Len(g_strVCCVersion) - 1), "")
     1914      for each strVccInfix in arrVccInfixes
     1915         for i = UBound(arrFolders) to LBound(arrFolders) step -1
     1916            if strVccInfix = "" or InStr(1, LCase(arrFolders(i)), strVccInfix) > 0 then
     1917LogPrint "i="&i&" strVccInfix="&strVccInfix
     1918               strPathQt5 = CheckForQt5Sub(strPathDev & "/win." & g_strTargetArch & "/qt/" & arrFolders(i), strOptInfix, strInfixQt5)
     1919               if strPathQt5 <> "" then
     1920                  CheckForQt5Internal = strPathQt5
     1921                  exit function
     1922               end if
     1923            end if
     1924         next
     1925      next
     1926   next
     1927end function
     1928
    19531929function Qt5ProgramItemCallback(ByRef arrStrings, cStrings, ByRef strUnused)
    19541930   dim str, off
     
    19681944function CheckForQt5Sub(strPathQt5, strOptInfix, ByRef strInfixQt5)
    19691945   CheckForQt5Sub = ""
    1970    LogPrint "trying: strPathQt5=" & strPathQt5
    1971 
    1972    if   LogFileExists(strPathQt5, "bin/moc.exe") _
    1973     and LogFileExists(strPathQt5, "bin/uic.exe") _
    1974     and LogFileExists(strPathQt5, "include/QtWidgets/qwidget.h") _
    1975     and LogFileExists(strPathQt5, "include/QtWidgets/QApplication") _
    1976     and LogFileExists(strPathQt5, "include/QtGui/QImage") _
    1977     and LogFileExists(strPathQt5, "include/QtNetwork/QHostAddress") _
    1978    then
    1979       ' Infix testing.
    1980       if   LogFileExists(strPathQt5, "lib/Qt5Core.lib") _
    1981        and LogFileExists(strPathQt5, "lib/Qt5Network.lib") then
    1982          strInfixQt5 = ""
    1983          CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))
    1984       elseif LogFileExists(strPathQt5, "lib/Qt5Core" & strOptInfix & ".lib") _
    1985          and LogFileExists(strPathQt5, "lib/Qt5Network" & strOptInfix & ".lib") then
    1986          strInfixQt5 = strOptInfix
    1987          CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))
    1988       elseif LogFileExists(strPathQt5, "lib/Qt5CoreVBox.lib") _
    1989          and LogFileExists(strPathQt5, "lib/Qt5NetworkVBox.lib") then
    1990          strInfixQt5 = "VBox"
    1991          CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))
     1946   if strPathQt5 <> "" then
     1947      LogPrint "Trying: strPathQt5=" & strPathQt5
     1948
     1949      if   LogFileExists(strPathQt5, "bin/moc.exe") _
     1950       and LogFileExists(strPathQt5, "bin/uic.exe") _
     1951       and LogFileExists(strPathQt5, "include/QtWidgets/qwidget.h") _
     1952       and LogFileExists(strPathQt5, "include/QtWidgets/QApplication") _
     1953       and LogFileExists(strPathQt5, "include/QtGui/QImage") _
     1954       and LogFileExists(strPathQt5, "include/QtNetwork/QHostAddress") _
     1955      then
     1956         ' Infix testing.
     1957         if   LogFileExists(strPathQt5, "lib/Qt5Core.lib") _
     1958          and LogFileExists(strPathQt5, "lib/Qt5Network.lib") then
     1959            LogPrint "found it w/o infix"
     1960            strInfixQt5 = ""
     1961            CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))
     1962         elseif LogFileExists(strPathQt5, "lib/Qt5Core" & strOptInfix & ".lib") _
     1963            and LogFileExists(strPathQt5, "lib/Qt5Network" & strOptInfix & ".lib") then
     1964            LogPrint "found it w/ infix: " & strOptInfix & " (option)"
     1965            strInfixQt5 = strOptInfix
     1966            CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))
     1967         elseif LogFileExists(strPathQt5, "lib/Qt5CoreVBox.lib") _
     1968            and LogFileExists(strPathQt5, "lib/Qt5NetworkVBox.lib") then
     1969            LogPrint "found it w/ infix: VBox"
     1970            strInfixQt5 = "VBox"
     1971            CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))
     1972         end if
    19921973      end if
    19931974   end if
     
    20842065   Print "  --with-libcurl=PATH     To use a cURL other than the VBox one (optional)."
    20852066   Print "  --with-libcurl32=PATH   The 32-bit variant of cURL (optional)."
     2067   Print ""
     2068   Print "  --append-tools-dir=PATH, --prepend-tools-dir=PATH"
     2069   Print "                          Adds an alternative tools directory to search."
     2070   Print "  --append-tools-dir=PATH, --prepend-prog-files=PATH"
     2071   Print "                          Adds an alternative Program Files dir to search."
     2072   Print "  --append-ewdk-drive=DRIVE, --prepend-ewdk-drive=DRIVE"
     2073   Print "                          Adds an EWDK drive the search list."
    20862074end sub
    20872075
     
    21992187            strOptPython = strPath
    22002188
     2189         ' Search lists.
     2190         case "--append-tools-dir"
     2191            g_arrToolsDirs    = ArrayAppend(g_arrPathDev, strPath)
     2192         case "--prepend-tools-dir"
     2193            g_arrToolsDirs    = ArrayPrepend(g_arrPathDev, strPath)
     2194         case "--append-prog-files"
     2195            g_arrProgramFiles = ArrayAppend(g_arrProgramFiles, strPath)
     2196         case "--prepend-prog-files"
     2197            g_arrProgramFiles = ArrayPrepend(g_arrProgramFiles, strPath)
     2198         case "--append-ewdk-drive"
     2199            g_arrProgramFiles = ArrayAppend(g_arrProgramFiles, strPath & "\Program Files")
     2200         case "--prepend-ewdk-drive"
     2201            g_arrProgramFiles = ArrayPrepend(g_arrProgramFiles, strPath & "\Program Files")
     2202
    22012203         ' --disable-something/--enable-something
    22022204         case "--disable-com"
  • trunk/tools/win/vbscript/helpers.vbs

    r85823 r85824  
    668668end function
    669669
     670'' Wrapper for StrComp as GetRef("StrComp") fails.
     671function WrapStrComp(str1, str2)
     672   WrapStrComp = StrComp(str1, str2)
     673end function
    670674
    671675''
    672676' Returns a reverse sorted array (strings).
    673677function ArraySortStrings(arrStrings)
    674    ArraySortStrings = ArraySortStringsEx(arrStrings, GetRef("StrComp"))
     678   ArraySortStrings = ArraySortStringsEx(arrStrings, GetRef("WrapStrComp"))
    675679end function
    676680
     
    683687
    684688
     689'' Wrapper for StrComp as GetRef("StrComp") fails.
     690function WrapStrCompNeg(str1, str2)
     691   WrapStrCompNeg = -StrComp(str1, str2)
     692end function
     693
    685694''
    686695' Returns a reverse sorted array (strings).
    687696function ArrayRSortStrings(arrStrings)
    688    ArrayRSortStrings = ArrayReverse(ArraySortStringsEx(arrStrings, GetRef("StrComp")))
     697   ArrayRSortStrings = ArraySortStringsEx(arrStrings, GetRef("WrapStrCompNeg"))
    689698end function
    690699
     
    707716
    708717''
     718' Returns an Array() statement string
     719function ArrayToString(arrStrings)
     720   dim strRet
     721   strRet = "Array("
     722   for i = LBound(arrStrings) to UBound(arrStrings)
     723      if i <> LBound(arrStrings) then strRet = strRet & ", "
     724      strRet = strRet & """" & arrStrings(i) & """"
     725   next
     726   ArrayToString = strRet & ")"
     727end function
     728
     729
     730''
    709731' Returns the input array with the string appended.
    710 ' Note! There must be some better way of doing this...
    711 ' @todo Lots of copying here...
    712 function ArrayAppend(arr, str)
    713    dim i, cnt
    714    cnt = UBound(arr) - LBound(arr) + 1
    715    redim arrRet(cnt)
    716    for i = LBound(arr) to UBound(arr)
    717       arrRet(i) = arr(i)
    718    next
    719    arrRet(UBound(arr) + 1) = str
    720    ArrayAppend = arrRet
     732' @note This works by reference
     733function ArrayAppend(ByRef arr, str)
     734   dim i
     735   redim preserve arr(UBound(arr) + 1)
     736   arr(UBound(arr)) = str
     737   ArrayAppend = arr
     738end function
     739
     740
     741''
     742' Returns the input array with the string prepended.
     743' @note This works by reference
     744function ArrayPrepend(ByRef arr, str)
     745   dim i
     746   redim preserve arr(UBound(arr) + 1)
     747   for i = UBound(arr) to (LBound(arr) + 1) step -1
     748      arr(i) = arr(i - 1)
     749   next
     750   arr(LBound(arr)) = str
     751   ArrayPrepend = arr
     752end function
     753
     754
     755''
     756' Returns the input array with the string prepended.
     757' @note This works by reference
     758function ArrayRemove(ByRef arr, idx)
     759   dim i
     760   for i = idx to (UBound(arr) - 1)
     761      arr(i) = arr(i + 1)
     762   next
     763   redim preserve arr(UBound(arr) - 1)
     764   ArrayRemove = arr
    721765end function
    722766
     
    748792   next
    749793end function
     794
     795
     796''
     797' Returns the index of the first occurance of the given string; -1 if not found.
     798function ArrayFindString(ByRef arr, str)
     799   dim i
     800   for i = LBound(arr) to UBound(arr)
     801      if StrComp(arr(i), str, vbBinaryCompare) = 0 then
     802         ArrayFindString = i
     803         exit function
     804      end if
     805   next
     806   ArrayFindString = LBound(arr) - 1
     807end function
     808
     809
     810''
     811' Returns the index of the first occurance of the given string, -1 if not found,
     812' case insensitive edition.
     813function ArrayFindStringI(ByRef arr, str)
     814   dim i
     815   for i = LBound(arr) to UBound(arr)
     816      if StrComp(arr(i), str, vbTextCompare) = 0 then
     817         ArrayFindStringI = i
     818         exit function
     819      end if
     820   next
     821   ArrayFindStringI = LBound(arr) - 1
     822end function
     823
    750824
    751825''
     
    11341208   if StrGetFirstWord("1234 5") <> "1234" then MsgFatal "SelfTest: StrGetFirstWord #5"
    11351209   if StrGetFirstWord("  ") <> "" then MsgFatal "SelfTest: StrGetFirstWord #6"
    1136 end sub
    1137 
     1210
     1211   dim arr
     1212   arr = ArrayAppend(Array("0", "1"), "2")
     1213   if ArraySize(arr) <> 3 then MsgFatal "SelfTest: Array #1: size:" & ArraySize(arr)
     1214   if ArrayToString(arr) <> "Array(""0"", ""1"", ""2"")" then MsgFatal "SelfTest: Array #1: " & ArrayToString(arr)
     1215
     1216   arr = ArrayPrepend(arr, "-1")
     1217   if ArraySize(arr) <> 4 then MsgFatal "SelfTest: Array #2: size:" & ArraySize(arr)
     1218   if ArrayToString(arr) <> "Array(""-1"", ""0"", ""1"", ""2"")" then MsgFatal "SelfTest: Array #2: " & ArrayToString(arr)
     1219
     1220   ArrayPrepend arr, "-2"
     1221   if ArraySize(arr) <> 5 then MsgFatal "SelfTest: Array #3: size:" & ArraySize(arr)
     1222   if ArrayToString(arr) <> "Array(""-2"", ""-1"", ""0"", ""1"", ""2"")" then MsgFatal "SelfTest: Array #3: " & ArrayToString(arr)
     1223
     1224   ArrayRemove arr, 1
     1225   if ArraySize(arr) <> 4 then MsgFatal "SelfTest: Array #4: size:" & ArraySize(arr)
     1226   if ArrayToString(arr) <> "Array(""-2"", ""0"", ""1"", ""2"")" then MsgFatal "SelfTest: Array #4: " & ArrayToString(arr)
     1227
     1228   arr = ArrayRemove(arr, 2)
     1229   if ArraySize(arr) <> 3 then MsgFatal "SelfTest: Array #5: size:" & ArraySize(arr)
     1230   if ArrayToString(arr) <> "Array(""-2"", ""0"", ""2"")" then MsgFatal "SelfTest: Array #5: " & ArrayToString(arr)
     1231
     1232   arr = ArrayPrepend(arr, "42")
     1233   arr = ArrayAppend(arr, "-42")
     1234   if ArraySize(arr) <> 5 then MsgFatal "SelfTest: Array #6: size:" & ArraySize(arr)
     1235   if ArrayToString(arr) <> "Array(""42"", ""-2"", ""0"", ""2"", ""-42"")" then MsgFatal "SelfTest: Array #6: " & ArrayToString(arr)
     1236
     1237   arr = ArraySortStrings(arr)
     1238   if ArraySize(arr) <> 5 then MsgFatal "SelfTest: Array #7: size:" & ArraySize(arr)
     1239   if ArrayToString(arr) <> "Array(""-2"", ""-42"", ""0"", ""2"", ""42"")" then MsgFatal "SelfTest: Array #7: " & ArrayToString(arr)
     1240
     1241   arr = ArrayRSortStrings(arr)
     1242   if ArraySize(arr) <> 5 then MsgFatal "SelfTest: Array #7: size:" & ArraySize(arr)
     1243   if ArrayToString(arr) <> "Array(""42"", ""2"", ""0"", ""-42"", ""-2"")" then MsgFatal "SelfTest: Array #8: " & ArrayToString(arr)
     1244
     1245   arr = ArrayVerSortStrings(Array("v10", "v1", "v0"))
     1246   if ArrayToString(arr) <> "Array(""v0"", ""v1"", ""v10"")" then MsgFatal "SelfTest: Array #9: " & ArrayToString(arr)
     1247
     1248   arr = ArrayRVerSortStrings(arr)
     1249   if ArrayToString(arr) <> "Array(""v10"", ""v1"", ""v0"")" then MsgFatal "SelfTest: Array #10: " & ArrayToString(arr)
     1250
     1251end sub
     1252
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