You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.3KB

  1. #!/bin/sh
  2. # fix missing S_ISLNK in libfswatch/src/libfswatch/c++/poll_monitor.cpp
  3. patch -ulbf libfswatch/src/libfswatch/c++/poll_monitor.cpp << EOF
  4. @@ -131,2 +131,3 @@
  5. +#ifndef _WIN32
  6. if (follow_symlinks && S_ISLNK(fd_stat.st_mode))
  7. @@ -139,2 +140,3 @@
  8. }
  9. +#endif
  10. EOF
  11. # fix missing realpath/lstat in libfswatch/src/libfswatch/c++/path_utils.cpp
  12. patch -ulbf libfswatch/src/libfswatch/c++/path_utils.cpp << EOF
  13. @@ -59,2 +59,5 @@
  14. {
  15. +#ifdef _WIN32
  16. + return false;
  17. +#else
  18. char *real_path = realpath(path.c_str(), nullptr);
  19. @@ -66,2 +69,3 @@
  20. return ret;
  21. +#endif
  22. }
  23. @@ -82,2 +86,6 @@
  24. {
  25. +#ifdef _WIN32
  26. + fsw_logf_perror(_("Cannot lstat %s (not implemented on Windows)"), path.c_str());
  27. + return false;
  28. +#else
  29. if (lstat(path.c_str(), &fd_stat) != 0)
  30. @@ -90,2 +98,3 @@
  31. return true;
  32. +#endif
  33. }
  34. EOF
  35. # fix missing sigaction/realpath in fswatch/src/fswatch.cpp
  36. patch -ulbf fswatch/src/fswatch.cpp << EOF
  37. @@ -36,2 +36,5 @@
  38. #include "libfswatch/c++/libfswatch_exception.hpp"
  39. +#ifdef _WIN32
  40. +#define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
  41. +#endif
  42. @@ -297,2 +300,3 @@
  43. {
  44. +#ifndef _WIN32
  45. struct sigaction action;
  46. @@ -328,2 +332,3 @@
  47. }
  48. +#endif
  49. }
  50. EOF
  51. # fix libfswatch/src/libfswatch/c++/windows/win_paths.cpp
  52. patch -ulbf libfswatch/src/libfswatch/c++/windows/win_paths.cpp << EOF
  53. @@ -16,3 +16,7 @@
  54. #include "win_paths.hpp"
  55. +#ifdef __CYGWIN__
  56. #include <sys/cygwin.h>
  57. +#else
  58. +#include <windows.h>
  59. +#endif
  60. #include "../libfswatch_exception.hpp"
  61. @@ -28,2 +32,3 @@
  62. {
  63. +#ifdef __CYGWIN__
  64. void * raw_path = cygwin_create_path(CCP_POSIX_TO_WIN_W, path.c_str());
  65. @@ -36,2 +41,11 @@
  66. return win_path;
  67. +#else
  68. + int pathlen = (int)path.length() + 1;
  69. + int buflen = MultiByteToWideChar(CP_ACP, 0, path.c_str(), pathlen, 0, 0);
  70. + wchar_t* buf = new wchar_t[buflen];
  71. + MultiByteToWideChar(CP_ACP, 0, path.c_str(), pathlen, buf, buflen);
  72. + std::wstring result(buf);
  73. + delete[] buf;
  74. + return result;
  75. +#endif
  76. }
  77. @@ -40,2 +54,3 @@
  78. {
  79. +#ifdef __CYGWIN__
  80. void * raw_path = cygwin_create_path(CCP_WIN_W_TO_POSIX, path.c_str());
  81. @@ -48,2 +63,11 @@
  82. return posix_path;
  83. +#else
  84. + int pathlen = (int)path.length() + 1;
  85. + int buflen = WideCharToMultiByte(CP_ACP, 0, path.c_str(), pathlen, 0, 0, 0, 0);
  86. + char* buf = new char[buflen];
  87. + WideCharToMultiByte(CP_ACP, 0, path.c_str(), pathlen, buf, buflen, 0, 0);
  88. + std::string result(buf);
  89. + delete[] buf;
  90. + return result;
  91. +#endif
  92. }
  93. EOF
  94. # fix missing file
  95. touch README.illumos
  96. # remove detection of realpath/regcomp/select
  97. mv libfswatch/configure.ac libfswatch/configure.ac.bak &&
  98. grep -v "realpath\|regcomp\|select" libfswatch/configure.ac.bak > libfswatch/configure.ac
  99. # remove detection of realpath
  100. mv configure.ac configure.ac.bak2 &&
  101. grep -v "realpath" configure.ac.bak2 > configure.ac
  102. # remove detection of realpath
  103. mv configure.ac configure.ac.bak3 &&
  104. grep -v "The select function cannot be found." configure.ac.bak3 > configure.ac
  105. # fix for building windows_monitor
  106. mv libfswatch/src/libfswatch/Makefile.am libfswatch/src/libfswatch/Makefile.am.bak &&
  107. sed -e "s/USE_CYGWIN/USE_WINDOWS/" libfswatch/src/libfswatch/Makefile.am.bak > libfswatch/src/libfswatch/Makefile.am