Browse Source

Switch fswatch to submodule from wget'd tarball. Add mingw fswatch

patch.
tags/v1.1.1
Andrew Belt 5 years ago
parent
commit
5473e6da15
4 changed files with 127 additions and 7 deletions
  1. +4
    -1
      .gitmodules
  2. +12
    -6
      Makefile
  3. +1
    -0
      fswatch
  4. +110
    -0
      fswatch_mingw_patch.sh

+ 4
- 1
.gitmodules View File

@@ -1,3 +1,6 @@
[submodule "fswatch"]
path = fswatch
url = https://github.com/emcrisostomo/fswatch.git
[submodule "QuickJS"]
path = QuickJS
url = https://github.com/JerrySievert/QuickJS
url = https://github.com/JerrySievert/QuickJS.git

+ 12
- 6
Makefile View File

@@ -11,18 +11,24 @@ SOURCES += $(wildcard src/*.cpp)
DISTRIBUTABLES += res examples
DISTRIBUTABLES += $(wildcard LICENSE*)

include $(RACK_DIR)/arch.mk

# fswatch
fswatch := dep/lib/libfswatch.a
DEPS += $(fswatch)
OBJECTS += $(fswatch)
ifdef ARCH_WIN
LDFLAGS += -lintl
FSWATCH_CONFIGURE_FLAGS += CFLAGS="-DHAVE_WINDOWS" CXXFLAGS="-DHAVE_WINDOWS"
endif
$(fswatch):
$(WGET) "https://github.com/emcrisostomo/fswatch/releases/download/1.14.0/fswatch-1.14.0.tar.gz"
$(SHA256) fswatch-1.14.0.tar.gz 44d5707adc0e46d901ba95a5dc35c5cc282bd6f331fcf9dbf9fad4af0ed5b29d
cd dep && $(UNTAR) ../fswatch-1.14.0.tar.gz
cd dep/fswatch-1.14.0 && $(CONFIGURE) --enable-shared=no
cd dep/fswatch-1.14.0 && $(MAKE)
cd dep/fswatch-1.14.0 && $(MAKE) install
ifdef ARCH_WIN
cd fswatch && MINGWPREFIX=/mingw64 ../fswatch_mingw_patch.sh
endif
cd fswatch && ./autogen.sh
cd fswatch && $(CONFIGURE) $(FSWATCH_CONFIGURE_FLAGS) --enable-shared=no
cd fswatch && $(MAKE)
cd fswatch && $(MAKE) install

# QuickJS
quickjs := dep/lib/quickjs/libquickjs.a


+ 1
- 0
fswatch

@@ -0,0 +1 @@
Subproject commit d5d2ea84da1f0b0da23921891965894a86c72c27

+ 110
- 0
fswatch_mingw_patch.sh View File

@@ -0,0 +1,110 @@
#!/bin/sh
# fix missing S_ISLNK in libfswatch/src/libfswatch/c++/poll_monitor.cpp
patch -ulbf libfswatch/src/libfswatch/c++/poll_monitor.cpp << EOF
@@ -131,2 +131,3 @@
+#ifndef _WIN32
if (follow_symlinks && S_ISLNK(fd_stat.st_mode))
@@ -139,2 +140,3 @@
}
+#endif
EOF
# fix missing realpath/lstat in libfswatch/src/libfswatch/c++/path_utils.cpp
patch -ulbf libfswatch/src/libfswatch/c++/path_utils.cpp << EOF
@@ -59,2 +59,5 @@
{
+#ifdef _WIN32
+ return false;
+#else
char *real_path = realpath(path.c_str(), nullptr);
@@ -66,2 +69,3 @@
return ret;
+#endif
}
@@ -82,2 +86,6 @@
{
+#ifdef _WIN32
+ fsw_logf_perror(_("Cannot lstat %s (not implemented on Windows)"), path.c_str());
+ return false;
+#else
if (lstat(path.c_str(), &fd_stat) != 0)
@@ -90,2 +98,3 @@
return true;
+#endif
}
EOF
# fix missing sigaction/realpath in fswatch/src/fswatch.cpp
patch -ulbf fswatch/src/fswatch.cpp << EOF
@@ -36,2 +36,5 @@
#include "libfswatch/c++/libfswatch_exception.hpp"
+#ifdef _WIN32
+#define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
+#endif
@@ -297,2 +300,3 @@
{
+#ifndef _WIN32
struct sigaction action;
@@ -328,2 +332,3 @@
}
+#endif
}
EOF
# fix libfswatch/src/libfswatch/c++/windows/win_paths.cpp
patch -ulbf libfswatch/src/libfswatch/c++/windows/win_paths.cpp << EOF
@@ -16,3 +16,7 @@
#include "win_paths.hpp"
+#ifdef __CYGWIN__
#include <sys/cygwin.h>
+#else
+#include <windows.h>
+#endif
#include "../libfswatch_exception.hpp"
@@ -28,2 +32,3 @@
{
+#ifdef __CYGWIN__
void * raw_path = cygwin_create_path(CCP_POSIX_TO_WIN_W, path.c_str());
@@ -36,2 +41,11 @@
return win_path;
+#else
+ int pathlen = (int)path.length() + 1;
+ int buflen = MultiByteToWideChar(CP_ACP, 0, path.c_str(), pathlen, 0, 0);
+ wchar_t* buf = new wchar_t[buflen];
+ MultiByteToWideChar(CP_ACP, 0, path.c_str(), pathlen, buf, buflen);
+ std::wstring result(buf);
+ delete[] buf;
+ return result;
+#endif
}
@@ -40,2 +54,3 @@
{
+#ifdef __CYGWIN__
void * raw_path = cygwin_create_path(CCP_WIN_W_TO_POSIX, path.c_str());
@@ -48,2 +63,11 @@
return posix_path;
+#else
+ int pathlen = (int)path.length() + 1;
+ int buflen = WideCharToMultiByte(CP_ACP, 0, path.c_str(), pathlen, 0, 0, 0, 0);
+ char* buf = new char[buflen];
+ WideCharToMultiByte(CP_ACP, 0, path.c_str(), pathlen, buf, buflen, 0, 0);
+ std::string result(buf);
+ delete[] buf;
+ return result;
+#endif
}
EOF
# fix missing file
touch README.illumos
# remove detection of realpath/regcomp/select
mv libfswatch/configure.ac libfswatch/configure.ac.bak &&
grep -v "realpath\|regcomp\|select" libfswatch/configure.ac.bak > libfswatch/configure.ac
# remove detection of realpath
mv configure.ac configure.ac.bak2 &&
grep -v "realpath" configure.ac.bak2 > configure.ac
# remove detection of realpath
mv configure.ac configure.ac.bak3 &&
grep -v "The select function cannot be found." configure.ac.bak3 > configure.ac
# fix for building windows_monitor
mv libfswatch/src/libfswatch/Makefile.am libfswatch/src/libfswatch/Makefile.am.bak &&
sed -e "s/USE_CYGWIN/USE_WINDOWS/" libfswatch/src/libfswatch/Makefile.am.bak > libfswatch/src/libfswatch/Makefile.am

Loading…
Cancel
Save