summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-07-31 10:33:27 +0200
committerThomas Martitz <kugel@rockbox.org>2012-07-31 10:33:27 +0200
commitefe73e143ad8997a791b895c9ee21a68b6570429 (patch)
treed206dd97632286975a271ea1502f35b56165767f
parentb358bcfc25272cb03dc95809c0c82688943f0f84 (diff)
downloadrockbox-efe73e143ad8997a791b895c9ee21a68b6570429.zip
rockbox-efe73e143ad8997a791b895c9ee21a68b6570429.tar.gz
rockbox-efe73e143ad8997a791b895c9ee21a68b6570429.tar.bz2
rockbox-efe73e143ad8997a791b895c9ee21a68b6570429.tar.xz
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
-rw-r--r--apps/tagcache.c14
-rw-r--r--apps/tagcache.h6
-rw-r--r--firmware/common/filefuncs.c2
-rw-r--r--firmware/export/filefuncs.h3
-rw-r--r--firmware/export/rbpaths.h4
-rw-r--r--firmware/include/file.h2
-rwxr-xr-xtools/configure10
-rw-r--r--tools/database/database.c29
-rw-r--r--tools/database/database.make54
-rw-r--r--uisimulator/common/io.c2
10 files changed, 62 insertions, 64 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 1f11f9e..7034cac 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 c1d0df9..dbe1c92 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 fd33f3c..f969a01 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 3d4e73a..92e97f6 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 c60ebdf..d50f66d 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 0ff94a8..4ba9c50 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 b01d505..aa787d3 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 0f9304e..30f1c39 100644
--- a/tools/database/database.c
+++ b/tools/database/database.c
@@ -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"
diff --git a/tools/database/database.make b/tools/database/database.make
index 49ad2ff..89a4aa7 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 bca5c27..7538788 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 */