diff options
author | Björn Stenberg <bjorn@haxx.se> | 2008-12-15 23:42:19 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2008-12-15 23:42:19 +0000 |
commit | ee46a3d88e8378e58f01ff0d521477ba0b7201fb (patch) | |
tree | ad63d929d4ebb1f762faf838ee9da965cfc0ab0b | |
parent | 9f37f04619feb93a6a5adb36e7db6d7ace3c227c (diff) | |
download | rockbox-ee46a3d88e8378e58f01ff0d521477ba0b7201fb.tar.gz rockbox-ee46a3d88e8378e58f01ff0d521477ba0b7201fb.zip |
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
-rw-r--r-- | apps/metadata.c | 2 | ||||
-rw-r--r-- | apps/tagcache.c | 16 | ||||
-rw-r--r-- | firmware/common/unicode.c | 5 | ||||
-rw-r--r-- | firmware/include/time.h | 7 | ||||
-rw-r--r-- | tools/Makefile | 11 | ||||
-rw-r--r-- | tools/database.c | 14 | ||||
-rw-r--r-- | tools/database/Makefile | 37 | ||||
-rw-r--r-- | tools/database/database.c | 49 | ||||
-rw-r--r-- | uisimulator/common/io.c | 18 |
9 files changed, 122 insertions, 37 deletions
diff --git a/apps/metadata.c b/apps/metadata.c index fa11fa787c..0892fc65fd 100644 --- a/apps/metadata.c +++ b/apps/metadata.c @@ -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) { diff --git a/apps/tagcache.c b/apps/tagcache.c index b6cfcd5ef5..8e14b9ff17 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -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) { diff --git a/firmware/common/unicode.c b/firmware/common/unicode.c index 713a8e70f9..61989e5ab0 100644 --- a/firmware/common/unicode.c +++ b/firmware/common/unicode.c @@ -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] = diff --git a/firmware/include/time.h b/firmware/include/time.h index 9200e82232..9010d99cc2 100644 --- a/firmware/include/time.h +++ b/firmware/include/time.h @@ -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_ */ diff --git a/tools/Makefile b/tools/Makefile index 569a727139..43f53e2569 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -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=\".\" \ diff --git a/tools/database.c b/tools/database.c deleted file mode 100644 index 9f0c620c2a..0000000000 --- a/tools/database.c +++ /dev/null @@ -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; -} - diff --git a/tools/database/Makefile b/tools/database/Makefile new file mode 100644 index 0000000000..01416eca0d --- /dev/null +++ b/tools/database/Makefile @@ -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) diff --git a/tools/database/database.c b/tools/database/database.c new file mode 100644 index 0000000000..a8be48ab4b --- /dev/null +++ b/tools/database/database.c @@ -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; +} + diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index 52df94901b..185e46260c 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c @@ -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 } |