Moved database builder into a separate directory, and gave it its' own Makefile. Now it compiles cleanly and builds a database if ran in root of music tree.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19448 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2008-12-15 23:42:19 +00:00
parent 9f37f04619
commit ee46a3d88e
9 changed files with 122 additions and 37 deletions

View file

@ -397,6 +397,7 @@ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname)
return true;
}
#ifndef __PCTOOL__
#if CONFIG_CODEC == SWCODEC
void strip_tags(int handle_id)
{
@ -434,6 +435,7 @@ void strip_tags(int handle_id)
bufcuttail(handle_id, len);
}
#endif /* CONFIG_CODEC == SWCODEC */
#endif /* ! __PCTOOL__ */
void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig)
{

View file

@ -155,10 +155,12 @@ struct tagcache_command_entry {
int32_t data;
};
#ifndef __PCTOOL__
static struct tagcache_command_entry command_queue[TAGCACHE_COMMAND_QUEUE_LENGTH];
static volatile int command_queue_widx = 0;
static volatile int command_queue_ridx = 0;
static struct mutex command_queue_mutex;
#endif
/* Tag database structures. */
@ -633,6 +635,8 @@ static bool get_index(int masterfd, int idxid,
return true;
}
#ifndef __PCTOOL__
static bool write_index(int masterfd, int idxid, struct index_entry *idx)
{
/* We need to exclude all memory only flags & tags when writing to disk. */
@ -678,6 +682,8 @@ static bool write_index(int masterfd, int idxid, struct index_entry *idx)
return true;
}
#endif /* !__PCTOOL__ */
static bool open_files(struct tagcache_search *tcs, int tag)
{
if (tcs->idxfd[tag] < 0)
@ -2993,6 +2999,8 @@ static void free_tempbuf(void)
tempbuf_size = 0;
}
#ifndef __PCTOOL__
static bool modify_numeric_entry(int masterfd, int idx_id, int tag, long data)
{
struct index_entry idx;
@ -3040,6 +3048,7 @@ static bool command_queue_is_full(void)
return (next == command_queue_ridx);
}
static bool command_queue_sync_callback(void)
{
@ -3152,6 +3161,7 @@ void tagcache_update_numeric(int idx_id, int tag, long data)
{
queue_command(CMD_UPDATE_NUMERIC, idx_id, tag, data);
}
#endif /* !__PCTOOL__ */
long tagcache_get_serial(void)
{
@ -3187,6 +3197,8 @@ static bool write_tag(int fd, const char *tagstr, const char *datastr)
return true;
}
#ifndef __PCTOOL__
static bool read_tag(char *dest, long size,
const char *src, const char *tagstr)
{
@ -3326,7 +3338,6 @@ static int parse_changelog_line(int line_n, const char *buf, void *parameters)
return write_index(masterfd, idx_id, &idx) ? 0 : -5;
}
#ifndef __PCTOOL__
bool tagcache_import_changelog(void)
{
struct master_header myhdr;
@ -3373,7 +3384,8 @@ bool tagcache_import_changelog(void)
return true;
}
#endif
#endif /* !__PCTOOL__ */
bool tagcache_create_changelog(struct tagcache_search *tcs)
{

View file

@ -83,9 +83,8 @@ static const char *name_codepages[NUM_CODEPAGES+1] =
#define MAX_CP_TABLE_SIZE 640
#define NUM_TABLES 1
static const char *filename[NUM_TABLES] =
{
CODEPAGE_DIR"/isomini.cp",
static const char *filename[NUM_TABLES] = {
CODEPAGE_DIR"/isomini.cp"
};
static const char cp_2_table[NUM_CODEPAGES] =

View file

@ -37,6 +37,13 @@ struct tm *localtime(const time_t *timep);
#endif /* SIMULATOR */
#ifdef __PCTOOL__
/* this time.h does not define struct timespec,
so tell sys/stat.h not to use it */
#undef __USE_MISC
#endif
#endif /* _TIME_H_ */

View file

@ -12,7 +12,7 @@ LDFLAGS := -g
.PHONY: rbspeexenc uclpack
CLEANALL := scramble descramble iriver sh2d bmp2rb rdf2binary convbdf \
generate_rocklatin mkboot ipod_fw codepages uclpack mi4 gigabeat database \
generate_rocklatin mkboot ipod_fw codepages uclpack mi4 gigabeat \
lngdump telechips gigabeats creative hmac-sha1 mktccboot mknkboot rbspeexenc mkzenboot
all: scramble descramble sh2d rdf2binary mkboot mktccboot mknkboot mkzenboot \
@ -66,15 +66,6 @@ lngdump: lngdump.c
ipod_fw: ipod_fw.c
$(SILENT)$(CC) $(CFLAGS) $+ -o $@
database: database.c ../apps/tagcache.c ../apps/metadata.c \
../firmware/id3.c ../firmware/common/unicode.c \
../firmware/common/crc32.c ../uisimulator/common/io.c \
../firmware/mp3data.c ../firmware/logf.c ../firmware/replaygain.c \
../firmware/common/structec.c
$(SILENT)$(CC) $(CFLAGS) -I../firmware/export -iquote ../firmware/include \
-D__PCTOOL__ -DHAVE_TAGCACHE -DROCKBOX_HAS_LOGF -DSIMULATOR \
-DCONFIG_CODEC=1 -ldl -I../apps $+ -o $@
checkwps: checkwps.c ../apps/gui/wps_parser.c ../apps/gui/wps_debug.c ../firmware/common/ctype.c ../apps/misc.c ../apps/recorder/bmp.c
$(SILENT)$(CC) $(CFLAGS) -I ../apps/gui -I../firmware/export \
-D__PCTOOL__ -DDEBUG -DROCKBOX_HAS_LOGF -DIPOD_COLOR -D ROCKBOX_DIR_LEN -D WPS_DIR=\".\" \

View file

@ -1,14 +0,0 @@
/* A _very_ skeleton file to demonstrate building tagcache db on host. */
#include <stdio.h>
#include "tagcache.h"
int main(int argc, char **argv)
{
tagcache_init();
tagcache_build("/export/stuff/mp3");
tagcache_reverse_scan();
return 0;
}

37
tools/database/Makefile Normal file
View file

@ -0,0 +1,37 @@
INCLUDE = -I../../firmware/export \
-I../../apps -I../../uisimulator/sdl -I/usr/include/SDL
FIRMINC = -I../../firmware/include -fno-builtin
DEFINES = -D__PCTOOL__ -DHAVE_TAGCACHE -DSIMULATOR -DCONFIG_CODEC=1 \
-DROCKBOX_LITTLE_ENDIAN -DROCKBOX_DIR=\".rockbox\" -DROCKBOX_HAS_LOGF \
-DCONFIG_CODEC=1
CFLAGS = -g $(INCLUDE) $(DEFINES) -Wno-pointer-sign
SRC = database.o tagcache.o replaygain.o \
metadata.o metadata_common.o mp3data.o \
a52.o mp3.o adx.o mp4.o aiff.o mpc.o ape.o ogg.o \
asap.o sid.o asf.o spc.o flac.o vorbis.o wave.o \
mod.o wavpack.o monkeys.o \
logf.o unicode.o ctype.o structec.o crc32.o io.o
OBJ = $(SRC:.c=.o)
# source code search path
VPATH = ../../apps ../../apps/metadata ../../firmware/common ../../firmware/ \
../../uisimulator/common
all: database
%.o : ../../uisimulator/common/%.c
@echo $(<F)
@$(CC) $(CFLAGS) -c -o $@ $<
%.o : %.c $<
@echo $(<F)
@$(CC) $(FIRMINC) $(CFLAGS) -c -o $@ $<
database: $(OBJ)
@echo Linking $@
@$(CC) -g -ldl -o $@ $+
clean:
rm $(OBJ)

49
tools/database/database.c Normal file
View file

@ -0,0 +1,49 @@
/* A _very_ skeleton file to demonstrate building tagcache db on host. */
#include <stdio.h>
#include "tagcache.h"
int main(int argc, char **argv)
{
tagcache_init();
tagcache_build(".");
tagcache_reverse_scan();
return 0;
}
/* stub to avoid including all of apps/misc.c */
bool file_exists(const char *file)
{
if (!stat(file))
return true;
return false;
}
/* stubs to avoid including thread-sdl.c */
#include "kernel.h"
void mutex_init(struct mutex *m)
{
(void)m;
}
void mutex_lock(struct mutex *m)
{
(void)m;
}
void mutex_unlock(struct mutex *m)
{
(void)m;
}
void thread_sdl_thread_lock(void *me)
{
(void)me;
}
void * thread_sdl_thread_unlock(void)
{
return (void*)1;
}

View file

@ -252,19 +252,22 @@ static ssize_t io_trigger_and_wait(int cmd)
return result;
}
#ifndef __PCTOOL__
static const char *get_sim_rootdir()
{
if (sim_root_dir != NULL)
return sim_root_dir;
return SIMULATOR_DEFAULT_ROOT;
}
#endif
MYDIR *sim_opendir(const char *name)
{
char buffer[MAX_PATH]; /* sufficiently big */
DIR_T *dir;
#ifndef __PCTOOL__
char buffer[MAX_PATH]; /* sufficiently big */
if(name[0] == '/')
{
snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name);
@ -277,7 +280,8 @@ MYDIR *sim_opendir(const char *name)
if(dir) {
MYDIR *my = (MYDIR *)malloc(sizeof(MYDIR));
my->dir = dir;
my->name = (char *)strdup(name);
my->name = (char *)malloc(strlen(name)+1);
strcpy(my->name, name);
return my;
}
@ -357,12 +361,10 @@ int sim_open(const char *name, int o)
name);
return -1;
#else
if (num_openfiles < MAX_OPEN_FILES)
{
ret = OPEN(buffer, opts, 0666);
if (ret >= 0) num_openfiles++;
return ret;
}
ret = OPEN(name, opts, 0666);
if (ret >= 0)
num_openfiles++;
return ret;
#endif
}