From efe73e143ad8997a791b895c9ee21a68b6570429 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Tue, 31 Jul 2012 10:33:27 +0200 Subject: Fix database tool. It was also broken functionally, probably since a while.So restore the functionality. Run it on the dap, the tcd files will be placed into .rockbox folder. Change-Id: Id7a6ce4389dfaf99799258902be80d630af0601c --- apps/tagcache.c | 14 ++++++++++-- apps/tagcache.h | 6 ++--- firmware/common/filefuncs.c | 2 +- firmware/export/filefuncs.h | 3 +-- firmware/export/rbpaths.h | 4 ---- firmware/include/file.h | 2 +- tools/configure | 10 ++++---- tools/database/database.c | 29 ++++++++++++++++-------- tools/database/database.make | 54 ++++++++++++++------------------------------ uisimulator/common/io.c | 2 +- 10 files changed, 62 insertions(+), 64 deletions(-) diff --git a/apps/tagcache.c b/apps/tagcache.c index 1f11f9e49f..7034cacab4 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -822,6 +822,8 @@ static long find_tag(int tag, int idx_id, const struct index_entry *idx) return result; } } +#else + (void)idx_id; #endif return idx->tag_seek[tag]; @@ -3110,7 +3112,10 @@ static bool commit(void) return true; } +#ifndef __PCTOOL__ static int tempbuf_handle; +#endif + static void allocate_tempbuf(void) { /* Yeah, malloc would be really nice now :) */ @@ -4483,8 +4488,11 @@ void tagcache_screensync_enable(bool state) tc_stat.syncscreen = state; } - -static void do_tagcache_build(const char *path[]) +#ifndef __PCTOOL__ +/* this is called by the database tool to not pull in global_settings */ +static +#endif +void do_tagcache_build(const char *path[]) { struct tagcache_header header; bool ret; @@ -4595,6 +4603,7 @@ static void do_tagcache_build(const char *path[]) cpu_boost(false); } +#ifndef __PCTOOL__ void tagcache_build(void) { char *vect[MAX_STATIC_ROOTS + 1]; /* +1 to ensure NULL sentinel */ @@ -4606,6 +4615,7 @@ void tagcache_build(void) do_tagcache_build((const char**)vect); } +#endif #ifdef HAVE_TC_RAMCACHE static void load_ramcache(void) diff --git a/apps/tagcache.h b/apps/tagcache.h index c1d0df9bcd..dbe1c92d39 100644 --- a/apps/tagcache.h +++ b/apps/tagcache.h @@ -203,13 +203,13 @@ struct tagcache_search { #ifdef __PCTOOL__ void tagcache_reverse_scan(void); +/* call this directly instead of tagcache_build in order to not pull + * on global_settings */ +void do_tagcache_build(const char *path[]); #endif const char* tagcache_tag_to_str(int tag); -#ifdef CPU_SH -bool tagcache_is_numeric_tag(int type); -#endif bool tagcache_find_index(struct tagcache_search *tcs, const char *filename); bool tagcache_check_clauses(struct tagcache_search *tcs, struct tagcache_search_clause **clause, int count); diff --git a/firmware/common/filefuncs.c b/firmware/common/filefuncs.c index fd33f3c6f9..f969a011b7 100644 --- a/firmware/common/filefuncs.c +++ b/firmware/common/filefuncs.c @@ -55,6 +55,7 @@ int strip_volume(const char* name, char* namecopy) } #endif /* #ifdef HAVE_MULTIVOLUME */ +#endif /* __PCTOOL__ */ /* Test file existence, using dircache of possible */ bool file_exists(const char *file) { @@ -89,7 +90,6 @@ bool dir_exists(const char *path) return true; } -#endif /* __PCTOOL__ */ #if (CONFIG_PLATFORM & (PLATFORM_NATIVE|PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) struct dirinfo dir_get_info(DIR* parent, struct dirent *entry) diff --git a/firmware/export/filefuncs.h b/firmware/export/filefuncs.h index 3d4e73ad9f..92e97f65b0 100644 --- a/firmware/export/filefuncs.h +++ b/firmware/export/filefuncs.h @@ -31,10 +31,9 @@ int strip_volume(const char* name, char* namecopy); #endif -#ifndef __PCTOOL__ bool file_exists(const char *file); bool dir_exists(const char *path); -#endif + extern struct dirinfo dir_get_info(DIR* parent, struct dirent *entry); #endif /* __INCLUDE_FILEFUNCS_H_ */ diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h index c60ebdf2af..d50f66d72d 100644 --- a/firmware/export/rbpaths.h +++ b/firmware/export/rbpaths.h @@ -30,11 +30,7 @@ /* name of directory where configuration, fonts and other data * files are stored */ #ifdef __PCTOOL__ -#undef ROCKBOX_DIR -#undef ROCKBOX_DIR_LEN #undef WPS_DIR -#define ROCKBOX_DIR "." -#define ROCKBOX_DIR_LEN 1 #else /* ROCKBOX_DIR is now defined in autoconf.h for flexible build types */ diff --git a/firmware/include/file.h b/firmware/include/file.h index 0ff94a8168..4ba9c503b4 100644 --- a/firmware/include/file.h +++ b/firmware/include/file.h @@ -54,7 +54,7 @@ extern int app_rename(const char* path, const char* newname); # define write(x,y,z) sim_write(x,y,z) # define close(x) sim_close(x) # endif -#elif defined(SIMULATOR) +#elif defined(SIMULATOR) || defined(DBTOOL) # define open(x, ...) sim_open(x, __VA_ARGS__) # define creat(x,m) sim_creat(x,m) # define remove(x) sim_remove(x) diff --git a/tools/configure b/tools/configure index b01d505c9a..aa787d3708 100755 --- a/tools/configure +++ b/tools/configure @@ -3530,6 +3530,7 @@ fi toolset=''; t_cpu=''; GCCOPTS=''; + rbdir='.' extradefines="$extradefines -DDEBUG" appsdir='$(ROOTDIR)/tools/checkwps'; output='checkwps.'${modelname}; @@ -3538,10 +3539,8 @@ fi ;; [Dd]) uname=`uname` - simcc "database" + simcc "database-sdl" toolset=''; - t_cpu=''; - GCCOPTS=''; appsdir='$(ROOTDIR)/tools/database'; archosrom=''; @@ -3553,7 +3552,10 @@ fi output='database.'${modelname}; ;; esac - + # architecture, manufacturer and model for the target-tree build + t_cpu="hosted" + t_manufacturer="sdl" + t_model="database" echo "Database tool build selected" ;; [Ww]) diff --git a/tools/database/database.c b/tools/database/database.c index 0f9304eb0a..30f1c39626 100644 --- a/tools/database/database.c +++ b/tools/database/database.c @@ -2,26 +2,37 @@ #include #include +#include #include + +#include "config.h" #include "tagcache.h" +#include "dir.h" + +/* This is meant to be run on the root of the dap. it'll put the db files into + * a .rockbox subdir */ int main(int argc, char **argv) { + (void)argc; + (void)argv; + + errno = 0; + if (mkdir(ROCKBOX_DIR) == -1 && errno != EEXIST) + return 1; + + /* / is actually ., will get translated in io.c + * (with the help of sim_root_dir below */ + const char *paths[] = { "/", NULL }; tagcache_init(); - tagcache_build("."); + do_tagcache_build(paths); tagcache_reverse_scan(); return 0; } -/* stub to avoid including all of apps/misc.c */ -bool file_exists(const char *file) -{ - struct stat s; - if (!stat(file, &s)) - return true; - return false; -} +/* needed for io.c */ +const char *sim_root_dir = "."; /* stubs to avoid including thread-sdl.c */ #include "kernel.h" diff --git a/tools/database/database.make b/tools/database/database.make index 49ad2ff9bc..89a4aa7d85 100644 --- a/tools/database/database.make +++ b/tools/database/database.make @@ -7,8 +7,7 @@ # $Id: checkwps.make 22680 2009-09-11 17:58:17Z gevaerts $ # -DBDEFINES=-g -DDEBUG -D__PCTOOL__ -CFLAGS+=$(DBDEFINES) +GCCOPTS += -g -DDEBUG -D__PCTOOL__ -DDBTOOL createsrc = $(shell cat $(1) > $(3); echo "\#if CONFIG_CODEC == SWCODEC" >> $(3); \ echo $(2) | sed 's/ /\n/g' >> $(3); \ @@ -21,44 +20,25 @@ SRCFILE := $(call createsrc, $(TOOLSDIR)/database/SOURCES, \ $(METADATAS), \ $(TOOLSDIR)/database/SOURCES.build) -SRC= $(call preprocess, $(SRCFILE)) +DATABASE_SRC = $(call preprocess, $(SRCFILE)) +DATABASE_OBJ = $(call c2obj,$(DATABASE_SRC)) -INCLUDES = -I$(ROOTDIR)/apps/gui \ - -I$(ROOTDIR)/firmware/export \ - -I$(ROOTDIR)/firmware/include \ - -I$(ROOTDIR)/apps \ - -I$(ROOTDIR)/apps/recorder \ - -I$(ROOTDIR)/lib/rbcodec \ - -I$(ROOTDIR)/lib/rbcodec/metadata \ - -I$(ROOTDIR)/lib/rbcodec/dsp \ - -I$(APPSDIR) \ - -I$(BUILDDIR) \ +OTHER_SRC += $(DATABASE_SRC) -SIMINCLUDES += -I$(FIRMDIR)/target/hosted/sdl -I$(FIRMDIR)/target/hosted \ - -I$(ROOTDIR)/uisimulator/common -I$(FIRMDIR)/export -I$(BUILDDIR) -I$(APPSDIR) +INCLUDES += -I$(ROOTDIR)/apps/gui \ + -I$(ROOTDIR)/firmware/export \ + -I$(ROOTDIR)/firmware/include \ + -I$(ROOTDIR)/apps \ + -I$(ROOTDIR)/apps/recorder \ + -I$(ROOTDIR)/lib/rbcodec \ + -I$(ROOTDIR)/lib/rbcodec/metadata \ + -I$(ROOTDIR)/lib/rbcodec/dsp \ + -I$(APPSDIR) \ + -I$(BUILDDIR) -# Makes mkdepfile happy -GCCOPTS+=`$(SDLCONFIG) --cflags` -OLDGCCOPTS:=$(GCCOPTS) -GCCOPTS+=-D__PCTOOL__ -fno-builtin $(INCLUDES) $(SIMINCLUDES) - -LIBS=`$(SDLCONFIG) --libs` -lc -ifneq ($(findstring MINGW,$(shell uname)),MINGW) -LIBS += -ldl -endif .SECONDEXPANSION: # $$(OBJ) is not populated until after this -SIMFLAGS += $(SIMINCLUDES) $(DBDEFINES) -DHAVE_CONFIG_H $(OLDGCCOPTS) $(INCLUDES) - -$(BUILDDIR)/$(BINARY): $$(OBJ) - @echo LD $(BINARY) - $(SILENT)$(HOSTCC) $(SIMFLAGS) $(LIBS) -o $@ $+ - -$(BUILDDIR)/tools/database/../../uisimulator/%.o: $(ROOTDIR)/uisimulator/%.c - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(SIMFLAGS) -c $< -o $@ - -$(BUILDDIR)/tools/database/database.o: $(APPSDIR)/database.c - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(SIMFLAGS) -c $< -o $@ +$(BUILDDIR)/$(BINARY): $$(DATABASE_OBJ) + $(call PRINTS,LD $(BINARY)) + $(SILENT)$(HOSTCC) -o $@ $+ diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index bca5c27a17..7538788bd6 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c @@ -282,7 +282,7 @@ static ssize_t io_trigger_and_wait(enum io_dir cmd) return result; } -#if !defined(__PCTOOL__) && !defined(APPLICATION) +#if !defined(APPLICATION) static const char *get_sim_pathname(const char *name) { static char buffer[MAX_PATH]; /* sufficiently big */ -- cgit v1.2.3