We can now build both the CLI and GUI binaries!

This commit is contained in:
David Given
2023-10-22 21:20:47 +02:00
parent 986be921f4
commit a24fe420c4
16 changed files with 256 additions and 13 deletions

View File

@@ -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"],
)

13
build/utils.py Normal file
View File

@@ -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",
)

14
extras/build.py Normal file
View File

@@ -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
},
)

View File

@@ -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",

33
scripts/build.py Normal file
View File

@@ -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",
)

64
src/formats/build.py Normal file
View File

@@ -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)

57
src/gui/build.py Normal file
View File

@@ -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",
],
)

View File

@@ -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)

View File

@@ -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<bool>& bits)

View File

@@ -1,7 +1,7 @@
#ifndef FILEVIEWERWINDOW_H
#define FILEVIEWERWINDOW_H
#include "lib/layout.h"
#include "layout.h"
class FileViewerWindow : public FileViewerWindowGen
{

View File

@@ -1,7 +1,7 @@
#ifndef FLUXVIEWERWINDOW_H
#define FLUXVIEWERWINDOW_H
#include "lib/layout.h"
#include "layout.h"
class TrackFlux;

View File

@@ -16,9 +16,9 @@
#include <wx/mstream.h>
#include <wx/image.h>
#include <wx/bitmap.h>
#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();
}

View File

@@ -5,7 +5,7 @@
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "lib/layout.h"
#include "layout.h"
#include "icon.png.h"

View File

@@ -1,7 +1,7 @@
#ifndef TEXTEDITORWINDOW_H
#define TEXTEDITORWINDOW_H
#include "lib/layout.h"
#include "layout.h"
class EditorSaveEvent : public wxEvent
{

View File

@@ -1,7 +1,7 @@
#ifndef TEXTVIEWERWINDOW_H
#define TEXTVIEWERWINDOW_H
#include "lib/layout.h"
#include "layout.h"
class TextViewerWindow : public TextViewerWindowGen
{

16
tests/build.py Normal file
View File

@@ -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"],
)