Skip to content

Commit

Permalink
Merge pull request #77 from davidgiven/build
Browse files Browse the repository at this point in the history
Build cleanups
  • Loading branch information
davidgiven authored Jul 11, 2019
2 parents a2fdbc5 + 9f92ce0 commit 6959d18
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ install:

build_script:
- make
- zip -9 fluxengine.zip fluxengine.exe brother120tool.exe cwftoflux.exe fluxtovcd.exe fluxtoau.exe
- zip -9 fluxengine.zip fluxengine.exe brother120tool.exe

artifacts:
- path: fluxengine.zip
Expand Down
64 changes: 34 additions & 30 deletions mkninja.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,33 @@ buildprogram() {
echo build $prog$EXTENSION : strip $prog-debug$EXTENSION
}

buildsimpleprogram() {
local prog
prog=$1
shift

local flags
flags=
while true; do
case $1 in
-*)
flags="$flags $1"
shift
;;

*)
break
esac
done

local src
src=$1
shift

buildlibrary lib$prog.a $flags $src
buildprogram $prog lib$prog.a "$@"
}

runtest() {
local prog
prog=$1
Expand Down Expand Up @@ -152,7 +179,10 @@ buildlibrary libbackend.a \
lib/zilogmcz/decoder.cc \

buildlibrary libfrontend.a \
src/fe-cwftoflux.cc \
src/fe-erase.cc \
src/fe-fluxtoau.cc \
src/fe-fluxtovcd.cc \
src/fe-inspect.cc \
src/fe-readadfs.cc \
src/fe-readaeslanier.cc \
Expand Down Expand Up @@ -183,40 +213,14 @@ buildprogram fluxengine \
libbackend.a \
libfmt.a \

buildlibrary libbrother120tool.a \
-Idep/emu \
tools/brother120tool.cc \

buildlibrary libemu.a \
dep/emu/fnmatch.c

buildprogram brother120tool \
libbrother120tool.a \
libemu.a \
libfmt.a \

buildlibrary libcwftoflux.a \
tools/cwftoflux.cc \

buildprogram cwftoflux \
libcwftoflux.a \
libbackend.a \
libfmt.a \

buildlibrary libfluxtovcd.a \
tools/fluxtovcd.cc \

buildprogram fluxtovcd \
libfluxtovcd.a \
libbackend.a \
libfmt.a \

buildlibrary libfluxtoau.a \
tools/fluxtoau.cc \

buildprogram fluxtoau \
libfluxtoau.a \
buildsimpleprogram brother120tool \
-Idep/emu \
tools/brother120tool.cc \
libbackend.a \
libemu.a \
libfmt.a \

runtest dataspec-test tests/dataspec.cc
Expand Down
4 changes: 2 additions & 2 deletions tools/cwftoflux.cc → src/fe-cwftoflux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static double clockRate;

static void syntax()
{
std::cout << "Syntax: cwftoflux <cwffile> <fluxfile>\n";
std::cout << "Syntax: fluxengine convert cwftoflux <cwffile> <fluxfile>\n";
exit(0);
}

Expand Down Expand Up @@ -116,7 +116,7 @@ static void read_track()
sqlWriteFlux(outputDb, track_number, trackheader.side, fluxmap);
}

