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
This commit is contained in:
Thomas Martitz 2012-07-31 10:33:27 +02:00
parent b358bcfc25
commit efe73e143a
10 changed files with 62 additions and 64 deletions

View file

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

View file

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

View file

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

View file

@ -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_ */

View file

@ -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 */

View file

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

10
tools/configure vendored
View file

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

View file

@ -2,26 +2,37 @@
#include <stdbool.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#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"

View file

@ -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,9 +20,12 @@ 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 \
OTHER_SRC += $(DATABASE_SRC)
INCLUDES += -I$(ROOTDIR)/apps/gui \
-I$(ROOTDIR)/firmware/export \
-I$(ROOTDIR)/firmware/include \
-I$(ROOTDIR)/apps \
@ -32,33 +34,11 @@ INCLUDES = -I$(ROOTDIR)/apps/gui \
-I$(ROOTDIR)/lib/rbcodec/metadata \
-I$(ROOTDIR)/lib/rbcodec/dsp \
-I$(APPSDIR) \
-I$(BUILDDIR) \
-I$(BUILDDIR)
SIMINCLUDES += -I$(FIRMDIR)/target/hosted/sdl -I$(FIRMDIR)/target/hosted \
-I$(ROOTDIR)/uisimulator/common -I$(FIRMDIR)/export -I$(BUILDDIR) -I$(APPSDIR)
# 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 $@ $+

View file

@ -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 */