From 561df3827e091c5646648a50b94278843a7554aa Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Thu, 4 Sep 2008 14:49:53 +0000 Subject: WPS editor: * Simplify Makefile * Get rid of buildall.* * Change library loading behaviour to work with MODEL_NAME Screenshot: * Simplify Makefile config-*.h: * Add MODEL_NAME git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18407 a1c6a512-1295-4272-9138-f99709370657 --- utils/wpseditor/buildall.bat | 9 --- utils/wpseditor/buildall.sh | 4 -- utils/wpseditor/gui/src/qwpsdrawer.cpp | 27 +++++--- utils/wpseditor/gui/src/qwpsdrawer.h | 8 +++ utils/wpseditor/libwps/Makefile | 113 +++++++++++++++------------------ utils/wpseditor/libwps/buildall.bat | 4 -- utils/wpseditor/libwps/buildall.sh | 9 --- utils/wpseditor/libwps/cleanall.sh | 7 -- utils/wpseditor/libwps/src/proxy.c | 4 +- utils/wpseditor/libwps/targets.txt | 9 --- utils/wpseditor/screenshot/Makefile | 28 ++------ utils/wpseditor/wpseditor.pro | 4 +- 12 files changed, 88 insertions(+), 138 deletions(-) delete mode 100644 utils/wpseditor/buildall.bat delete mode 100755 utils/wpseditor/buildall.sh delete mode 100644 utils/wpseditor/libwps/buildall.bat delete mode 100755 utils/wpseditor/libwps/buildall.sh delete mode 100644 utils/wpseditor/libwps/cleanall.sh delete mode 100644 utils/wpseditor/libwps/targets.txt (limited to 'utils') diff --git a/utils/wpseditor/buildall.bat b/utils/wpseditor/buildall.bat deleted file mode 100644 index b813a38510..0000000000 --- a/utils/wpseditor/buildall.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -echo qmake... -qmake -echo Building gui... -mingw32-make 1>nul -echo Building libs... -cd libwps -call buildall.bat 2>nul -cd .. diff --git a/utils/wpseditor/buildall.sh b/utils/wpseditor/buildall.sh deleted file mode 100755 index c891900813..0000000000 --- a/utils/wpseditor/buildall.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -qmake && make -cd libwps -./buildall.sh 2> /dev/null diff --git a/utils/wpseditor/gui/src/qwpsdrawer.cpp b/utils/wpseditor/gui/src/qwpsdrawer.cpp index a506d5c03b..096d835491 100644 --- a/utils/wpseditor/gui/src/qwpsdrawer.cpp +++ b/utils/wpseditor/gui/src/qwpsdrawer.cpp @@ -17,14 +17,14 @@ QImage QWpsDrawer::backdrop; proxy_api QWpsDrawer::api; QWpsDrawer::QWpsDrawer( QWpsState *ws,QTrackState *ms, QWidget *parent ) - : QWidget(parent),wpsState(ws),trackState(ms),showGrid(false),mCurTarget("h10_5gb") { + : QWidget(parent),wpsState(ws),trackState(ms),showGrid(false),mCurTarget(qApp->applicationDirPath()+"/libwps_IRIVER_H10_5GB") { tryResolve(); newTempWps(); } bool QWpsDrawer::tryResolve() { - QLibrary lib(qApp->applicationDirPath()+"/libwps_"+mCurTarget); + QLibrary lib(mCurTarget); lib_wps_init = (pfwps_init)lib.resolve("wps_init"); lib_wps_display = (pfwps_display)lib.resolve("wps_display"); lib_wps_refresh = (pfwps_refresh)lib.resolve("wps_refresh"); @@ -47,7 +47,7 @@ bool QWpsDrawer::tryResolve() { api.load_wps_backdrop = &QWpsDrawer::load_wps_backdrop; api.read_bmp_file = &QWpsDrawer::read_bmp_file; api.debugf = &qlogger; - qDebug()<<(qApp->applicationDirPath()+"/libwps_"+mCurTarget+" resolved"); + qDebug()<<(mCurTarget+" resolved"); } return mResolved; } @@ -222,7 +222,7 @@ QString QWpsDrawer::getModelName(QString libraryName) { QList QWpsDrawer::getTargets() { QList list ; QDir d = QDir(qApp->applicationDirPath()); - QFileInfoList libs = d.entryInfoList(QStringList("libwps*")); + QFileInfoList libs = d.entryInfoList(QStringList("libwps_*")); qDebug() << libs.size()<<"libs found"; for (int i = 0; i < libs.size(); i++) { QString modelName = getModelName(libs[i].absoluteFilePath()); @@ -230,15 +230,24 @@ QList QWpsDrawer::getTargets() { if (modelName == "unknown") continue; list.append(modelName); + libs_array[i].target_name = modelName; + libs_array[i].lib = libs[i].absoluteFilePath(); } return list; } bool QWpsDrawer::setTarget(QString target) { - QLibrary lib(qApp->applicationDirPath()+"/libwps_"+mCurTarget); - //lib.unload(); - if (getModelName("libwps_"+target)!="unknown") { - mCurTarget = target; - return tryResolve(); + foreach(lib_t cur_lib, libs_array) + { + if(cur_lib.target_name == target) + { + QLibrary lib(cur_lib.lib); + //lib.unload(); + if (getModelName(cur_lib.lib) != "unknown") + { + mCurTarget = cur_lib.lib; + return tryResolve(); + } + } } return false; } diff --git a/utils/wpseditor/gui/src/qwpsdrawer.h b/utils/wpseditor/gui/src/qwpsdrawer.h index 65e98723f5..eec4300286 100644 --- a/utils/wpseditor/gui/src/qwpsdrawer.h +++ b/utils/wpseditor/gui/src/qwpsdrawer.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "wpsstate.h" @@ -37,6 +38,13 @@ class QWpsDrawer : public QWidget { QString mWpsString; QString mCurTarget; static QString mTmpWpsString; + + struct lib_t + { + QString target_name; + QString lib; + }; + QMap libs_array; protected: diff --git a/utils/wpseditor/libwps/Makefile b/utils/wpseditor/libwps/Makefile index c5d0a39de1..879cc8e4db 100644 --- a/utils/wpseditor/libwps/Makefile +++ b/utils/wpseditor/libwps/Makefile @@ -8,15 +8,13 @@ # ROOT=../../.. -OS = w32 -CC = gcc -MKDIR = mkdir -p - -ifeq ($(findstring MINGW,$(shell uname)),MINGW) +ifneq ($or($(findstring MINGW,$(shell uname)),$(findstring Windows_NT,$(OS))),) OS = w32 CC = mingw32-gcc COPY = copy - RM = rm + RM = del + EXT = .dll + LDFLAGS = -DBUILD_DLL endif ifeq ($(findstring Linux,$(shell uname)),Linux) @@ -24,39 +22,48 @@ ifeq ($(findstring Linux,$(shell uname)),Linux) CC = gcc COPY = cp RM = rm -f + EXT = .so + LDFLAGS = -fPIC endif - +TARGETS=IRIVER_H10 \ + IRIVER_H10_5GB \ + IPOD_COLOR \ + IPOD_NANO \ + IPOD_VIDEO \ + GIGABEAT_F \ + GIGABEAT_S \ + SANSA_E200 \ + SANSA_C200 SOURCES= \ - src/api.c \ - src/dummies.c \ - src/lcd.c \ - src/proxy.c \ - $(ROOT)/apps/gui/scrollbar.c \ - $(ROOT)/apps/gui/gwps-common.c \ - $(ROOT)/apps/gui/wps_parser.c \ - $(ROOT)/apps/gui/wps_debug.c \ - $(ROOT)/apps/recorder/peakmeter.c \ - $(ROOT)/apps/recorder/icons.c \ - $(ROOT)/apps/misc.c \ - $(ROOT)/apps/status.c \ - $(ROOT)/firmware/common/ctype.c \ - $(ROOT)/firmware/common/timefuncs.c \ - $(ROOT)/firmware/common/unicode.c \ - $(ROOT)/firmware/font.c \ - $(ROOT)/firmware/font_cache.c \ - $(ROOT)/firmware/id3.c \ - $(ROOT)/firmware/lru.c \ - $(ROOT)/firmware/mp3data.c \ - $(ROOT)/firmware/replaygain.c - -# $(ROOT)/apps/recorder/bmp.c -# $(ROOT)/apps/abrepeat.c \ -# $(ROOT)/apps/action.c \ -# $(ROOT)/apps/cuesheet.c \ -# $(ROOT)/apps/gui/statusbar.c \ -# $(ROOT)/apps/gui/gwps.c \ + src/api.c \ + src/dummies.c \ + src/lcd.c \ + src/proxy.c \ + $(ROOT)/apps/gui/scrollbar.c \ + $(ROOT)/apps/gui/gwps-common.c \ + $(ROOT)/apps/gui/wps_parser.c \ + $(ROOT)/apps/gui/wps_debug.c \ + $(ROOT)/apps/recorder/peakmeter.c \ + $(ROOT)/apps/recorder/icons.c \ + $(ROOT)/apps/misc.c \ + $(ROOT)/apps/status.c \ + $(ROOT)/firmware/common/ctype.c \ + $(ROOT)/firmware/common/timefuncs.c \ + $(ROOT)/firmware/common/unicode.c \ + $(ROOT)/firmware/font.c \ + $(ROOT)/firmware/font_cache.c \ + $(ROOT)/firmware/id3.c \ + $(ROOT)/firmware/lru.c \ + $(ROOT)/firmware/mp3data.c \ + $(ROOT)/firmware/replaygain.c +# $(ROOT)/apps/recorder/bmp.c +# $(ROOT)/apps/abrepeat.c \ +# $(ROOT)/apps/action.c \ +# $(ROOT)/apps/cuesheet.c \ +# $(ROOT)/apps/gui/statusbar.c \ +# $(ROOT)/apps/gui/gwps.c \ INCLUDE=-I src/include \ -I $(ROOT)/apps/gui \ @@ -68,34 +75,14 @@ INCLUDE=-I src/include \ CFLAGS = -g -Wall -D__PCTOOL__ -DWPSEDITOR -DDEBUG -DROCKBOX_DIR_LEN=1 -DBUTTON_REMOTE -all: - @echo To build, run the buildall.sh script - -build: build-$(OS) - -build-w32: $(SOURCES) - @echo CC [$(TARGET)] - @$(CC) $(INCLUDE) $(CFLAGS) -D$(TARGET) -DTARGET_MODEL=\"$(MODEL)\" -DBUILD_DLL $(SOURCES) -shared -o libwps_$(MODEL).dll - -build-linux: $(SOURCES) - @echo CC [$(TARGET)] - @$(CC) $(INCLUDE) $(CFLAGS) -D$(TARGET) -DTARGET_MODEL=\"$(MODEL)\" -shared -Wl,-soname,libwps_$(MODEL).so,-olibwps_$(MODEL).so -fPIC $(SOURCES) - -clean: clean-$(OS) - -clean-w32: - $(RM) "libwps_$(MODEL).dll" - -clean-linux: - $(RM) "libwps_$(MODEL).so" +RESULTS := $(patsubst %,libwps_%$(EXT),$(TARGETS)) -shared: shared-$(OS) +all: $(RESULTS) + @$(COPY) $(RESULTS) ../gui/bin/ -shared-w32: $(SOURCES) - @echo CC [IRIVER_H10_5GB] - @$(CC) $(INCLUDE) $(CFLAGS) -DIRIVER_H10_5GB -DTARGET_MODEL=\"h10_5gb\" -DBUILD_DLL -shared $(SOURCES) -o ../gui/bin/libwps_h10_5gb.dll +libwps_%$(EXT): $(SOURCES) + @echo CC [$(subst libwps_,,$(subst $(EXT),,$@))] + @$(CC) $(INCLUDE) $(CFLAGS) -D$(subst libwps_,,$(subst $(EXT),,$@)) $(LDFLAGS) -shared -o $@ $+ -shared-linux: $(SOURCES) - @echo CC [IRIVER_H10_5GB] - @$(CC) $(INCLUDE) $(CFLAGS) -DIRIVER_H10_5GB -DTARGET_MODEL=\"h10_5gb\" -shared -Wl,-soname,libwps_h10_5gb.so,-olibwps_h10_5gb.so -fPIC $(SOURCES) - @$(COPY) libwps_h10_5gb.so ../gui/bin/libwps_h10_5gb.so +clean: + $(RM) $(RESULTS) diff --git a/utils/wpseditor/libwps/buildall.bat b/utils/wpseditor/libwps/buildall.bat deleted file mode 100644 index fb66b41904..0000000000 --- a/utils/wpseditor/libwps/buildall.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -FOR /F "tokens=1,2* delims=, " %%i in (targets.txt) do @mingw32-make MODEL=%%j TARGET=%%i build 2>nul -echo Copying files... -xcopy /I /Y *.dll ..\gui\bin diff --git a/utils/wpseditor/libwps/buildall.sh b/utils/wpseditor/libwps/buildall.sh deleted file mode 100755 index 0f32bb9b9a..0000000000 --- a/utils/wpseditor/libwps/buildall.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -cat targets.txt | ( - while read target model - do - make MODEL=$model TARGET=$target build - done - cp *.dll ../gui/bin - cp *.so ../gui/bin -) diff --git a/utils/wpseditor/libwps/cleanall.sh b/utils/wpseditor/libwps/cleanall.sh deleted file mode 100644 index 15b733a6a7..0000000000 --- a/utils/wpseditor/libwps/cleanall.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -cat targets.txt | ( - while read target model - do - make MODEL=$model TARGET=$target clean - done -) diff --git a/utils/wpseditor/libwps/src/proxy.c b/utils/wpseditor/libwps/src/proxy.c index 8f9218e3ff..1e4804cd11 100644 --- a/utils/wpseditor/libwps/src/proxy.c +++ b/utils/wpseditor/libwps/src/proxy.c @@ -23,8 +23,8 @@ pfdebugf dbgf = 0; static char pluginbuf[PLUGIN_BUFFER_SIZE]; const char* get_model_name(){ -#ifdef TARGET_MODEL - return TARGET_MODEL; +#ifdef MODEL_NAME + return MODEL_NAME; #else return "unknown"; #endif diff --git a/utils/wpseditor/libwps/targets.txt b/utils/wpseditor/libwps/targets.txt deleted file mode 100644 index 547a2ba42c..0000000000 --- a/utils/wpseditor/libwps/targets.txt +++ /dev/null @@ -1,9 +0,0 @@ -IRIVER_H10 h10 -IRIVER_H10_5GB h10_5gb -IPOD_COLOR ipodcolor -IPOD_NANO ipodnano -IPOD_VIDEO ipodvideo -GIGABEAT_F gigabeatf -GIGABEAT_S gigabeats -SANSA_E200 e200 -SANSA_C200 c200 diff --git a/utils/wpseditor/screenshot/Makefile b/utils/wpseditor/screenshot/Makefile index 18a6de35a5..f9309f58a5 100644 --- a/utils/wpseditor/screenshot/Makefile +++ b/utils/wpseditor/screenshot/Makefile @@ -8,31 +8,17 @@ # ROOT=../../.. -OS = w32 -CC = gcc - -ifeq ($(findstring MINGW,$(shell uname)),MINGW) -OS = w32 -CC = mingw32-gcc -RM = rm -endif - -ifeq ($(findstring Linux,$(shell uname)),Linux) -OS = linux CC = gcc RM = rm -f -endif - - -COMMON= main.c gd_bmp.c +COMMON = main.c gd_bmp.c -INCLUDE=-I ../libwps/src \ - -I $(ROOT)/apps/gui \ - -I $(ROOT)/firmware/export \ - -I $(ROOT)/apps/recorder \ - -I $(ROOT)/apps \ - -I . +INCLUDE = -I ../libwps/src \ + -I $(ROOT)/apps/gui \ + -I $(ROOT)/firmware/export \ + -I $(ROOT)/apps/recorder \ + -I $(ROOT)/apps \ + -I . CFLAGS = -g -Wall diff --git a/utils/wpseditor/wpseditor.pro b/utils/wpseditor/wpseditor.pro index 0e9ecbbf51..df954ed68a 100644 --- a/utils/wpseditor/wpseditor.pro +++ b/utils/wpseditor/wpseditor.pro @@ -1,2 +1,4 @@ -SUBDIRS =gui/src/QPropertyEditor gui TEMPLATE = subdirs +SUBDIRS = gui/src/QPropertyEditor gui libwps +libwps.commands = @$(MAKE) -C libwps +QMAKE_EXTRA_TARGETS += libwps -- cgit v1.2.3