SubDir TOP hog-services indexer ;



#########  Compilation: vfs_indexer.lib.so  #########

SetupHeadersHoG ; #/// needed only due to spurious "-include HaikuBuildCompatibility.h" gcc directive; once that is refactored to target only Haiku apps and not pure-genode components, I can remove this...

SubDirHdrs
#	$(GenodeRepos)/world/src/lib/vfs/fuse  # for xattr_mapping.h
	$(HoG_TOP)/ge-drivers/vfs_fuse_ntfs_tts  # for xattr_mapping.h
	;
SubDirHdrs
	$(SUBDIR)/../../haiku-on-genode/sys-libroot/librootbuild-variant  # for fs_attr_extattr.h
	;


SEARCH_SOURCE +=
	"$(SUBDIR)/web.ncf.ca-au829-BeOS/MatchUTF8 v1.4"  # for MatchUTF8.{c,h}
	;


SolibFromObjects vfs_indexer.lib.so :
	# ./
	vfs_indexer.o
	BufIO.o
	IndexStore.o
	SlotIO.o
	SlotItem.o
	# MatchUTF8 v1.4/
	MatchUTF8.o
	;
Library vfs_foo.a :  #xx we shouldn't need to do a 'dummy' call to Library... clean up the build rules
	# ./
	vfs_indexer.cpp
	BufIO.cpp
	IndexStore.cpp
	SlotIO.cpp
	SlotItem.cpp
	# MatchUTF8 v1.4/
	MatchUTF8.c
	;

#///ToDo: it's annoying to have to specify "Library foo..." to force compilation of cpp files (here for vfs plug-in, and for haiku.lib.so too)
# to fix that, find out the culprit and/or create a "GeSharedLibrary" rule from scratch, maybe based on LibraryFromObjects:
#LibraryFromObjects
#	vfs_foo.a : $(objs) ;



###############  Scénario: hog-people.run  #################

AddInteractiveComponents	hog-people.run ;
AddComponentService			hog-people.run : 1M : pc_rtc : Rtc ;

IndexerTest_NTFS_IMAGE =
	/tmp/hog_IndexerTest_disk_image.raw
	;
DiskNtfsBlank
	$(IndexerTest_NTFS_IMAGE)
	;
AddComponentService  hog-people.run
	: 2M
	: ahci  # was: ahci_drv
	: Block
	: "<config>
			<policy label_prefix=\"\" device=\"0\" writeable=\"yes\" />
		</config>
		"
	;

AddRawComponent  hog-people.run : vfs_fuse.lib.so		: vfs_fuse.lib.so ;
AddRawComponent  hog-people.run : vfs_indexer.lib.so	: vfs_indexer.lib.so ;

# VFS server that hosts the NTFS driver:
AddComponentService
	hog-people.run : 12M : vfs : File_system : "
		<config>
			<vfs>
				<dir name=\"dev\">
					<log/>
				</dir>
	\			<block name=\"blockdev\"/>  <!-- ahci driver, exposed as pseudo file '/blockdev' -->
	\			<dir name=\"DataNtfs\">
	\				<fuse block_path=\"/blockdev\"/>  <!-- ntfs-3g driver -->
	\			</dir>
	\			<dir name=\"boot\">
	\				<indexer fs_path=\"/DataNtfs\"/>  <!-- BQuery support on top of ntfs-3g driver -->
	\			</dir>
			</vfs>
			<policy label_prefix=\"\" root=\"/\" writeable=\"yes\"/>
		</config>
		"
	;

#Config_Vfs on hog-people.run = "
#	\		<dir name=\"raw_boot_sans_indexing\">
#	\			<ram/>
#	\		</dir>
#	\		<dir name=\"boot\">
#	\			<indexer fs_path=\"/raw_boot_sans_indexing\"/>"
#	\		</dir>
#	;

# Just use a client FS 'session' that calls the VFS server:
Config_Vfs on hog-people.run = "
		<fs/>
	"
	;
AddPosixApp hog-people.run : 32M : :
	Pulse
	;


#///ToDo-2: ---- use MakeMyDay instead of "People" or even "Pulse"... -------

# 1) ram, or
# 2) 	<block name="sda1"/>  <!-- handles block session to real block device -->

#AddComponentAsStart hog-people.run : 32M
#		: Pulse : "name=\"Pulse\" caps=\"1000\"" : "
#	<config ld_verbose=\"yes\">
#	\	<libc  rtc=\"/dev/rtc\" stdin=\"/dev/null\" stdout=\"/dev/log\" stderr=\"/dev/log\"/>
#	\	<vfs>
#	\		<dir name=\"dev\">
#	\			<rtc/>
#	\			<log/>
#	\			<null/>
#	\		</dir>
#	\		<dir name=\"raw_boot_sans_indexing\">
#	\			<ram/>
#	\		</dir>
#	\		<dir name=\"boot\">
#	\			<indexer fs_path=\"/raw_boot_sans_indexing\"/>
##	\			<ram/>
#	\		</dir>
#	\	</vfs>
#	</config>
#		"
#		;

RunQemu
	hog-people.run : $(IndexerTest_NTFS_IMAGE)  # make Qemu emulate an AHCI device with this image
	;

