Ignore:
Timestamp:
Jul 1, 2020, 10:24:52 PM (5 years ago)
Author:
bird
Message:

kmk: Added version sort function: versort, rversort, versortfiles, rversortfiles, qversortfiles, qrversortfiles. Try get the real host version on windows by using RtlGetVersion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/variable.c

    r3319 r3394  
    16061606  struct variable *envvar1;
    16071607  struct variable *envvar2;
    1608 # ifdef WINDOWS32
    1609   OSVERSIONINFOEX oix;
    1610 # else
     1608# ifndef WINDOWS32
    16111609  struct utsname uts;
    16121610# endif
     
    16771675
    16781676  /* The host kernel version. */
    1679 #if defined(WINDOWS32)
    1680   memset (&oix, '\0', sizeof (oix));
    1681   oix.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    1682   if (!GetVersionEx ((LPOSVERSIONINFO)&oix))
    1683     {
    1684       memset (&oix, '\0', sizeof (oix));
    1685       oix.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
    1686       GetVersionEx ((LPOSVERSIONINFO)&oix);
    1687     }
    1688   if (oix.dwPlatformId == VER_PLATFORM_WIN32_NT)
    1689     {
    1690       ulMajor = oix.dwMajorVersion;
    1691       ulMinor = oix.dwMinorVersion;
    1692       ulPatch = oix.wServicePackMajor;
    1693       ul4th   = oix.wServicePackMinor;
    1694     }
    1695   else
    1696     {
    1697       ulMajor = oix.dwPlatformId == 1 ? 0 /*Win95/98/ME*/
    1698               : oix.dwPlatformId == 3 ? 1 /*WinCE*/
    1699               : 2; /*??*/
    1700       ulMinor = oix.dwMajorVersion;
    1701       ulPatch = oix.dwMinorVersion;
    1702       ul4th   = oix.wServicePackMajor;
    1703     }
    1704 #else
     1677# if defined(WINDOWS32)
     1678  {
     1679    OSVERSIONINFOEXW oix;
     1680    typedef NTSTATUS (WINAPI *pfnRtlGetVersion)(OSVERSIONINFOEXW *);
     1681    *(FARPROC *)&pfnRtlGetVersion = GetProcAddress (GetModuleHandleW ("NTDLL.DLL"),
     1682                                                    "RtlGetVersion"); /* GetVersionEx lies */
     1683    memset (&oix, '\0', sizeof (oix));
     1684    oix.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
     1685    if (!pfnRtlGetVersion || pfnRtlGetVersion (&oix) < 0)
     1686      {
     1687        memset (&oix, '\0', sizeof (oix));
     1688        oix.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
     1689        if (!GetVersionExW((LPOSVERSIONINFO)&oix))
     1690          {
     1691            memset (&oix, '\0', sizeof (oix));
     1692            oix.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
     1693            GetVersionExW ((LPOSVERSIONINFO)&oix);
     1694          }
     1695      }
     1696    if (oix.dwPlatformId == VER_PLATFORM_WIN32_NT)
     1697      {
     1698        ulMajor = oix.dwMajorVersion;
     1699        ulMinor = oix.dwMinorVersion;
     1700        ulPatch = oix.wServicePackMajor;
     1701        ul4th   = oix.wServicePackMinor;
     1702      }
     1703    else
     1704      {
     1705        ulMajor = oix.dwPlatformId == 1 ? 0 /*Win95/98/ME*/
     1706                : oix.dwPlatformId == 3 ? 1 /*WinCE*/
     1707                : 2; /*??*/
     1708        ulMinor = oix.dwMajorVersion;
     1709        ulPatch = oix.dwMinorVersion;
     1710        ul4th   = oix.wServicePackMajor;
     1711      }
     1712  }
     1713# else
    17051714  memset (&uts, 0, sizeof(uts));
    17061715  uname (&uts);
     
    17161725  define_variable_cname ("KBUILD_HOST_UNAME_MACHINE", uts.machine, o_default, 0);
    17171726  define_variable_cname ("KBUILD_HOST_UNAME_NODENAME", uts.nodename, o_default, 0);
    1718 #endif
     1727# endif
    17191728
    17201729  sprintf (buf, "%lu.%lu.%lu.%lu", ulMajor, ulMinor, ulPatch, ul4th);
     
    17651774  && defined (KMK_HELPERS)
    17661775  define_variable_cname ("KMK_FEATURES",
    1767                          "append-dash-n abspath includedep-queue install-hard-linking umask quote"
     1776                         "append-dash-n abspath includedep-queue install-hard-linking umask quote versort"
    17681777                         " kBuild-define"
    17691778                         " rsort"
     
    17961805# else /* MSC can't deal with strings mixed with #if/#endif, thus the slow way. */
    17971806#  error "All features should be enabled by default!"
    1798   strcpy (buf, "append-dash-n abspath includedep-queue install-hard-linking umask quote"
     1807  strcpy (buf, "append-dash-n abspath includedep-queue install-hard-linking umask quote versort"
    17991808               " kBuild-define");
    18001809#  if defined (CONFIG_WITH_RSORT)
Note: See TracChangeset for help on using the changeset viewer.