mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Merge pull request #72 from davidgiven/windows
Use mingw32 to build the Windows client, removing the cygwin dependency.
This commit is contained in:
@@ -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</dev/null; make"'
|
||||
- make
|
||||
|
||||
artifacts:
|
||||
- path: fluxengine.exe
|
||||
|
||||
12
.travis.yml
12
.travis.yml
@@ -1,4 +1,6 @@
|
||||
language: generic
|
||||
language: shell
|
||||
git:
|
||||
depth: 1
|
||||
|
||||
matrix:
|
||||
include:
|
||||
@@ -8,6 +10,8 @@ matrix:
|
||||
dist: xenial
|
||||
compiler: gcc
|
||||
env: CXX=g++-8
|
||||
script:
|
||||
- make
|
||||
-
|
||||
os: osx
|
||||
osx_image: xcode10.2
|
||||
@@ -27,9 +31,7 @@ addons:
|
||||
packages:
|
||||
- ninja
|
||||
|
||||
git:
|
||||
depth: 1
|
||||
|
||||
script:
|
||||
- make
|
||||
- make
|
||||
|
||||
|
||||
|
||||
22
Makefile
22
Makefile
@@ -1,19 +1,35 @@
|
||||
PACKAGES = zlib sqlite3 libusb-1.0
|
||||
|
||||
ifeq ($(OS), Windows_NT)
|
||||
export CXX = /mingw32/bin/g++
|
||||
export AR = /mingw32/bin/ar rcs
|
||||
export STRIP = /mingw32/bin/strip
|
||||
export CFLAGS = -O3 -g --std=c++14 -I/mingw32/include/libusb-1.0
|
||||
export LDFLAGS = -O3
|
||||
export LIBS = -static -lz -lsqlite3 -lusb-1.0
|
||||
export EXTENSION = .exe
|
||||
else
|
||||
export CXX = g++
|
||||
export AR = ar rcs
|
||||
export STRIP = strip
|
||||
export CFLAGS = -Og -g --std=c++14
|
||||
export CFLAGS = -Og -g --std=c++14 $(shell pkg-config --cflags $(PACKAGES))
|
||||
export LDFLAGS = -Og
|
||||
export LIBS = $(shell pkg-config --libs $(PACKAGES))
|
||||
export EXTENSION =
|
||||
endif
|
||||
|
||||
CFLAGS += -Ilib -Idep/fmt
|
||||
|
||||
export OBJDIR = .obj
|
||||
|
||||
all: .obj/build.ninja
|
||||
@ninja -f .obj/build.ninja
|
||||
@ninja -f .obj/build.ninja -v
|
||||
|
||||
clean:
|
||||
@echo CLEAN
|
||||
@rm -rf $(OBJDIR)
|
||||
|
||||
.obj/build.ninja: mkninja.sh
|
||||
.obj/build.ninja: mkninja.sh Makefile
|
||||
@echo MKNINJA $@
|
||||
@mkdir -p $(OBJDIR)
|
||||
@sh $< > $@
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include "protocol.h"
|
||||
#include "fmt/format.h"
|
||||
#include <fstream>
|
||||
#include <glob.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#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<Fluxmap> 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);
|
||||
}
|
||||
|
||||
21
mkninja.sh
21
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 <<EOF
|
||||
rule cxx
|
||||
@@ -16,7 +13,7 @@ rule library
|
||||
description = AR \$in
|
||||
|
||||
rule link
|
||||
command = $CXX $LDFLAGS -o \$out \$in \$flags
|
||||
command = $CXX $LDFLAGS -o \$out \$in \$flags $LIBS
|
||||
description = LINK \$in
|
||||
|
||||
rule test
|
||||
@@ -96,17 +93,14 @@ runtest() {
|
||||
shift
|
||||
|
||||
buildlibrary lib$prog.a \
|
||||
-Ilib \
|
||||
$pkgcflags \
|
||||
"$@"
|
||||
|
||||
buildprogram $OBJDIR/$prog \
|
||||
$pkgldflags \
|
||||
buildprogram $OBJDIR/$prog$EXTENSION \
|
||||
lib$prog.a \
|
||||
libbackend.a \
|
||||
libfmt.a
|
||||
|
||||
echo build $OBJDIR/$prog.stamp : test $OBJDIR/$prog
|
||||
echo build $OBJDIR/$prog.stamp : test $OBJDIR/$prog$EXTENSION
|
||||
}
|
||||
|
||||
buildlibrary libfmt.a \
|
||||
@@ -114,8 +108,6 @@ buildlibrary libfmt.a \
|
||||
dep/fmt/posix.cc \
|
||||
|
||||
buildlibrary libbackend.a \
|
||||
-Ilib \
|
||||
$pkgcflags \
|
||||
lib/aeslanier/decoder.cc \
|
||||
lib/amiga/decoder.cc \
|
||||
lib/apple2/decoder.cc \
|
||||
@@ -158,8 +150,6 @@ buildlibrary libbackend.a \
|
||||
lib/zilogmcz/decoder.cc \
|
||||
|
||||
buildlibrary libfrontend.a \
|
||||
-Ilib \
|
||||
$pkgcflags \
|
||||
src/fe-erase.cc \
|
||||
src/fe-inspect.cc \
|
||||
src/fe-readadfs.cc \
|
||||
@@ -186,13 +176,12 @@ buildlibrary libfrontend.a \
|
||||
src/fe-writetestpattern.cc \
|
||||
src/fluxengine.cc \
|
||||
|
||||
buildprogram fluxengine-debug \
|
||||
$pkgldflags \
|
||||
buildprogram fluxengine-debug$EXTENSION \
|
||||
libfrontend.a \
|
||||
libbackend.a \
|
||||
libfmt.a \
|
||||
|
||||
echo "build fluxengine : strip fluxengine-debug"
|
||||
echo "build fluxengine$EXTENSION : strip fluxengine-debug$EXTENSION"
|
||||
|
||||
runtest dataspec-test tests/dataspec.cc
|
||||
runtest flags-test tests/flags.cc
|
||||
|
||||
Reference in New Issue
Block a user