diff --git a/.appveyor.yml b/.appveyor.yml index 3dd492b6..7e73ec37 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,19 +1,19 @@ -environment: - matrix: - - CYGWIN: C:\cygwin64 - +version: '{branch}.{build}' clone_depth: 1 +environment: + MSYSTEM: MINGW32 + init: - git config --global core.autocrlf input install: - - '%CYGWIN%\bin\bash -lc "cygcheck -dc cygwin"' - - '%CYGWIN%\setup-x86_64 -q -P libsqlite3-devel,ninja,zlib-devel,libusb1.0-devel' + - set PATH=c:\msys64\mingw32\bin;c:\msys64\usr\bin;c:\msys64\bin;%PATH% + - echo %PATH% + - pacman -S --noconfirm --needed make ninja mingw-w64-i686-libusb mingw-w64-i686-sqlite3 mingw-w64-i686-zlib mingw-w64-i686-gcc build_script: - - 'echo building...' - - '%CYGWIN%\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0 $@ diff --git a/doc/building.md b/doc/building.md index bfcf69aa..cad2de95 100644 --- a/doc/building.md +++ b/doc/building.md @@ -141,11 +141,22 @@ the port and proceed normally. The client software is where the intelligence, such as it is, is. It's pretty generic libusb stuff and should build and run on Windows, Linux and OSX as -well, although on Windows I've only ever used it with Cygwin. You'll need the -`sqlite3`, `libusb-1.0` and `ninja` packages (which should be easy to come by -in your distribution). Just do `make` and it should build. The result will -be a single executable, `fluxengine`, in the current directory. It has -minimal dependencies and can be installed anywhere. +well, although on Windows it'll need MSYS2 and mingw32. You'll need to +install some support packages. + + - For Linux (this is Ubuntu, but this should apply to Debian too): + `ninja-build`, `libusb-1.0-0-dev`, `libsqlite3-dev`. + - For OSX with Homebrew: `ninja`. + - For Windows with MSYS2: `make`, `ninja`, `mingw-w64-i686-libusb`, + `mingw-w64-i686-sqlite3`, `mingw-w64-i686-zlib`, `mingw-w64-i686-gcc`. + +These lists are not necessarily exhaustive --- plaese [get in +touch](https://github.com/davidgiven/fluxengine/issues/new) if I've missed +anything. + +All systems build by just doing `make`. You should end up with a single +executable in the current directory, called `fluxengine`. It has minimal +dependencies and you should be able to put it anywhere. If it doesn't build, please [get in touch](https://github.com/davidgiven/fluxengine/issues/new). diff --git a/lib/fluxsource/kryoflux.cc b/lib/fluxsource/kryoflux.cc index f6961774..141e005d 100644 --- a/lib/fluxsource/kryoflux.cc +++ b/lib/fluxsource/kryoflux.cc @@ -4,7 +4,8 @@ #include "protocol.h" #include "fmt/format.h" #include -#include +#include +#include #define MCLK_HZ (((18432000.0 * 73.0) / 14.0) / 2.0) #define SCLK_HZ (MCLK_HZ / 2) @@ -12,17 +13,40 @@ #define TICKS_PER_SCLK (TICK_FREQUENCY / SCLK_HZ) +static bool has_suffix(const std::string& haystack, const std::string& needle) +{ + if (needle.length() > haystack.length()) + return false; + + return haystack.compare(haystack.length() - needle.length(), needle.length(), needle) == 0; +} + std::unique_ptr readStream(const std::string& dir, unsigned track, unsigned side) { std::string suffix = fmt::format("{:02}.{}.raw", track, side); - std::string pattern = fmt::format("{}*{}", dir, suffix); - glob_t globdata; - if (glob(pattern.c_str(), GLOB_NOSORT, NULL, &globdata)) + + DIR* dirp = opendir(dir.c_str()); + if (!dirp) Error() << fmt::format("cannot access path '{}'", dir); - if (globdata.gl_pathc != 1) - Error() << fmt::format("data is ambiguous --- multiple files end in {}", suffix); - std::string filename = globdata.gl_pathv[0]; - globfree(&globdata); + + std::string filename; + for (;;) + { + struct dirent* de = readdir(dirp); + if (!de) + break; + + if (has_suffix(de->d_name, suffix)) + { + if (!filename.empty()) + Error() << fmt::format("data is ambiguous --- multiple files end in {}", suffix); + filename = fmt::format("{}/{}", dir, de->d_name); + } + } + closedir(dirp); + + if (filename.empty()) + Error() << fmt::format("failed to find track {} side {} in {}", track, side, dir); return readStream(filename); } diff --git a/mkninja.sh b/mkninja.sh index 966ddbf4..d99c05ad 100644 --- a/mkninja.sh +++ b/mkninja.sh @@ -1,8 +1,5 @@ #!/bin/sh set -e -packages="zlib sqlite3 libusb-1.0" -pkgcflags="$(pkg-config --cflags $packages) -Idep/fmt" -pkgldflags=$(pkg-config --libs $packages) cat <