diff --git a/build.py b/build.py index d862396b..f017100e 100644 --- a/build.py +++ b/build.py @@ -12,4 +12,8 @@ clibrary(name="protocol", hdrs={"protocol.h": "./protocol.h"}) proto(name="fl2_proto", srcs=["lib/fl2.proto"]) protocc(name="fl2_proto_lib", srcs=["+fl2_proto"]) -export(name="all", items={"fluxengine": "src+fluxengine"}, deps=["+protocol"]) +export( + name="all", + items={"fluxengine": "src+fluxengine", "fluxengine-gui": "src/gui"}, + deps=["+protocol"], +) diff --git a/build/utils.py b/build/utils.py new file mode 100644 index 00000000..05283194 --- /dev/null +++ b/build/utils.py @@ -0,0 +1,13 @@ +from build.ab import Rule, normalrule, Target, filenameof +from os.path import basename + + +@Rule +def objectify(self, name, src: Target, symbol): + normalrule( + replaces=self, + ins=[src], + outs=[basename(filenameof(src)) + ".h"], + commands=["xxd -i -n " + symbol + " {ins} > {outs}"], + label="OBJECTIFY", + ) diff --git a/extras/build.py b/extras/build.py new file mode 100644 index 00000000..14c3045e --- /dev/null +++ b/extras/build.py @@ -0,0 +1,14 @@ +from build.utils import objectify +from build.c import clibrary + +icons = ["fluxfile", "hardware", "icon", "imagefile"] + +clibrary( + name="icons", + hdrs={ + f"icons/{n}.h": objectify( + name=n + "_h", src=f"./{n}.png", symbol=f"icon_{n}_png" + ) + for n in icons + }, +) diff --git a/lib/build.py b/lib/build.py index 743d8442..e57e2faf 100644 --- a/lib/build.py +++ b/lib/build.py @@ -117,10 +117,12 @@ clibrary( "lib/imagereader/imagereader.h": "./imagereader/imagereader.h", "lib/imagewriter/imagewriter.h": "./imagewriter/imagewriter.h", "lib/layout.h": "./layout.h", + "lib/logger.h": "./logger.h", "lib/proto.h": "./proto.h", "lib/readerwriter.h": "./readerwriter.h", "lib/sector.h": "./sector.h", "lib/usb/usb.h": "./usb/usb.h", + "lib/usb/usbfinder.h": "./usb/usbfinder.h", "lib/utils.h": "./utils.h", "lib/vfs/sectorinterface.h": "./vfs/sectorinterface.h", "lib/vfs/vfs.h": "./vfs/vfs.h", diff --git a/scripts/build.py b/scripts/build.py new file mode 100644 index 00000000..893bab7a --- /dev/null +++ b/scripts/build.py @@ -0,0 +1,33 @@ +from build.ab import Rule, normalrule, Targets +from build.c import cxxprogram + +encoders = {} + + +@Rule +def protoencode(self, name, srcs: Targets, proto, symbol): + if proto not in encoders: + r = cxxprogram( + name="protoencode_" + proto, + srcs=["scripts/protoencode.cc"], + cflags=["-DPROTO=" + proto], + deps=[ + "lib+config_proto_lib", + "tests+test_proto_lib", + "+protobuf_lib", + "+fmt_lib", + ], + ) + encoders[proto] = r + else: + r = encoders[proto] + r.materialise() + + normalrule( + replaces=self, + ins=srcs, + outs=[f"{name}.cc"], + deps=[r], + commands=["{deps[0]} {ins} {outs} " + symbol], + label="PROTOENCODE", + ) diff --git a/src/formats/build.py b/src/formats/build.py new file mode 100644 index 00000000..ea2937a8 --- /dev/null +++ b/src/formats/build.py @@ -0,0 +1,64 @@ +from build.ab import normalrule +from build.c import clibrary +from scripts.build import protoencode + +formats = [ + "40track_drive", + "acornadfs", + "acorndfs", + "aeslanier", + "agat", + "amiga", + "ampro", + "apple2_drive", + "apple2", + "atarist", + "bk", + "brother", + "commodore", + "eco1", + "epsonpf10", + "f85", + "fb100", + "hplif", + "ibm", + "icl30", + "mac", + "micropolis", + "ms2000", + "mx", + "n88basic", + "northstar", + "psos", + "rolandd20", + "rx50", + "shugart_drive", + "smaky6", + "tids990", + "tiki", + "victor9k", + "zilogmcz", +] + +normalrule( + name="table_cc", + ins=[f"./{name}.textpb" for name in formats], + deps=["scripts/mktable.sh"], + outs=["table.cc"], + commands=[ + "sh scripts/mktable.sh formats " + (" ".join(formats)) + " > {outs}" + ], + label="MKTABLE", +) + +encoded = [ + protoencode( + name=f"{name}_cc", + srcs=[f"./{name}.textpb"], + proto="ConfigProto", + symbol=f"formats_{name}_pb", + ) + for name in formats +] + +clibrary(name="formats", srcs=[".+table_cc"] + encoded) diff --git a/src/gui/build.py b/src/gui/build.py new file mode 100644 index 00000000..011b8942 --- /dev/null +++ b/src/gui/build.py @@ -0,0 +1,57 @@ +from build.ab import emit +from build.c import cxxprogram + +emit( + """ +WX_CONFIG ?= wx-config +ifneq ($(strip $(shell command -v $(WX_CONFIG) >/dev/null 2>&1; echo $$?)),0) +$(error Required binary 'wx-config' not found.) +endif + +WX_CFLAGS := $(shell $(WX_CONFIG) --cxxflags core base adv aui richtext) +WX_LDFLAGS := $(shell $(WX_CONFIG) --libs core base adv aui richtext) +""" +) + +cxxprogram( + name="gui", + srcs=[ + "./browserpanel.cc", + "./customstatusbar.cc", + "./explorerpanel.cc", + "./filesystemmodel.cc", + "./fileviewerwindow.cc", + "./fluxviewercontrol.cc", + "./fluxviewerwindow.cc", + "./histogramviewer.cc", + "./iconbutton.cc", + "./idlepanel.cc", + "./imagerpanel.cc", + "./jobqueue.cc", + "./main.cc", + "./mainwindow.cc", + "./texteditorwindow.cc", + "./textviewerwindow.cc", + "./visualisationcontrol.cc", + "./layout.cpp", + ], + cflags=["$(WX_CFLAGS)"], + ldflags=["$(WX_LDFLAGS)"], + deps=[ + "+fl2_proto_lib", + "+protocol", + "arch", + "dep/adflib", + "dep/fatfs", + "dep/hfsutils", + "dep/libusbp", + "extras+icons", + "lib", + "lib+config_proto_lib", + "src/formats", + "src/gui/drivetypes", + "+z_lib", + "+fmt_lib", + "+protobuf_lib", + ], +) diff --git a/src/gui/drivetypes/build.py b/src/gui/drivetypes/build.py new file mode 100644 index 00000000..9ad17710 --- /dev/null +++ b/src/gui/drivetypes/build.py @@ -0,0 +1,40 @@ +from build.ab import normalrule +from build.c import clibrary +from scripts.build import protoencode + +drivetypes = [ + "35_40", + "35_80", + "525_40M", + "525_40", + "525_80M", + "525_80", + "8_38", + "8_77", + "apple2", +] + +normalrule( + name="drivetypes_cc", + ins=[f"./{name}.textpb" for name in drivetypes], + deps=["scripts/mktable.sh"], + outs=["table.cc"], + commands=[ + "sh scripts/mktable.sh drivetypes " + + (" ".join(drivetypes)) + + " > {outs}" + ], + label="MKTABLE", +) + +encoded = [ + protoencode( + name=f"{name}_cc", + srcs=[f"./{name}.textpb"], + proto="ConfigProto", + symbol=f"drivetypes_{name}_pb", + ) + for name in drivetypes +] + +clibrary(name="drivetypes", srcs=[".+drivetypes_cc"] + encoded) diff --git a/src/gui/explorerpanel.cc b/src/gui/explorerpanel.cc index 1275537d..c3b7e8c6 100644 --- a/src/gui/explorerpanel.cc +++ b/src/gui/explorerpanel.cc @@ -4,7 +4,7 @@ #include "lib/decoders/decoders.h" #include "lib/proto.h" #include "gui.h" -#include "lib/layout.h" +#include "layout.h" #include "jobqueue.h" static Bytes fakeBits(const std::vector& bits) diff --git a/src/gui/fileviewerwindow.h b/src/gui/fileviewerwindow.h index a5dce046..7de91268 100644 --- a/src/gui/fileviewerwindow.h +++ b/src/gui/fileviewerwindow.h @@ -1,7 +1,7 @@ #ifndef FILEVIEWERWINDOW_H #define FILEVIEWERWINDOW_H -#include "lib/layout.h" +#include "layout.h" class FileViewerWindow : public FileViewerWindowGen { diff --git a/src/gui/fluxviewerwindow.h b/src/gui/fluxviewerwindow.h index 9416fa9d..61c39df2 100644 --- a/src/gui/fluxviewerwindow.h +++ b/src/gui/fluxviewerwindow.h @@ -1,7 +1,7 @@ #ifndef FLUXVIEWERWINDOW_H #define FLUXVIEWERWINDOW_H -#include "lib/layout.h" +#include "layout.h" class TrackFlux; diff --git a/src/gui/idlepanel.cc b/src/gui/idlepanel.cc index bbaa67fb..e4f5f3dd 100644 --- a/src/gui/idlepanel.cc +++ b/src/gui/idlepanel.cc @@ -16,9 +16,9 @@ #include #include #include -#include ".obj/extras/hardware.h" -#include ".obj/extras/fluxfile.h" -#include ".obj/extras/imagefile.h" +#include "icons/hardware.h" +#include "icons/fluxfile.h" +#include "icons/imagefile.h" #define CONFIG_SELECTEDSOURCE "SelectedSource" #define CONFIG_DEVICE "Device" @@ -103,11 +103,11 @@ public: parent->AddPage(this, "idle"); _imageList.Add( - createBitmap(extras_hardware_png, sizeof(extras_hardware_png))); + createBitmap(icon_hardware_png, sizeof(icon_hardware_png))); _imageList.Add( - createBitmap(extras_fluxfile_png, sizeof(extras_fluxfile_png))); + createBitmap(icon_fluxfile_png, sizeof(icon_fluxfile_png))); _imageList.Add( - createBitmap(extras_imagefile_png, sizeof(extras_imagefile_png))); + createBitmap(icon_imagefile_png, sizeof(icon_imagefile_png))); UpdateSources(); } diff --git a/src/gui/layout.cpp b/src/gui/layout.cpp index 06d58d68..e8d495d9 100644 --- a/src/gui/layout.cpp +++ b/src/gui/layout.cpp @@ -5,7 +5,7 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "lib/layout.h" +#include "layout.h" #include "icon.png.h" diff --git a/src/gui/texteditorwindow.h b/src/gui/texteditorwindow.h index 4f990881..f150cb36 100644 --- a/src/gui/texteditorwindow.h +++ b/src/gui/texteditorwindow.h @@ -1,7 +1,7 @@ #ifndef TEXTEDITORWINDOW_H #define TEXTEDITORWINDOW_H -#include "lib/layout.h" +#include "layout.h" class EditorSaveEvent : public wxEvent { diff --git a/src/gui/textviewerwindow.h b/src/gui/textviewerwindow.h index e03d6c58..ee2624fc 100644 --- a/src/gui/textviewerwindow.h +++ b/src/gui/textviewerwindow.h @@ -1,7 +1,7 @@ #ifndef TEXTVIEWERWINDOW_H #define TEXTVIEWERWINDOW_H -#include "lib/layout.h" +#include "layout.h" class TextViewerWindow : public TextViewerWindowGen { diff --git a/tests/build.py b/tests/build.py new file mode 100644 index 00000000..e39ebca7 --- /dev/null +++ b/tests/build.py @@ -0,0 +1,16 @@ +from build.c import clibrary +from build.protobuf import proto, protocc + + +proto( + name="test_proto", + srcs=[ + "./testproto.proto", + ], +) + +protocc( + name="test_proto_lib", + srcs=[".+test_proto"], + deps=["lib+config_proto", "arch+arch_proto"], +)