SubDir TOP hog-services broker ;
#### Compilation: broker_server (and unit test) ####
SetupHeadersHoG ;
SEARCH_SOURCE += $(SUBDIR)/../indexer ; # for BufIO.*
# We want to link against libc.lib.so but NOT against haiku.lib.so (we don't use/need Haiku code, and more importantly, we must avoid self-deadlock complications : Haiku's glue code would attempt to synchronously reach the Broker from within the Broker, oops)
PosixExecutable broker_server :
broker_server.cpp
BufIO.cpp # ! ///maybe move that .cpp to a sibling folder named e.g. "_common/" ?
;
# Build unit-test as a normal Haiku app
Application _test_client :
_test_client.cpp
;
############### Test Scénario: hog-broker.run #################
#AddInteractiveComponents hog-broker.run ;
# Optim/scale down to "minimum plus" (disable vesa_fb etc), so as to shave a second of build time:
AddMinimumComponents hog-broker.run ;
local libs_list =
haiku.lib.so
libc.lib.so
libm.lib.so
stdcxx.lib.so
vfs.lib.so
vfs_pipe.lib.so # !
zlib.lib.so
;
AddRawComponent hog-broker.run : $(libs_list) : $(libs_list) ;
# VFS server that 'connects' the broker_server and clients:
AddComponentService
hog-broker.run : 4M : vfs : File_system : "
\ <config>
\ <vfs>
\ <dir name=\"dev\">
\ <log/>
\ </dir>
\ <!-- Pipes are at top-level, so that clients invoking "fs" from /dev will see these as /dev/bro2app/... -->
\ <!-- We use many-dirs-holding-one-pipe-each, so that the directory can be readdir()ed (discovered) by Broker (for some reason, one-pipe-with-many-fifos cannot be discovered, so Broker would have to hardcode the paths) -->
# <dir name=\"bro2app\">
# <pipe>
# <fifo name=\"1\"/> <!-- write_port() of data and flattened BMessages: the second leg of the journey (from broker to recipient application) goes through those unix pipes instead of RPC calls -->
# <fifo name=\"2\"/>
# </pipe>
# </dir>
\ <dir name=\"export\">
\ <dir name=\"bro2app\">
\ <dir name=\"1\"> <pipe> <fifo name=\"pipe\"/> </pipe> </dir>
\ <dir name=\"2\"> <pipe> <fifo name=\"pipe\"/> </pipe> </dir>
\ <dir name=\"3\"> <pipe> <fifo name=\"pipe\"/> </pipe> </dir>
\ </dir>
\ </dir>
\ </vfs>
# <policy label="fifo-pipe-test -> in" root="/.upstream/in" writeable="yes" /> .....
\ <default-policy root=\"/export\" writeable=\"yes\"/>
\ </config>
"
;
# Broker:
AddComponentService
hog-broker.run : 4M : broker_server : Hai_Broker : "
\ <config>
\ <libc rtc=\"/dev/rtc\" stdin=\"/dev/null\" stdout=\"/dev/log\" stderr=\"/dev/log\"/>
\ <vfs>
\ <dir name=\"dev\">
\ <log/>
\ <null/>
\
\ <!-- VFS server's named pipes: /dev/bro2app/1/pipe and so on -->
\ <fs/> <!-- fs label=\"downstream\"/ -->
\ </dir>
\ </vfs>
\ </config>
"
;
# Registrar (leverages Broker):
#
#AddPosixApp hog-broker.run : 11M : 85 : registrar ;
#refactor registrar & test_client into this instead:
#
AddComponentClient hog-broker.run
: 27M
: _test_client registrar # !
: "
\ <config ld_verbose=\"yes\">
\ <!-- setup anon pipes at /pipe: -->
\ <libc pipe=\"/pipe\" rtc=\"/dev/rtc\" stdin=\"/dev/null\" stdout=\"/dev/log\" stderr=\"/dev/log\"/>
\ <vfs>
\ <dir name=\"dev\">
\ <log/>
\ <null/>
<fs label=\"downstream\"/>
\ </dir>
<dir name=\"pipe\"> <pipe/> </dir> <!-- for anon (fork/exec) pipes at /pipe/new etc -->
\ </vfs>
\ <!-- Routing: no need to route 'Gui' service as no BApplication is instantiated in test_client (what about registrar?) -->
\ </config>
"
;
RunQemu
hog-broker.run
;