int main(int argc, const char* argv[])
int mainConvertCwfToFlux(int argc, const char* argv[])
{
if (argc != 3)
syntax();
Expand Down
6 changes: 4 additions & 2 deletions tools/fluxtoau.cc → src/fe-fluxtoau.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "fmt/format.h"
#include <fstream>

FlagGroup flags { &hardwareFluxSourceFlags };
static FlagGroup flags { &hardwareFluxSourceFlags };

static DataSpecFlag source(
{ "--source", "-s" },
Expand All @@ -30,7 +30,7 @@ static SettableFlag withIndex(
{ "--with-index" },
"place index markers in the right hand channel");

int main(int argc, const char* argv[])
int mainConvertFluxToAu(int argc, const char* argv[])
{
flags.parseFlags(argc, argv);

Expand Down Expand Up @@ -94,5 +94,7 @@ int main(int argc, const char* argv[])
of.write((const char*) data.cbegin(), data.size());
}

std::cerr << "Done. Warning: do not play this file, or you will break your speakers"
" and/or ears!\n";
return 0;
}
4 changes: 2 additions & 2 deletions tools/fluxtovcd.cc → src/fe-fluxtovcd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "fmt/format.h"
#include <fstream>

FlagGroup flags { &hardwareFluxSourceFlags };
static FlagGroup flags { &hardwareFluxSourceFlags };

static DataSpecFlag source(
{ "--source", "-s" },
Expand All @@ -26,7 +26,7 @@ static SettableFlag highDensityFlag(
{ "--high-density", "--hd" },
"set the drive to high density mode");

int main(int argc, const char* argv[])
int mainConvertFluxToVcd(int argc, const char* argv[])
{
flags.parseFlags(argc, argv);

Expand Down
33 changes: 24 additions & 9 deletions src/fluxengine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
typedef int command_cb(int agrc, const char* argv[]);

extern command_cb mainErase;
extern command_cb mainConvertCwfToFlux;
extern command_cb mainConvertFluxToAu;
extern command_cb mainConvertFluxToVcd;
extern command_cb mainInspect;
extern command_cb mainReadADFS;
extern command_cb mainReadAESLanier;
Expand All @@ -15,9 +18,9 @@ extern command_cb mainReadDFS;
extern command_cb mainReadF85;
extern command_cb mainReadFB100;
extern command_cb mainReadIBM;
extern command_cb mainReadVictor9K;
extern command_cb mainReadMac;
extern command_cb mainReadMx;
extern command_cb mainReadVictor9K;
extern command_cb mainReadZilogMCZ;
extern command_cb mainRpm;
extern command_cb mainSeek;
Expand All @@ -36,16 +39,18 @@ struct Command

static command_cb mainRead;
static command_cb mainWrite;
static command_cb mainConvert;

static std::vector<Command> commands =
{
{ "erase", mainErase, "Permanently but rapidly erases some or all of a disk." },
{ "convert", mainConvert, "Converts various types of data file.", },
{ "inspect", mainInspect, "Low-level analysis and inspection of a disk." },
{ "read", mainRead, "Reads a disk, producing a sector image.", },
{ "rpm", mainRpm, "Measures the disk rotational speed.", },
{ "seek", mainSeek, "Moves the disk head.", },
{ "testbulktransport", mainTestBulkTransport, "Measures your USB bandwidth.", },
{ "upgradefluxfile", mainUpgradeFluxFile, "Upgrades a flux file from a previous version of this software.", },
{ "read", mainRead, "Reads a disk, producing a sector image.", },
{ "write", mainWrite, "Writes a sector image to a disk.", },
{ "writeflux", mainWriteFlux, "Writes a raw flux file. Warning: you can't use this to copy disks.", },
{ "writetestpattern", mainWriteTestPattern, "Writes a machine-generated test pattern to a disk.", },
Expand Down Expand Up @@ -75,26 +80,33 @@ static std::vector<Command> writeables =
{ "brother", mainWriteBrother, "Writes 120kB and 240kB Brother word processor disks.", },
};

static void readWriteHelp(std::vector<Command>& subcommands, const std::string& command)
static std::vector<Command> convertables =
{
{ "cwftoflux", mainConvertCwfToFlux, "Converts CatWeasel stream files to flux.", },
{ "fluxtoau", mainConvertFluxToAu, "Converts (one track of a) flux file to an .au audio file.", },
{ "fluxtovcd", mainConvertFluxToVcd, "Converts (one track of a) flux file to a VCD file.", },
};

static void extendedHelp(std::vector<Command>& subcommands, const std::string& command)
{
std::cout << "fluxengine: syntax: fluxengine " << command << " <format> [<flags>...]\n"
"These formats are supported:\n";
"These subcommands are supported:\n";

for (Command& c : subcommands)
std::cout << " " << c.name << ": " << c.help << "\n";

exit(0);
}

static int mainReadWrite(std::vector<Command>& subcommands, const std::string& command,
static int mainExtended(std::vector<Command>& subcommands, const std::string& command,
int argc, const char* argv[])
{
if (argc == 1)
readWriteHelp(subcommands, command);
extendedHelp(subcommands, command);

std::string format = argv[1];
if (format == "--help")
readWriteHelp(subcommands, command);
extendedHelp(subcommands, command);

for (Command& c : subcommands)
{
Expand All @@ -107,10 +119,13 @@ static int mainReadWrite(std::vector<Command>& subcommands, const std::string& c
}

static int mainRead(int argc, const char* argv[])
{ return mainReadWrite(readables, "read", argc, argv); }
{ return mainExtended(readables, "read", argc, argv); }

static int mainWrite(int argc, const char* argv[])
{ return mainReadWrite(writeables, "write", argc, argv); }
{ return mainExtended(writeables, "write", argc, argv); }

static int mainConvert(int argc, const char* argv[])
{ return mainExtended(convertables, "convert", argc, argv); }

static void help()
{
Expand Down

0 comments on commit 6959d18

Please sign in to comment.