summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2014-11-13 23:39:54 +0000
committerrandomdan <randomdan@localhost>2014-11-13 23:39:54 +0000
commit4ab586b9b2b009cf01d74029066e2a5cd1652781 (patch)
tree23888c87144aba426b8806a3e1f99060cf489102
parentFix quirk (from glibc update?) around fields in struct tm and the _BSD_SOURCE... (diff)
downloadp2pvr-4ab586b9b2b009cf01d74029066e2a5cd1652781.tar.bz2
p2pvr-4ab586b9b2b009cf01d74029066e2a5cd1652781.tar.xz
p2pvr-4ab586b9b2b009cf01d74029066e2a5cd1652781.zip
Scattering of fixes to remove hacks around paths and fix running the build from folders other than the project root
-rw-r--r--libtmdb/Jamfile.jam3
-rw-r--r--libtmdb/testModels.cpp10
-rw-r--r--p2pvr/Jamfile.jam51
-rw-r--r--p2pvr/daemon/Jamfile.jam16
-rw-r--r--p2pvr/daemon/recordings.cpp10
-rw-r--r--p2pvr/daemon/schedules.cpp16
-rw-r--r--p2pvr/daemon/si.cpp18
-rw-r--r--p2pvr/daemon/test/dummySelect.sql1
-rw-r--r--p2pvr/daemon/testEmbedding.cpp14
-rw-r--r--p2pvr/lib/resources.h7
10 files changed, 92 insertions, 54 deletions
diff --git a/libtmdb/Jamfile.jam b/libtmdb/Jamfile.jam
index 8b6d246..bbdb3b6 100644
--- a/libtmdb/Jamfile.jam
+++ b/libtmdb/Jamfile.jam
@@ -34,9 +34,12 @@ lib tmdb :
<library>pthread
;
+path-constant me : . ;
+
unit-test testModels :
[ glob testModels.cpp ]
:
+ <define>ROOT=\"$(me)\"
<define>BOOST_TEST_DYN_LINK
<library>boost_utf
<library>tmdb
diff --git a/libtmdb/testModels.cpp b/libtmdb/testModels.cpp
index fe2dbab..fac4e65 100644
--- a/libtmdb/testModels.cpp
+++ b/libtmdb/testModels.cpp
@@ -14,9 +14,13 @@ namespace std {
}
};
+#define XSTR(s) STR(s)
+#define STR(s) #s
+const boost::filesystem::path root(XSTR(ROOT));
+
BOOST_AUTO_TEST_CASE( deserialize_searchmulti_json )
{
- auto results = Slicer::Deserialize<Slicer::JsonFileDeserializer, TMDb::SearchMultiResults>("samples/searchMulti_breakingBad.json");
+ auto results = Slicer::Deserialize<Slicer::JsonFileDeserializer, TMDb::SearchMultiResults>((root / "samples" / "searchMulti_breakingBad.json").string());
BOOST_REQUIRE_EQUAL(1, results->Page);
BOOST_REQUIRE_EQUAL(1, results->TotalPages);
BOOST_REQUIRE_EQUAL(3, results->TotalResults);
@@ -41,7 +45,7 @@ BOOST_AUTO_TEST_CASE( deserialize_searchmulti_json )
BOOST_AUTO_TEST_CASE( deserialize_movie_json )
{
- auto movie = Slicer::Deserialize<Slicer::JsonFileDeserializer, TMDb::Movie>("samples/movie_550.json");
+ auto movie = Slicer::Deserialize<Slicer::JsonFileDeserializer, TMDb::Movie>((root / "samples" / "movie_550.json").string());
BOOST_REQUIRE_EQUAL(550, movie->Id);
BOOST_REQUIRE_EQUAL(false, movie->Adult);
BOOST_REQUIRE_EQUAL("/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg", movie->BackdropPath);
@@ -76,7 +80,7 @@ BOOST_AUTO_TEST_CASE( deserialize_movie_json )
BOOST_AUTO_TEST_CASE( deserialize_tvseries_json )
{
- auto tvSeries = Slicer::Deserialize<Slicer::JsonFileDeserializer, TMDb::TvSeries>("samples/tv_1396.json");
+ auto tvSeries = Slicer::Deserialize<Slicer::JsonFileDeserializer, TMDb::TvSeries>((root / "samples" / "tv_1396.json").string());
BOOST_REQUIRE_EQUAL("/sIJyCJedGlZf1TId41gCtkblBGo.jpg", tvSeries->BackdropPath);
BOOST_REQUIRE_EQUAL(1, tvSeries->CreatedBy.size());
BOOST_REQUIRE_EQUAL(66633, tvSeries->CreatedBy.front().Id);
diff --git a/p2pvr/Jamfile.jam b/p2pvr/Jamfile.jam
index 4644151..6851a3c 100644
--- a/p2pvr/Jamfile.jam
+++ b/p2pvr/Jamfile.jam
@@ -1,4 +1,6 @@
import package ;
+import type ;
+import generators ;
alias glibmm : : : :
<cflags>"`pkg-config --cflags glibmm-2.4`"
@@ -39,31 +41,28 @@ build-project carddaemon ;
install debuginstall : p2comp//p2pvrp2comp dvb//p2pvrdvb devices//p2pvrdevices lib//p2pvrlib carddaemon//p2pvrcarddaemon daemonbase//p2pvrdaemonbase daemon//p2pvrdaemon ice//p2pvrice ../libtmdb//tmdb : <location>./testing ;
package.install install : : : p2comp carddaemon daemon ;
-import type ;
-import generators ;
-import feature ;
-import "class" : new ;
type.register SQL : sql ;
-class sql-generator : generator
-{
- import "class" : new ;
- rule __init__ ( * : * )
- {
- generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
- }
- rule run ( project name ? : property-set : sources * )
- {
- return [ generator.run $(project) $(name) : $(property-set) : $(sources) ] ;
- }
- rule generated-targets ( sources + : property-set : project name ? )
- {
- return [ generator.generated-targets $(sources) : $(property-set) : $(project) $(name) ] ;
- }
-}
-generators.register [ new sql-generator sql.sql2o : SQL : OBJ ] ;
-actions sql.sql2o
+
+generators.register-standard sql.embed.asm : SQL : ASM ;
+
+actions sql.embed.asm
{
- ld -r -b binary -o $(1) $(2)
- objcopy --add-section .note.GNU-stack=/dev/null $(1) $(1)
-}
-IMPORT $(__name__) : sql.sql2o : : sql.sql2o ;
+ echo ".section .rodata
+ .global sql_$(2:B)_start
+ .type sql_$(2:B)_start, @object
+sql_$(2:B)_start:
+ .incbin \"$(2)\"
+
+ .global sql_$(2:B)_end
+ .type sql_$(2:B)_end, @object
+sql_$(2:B)_end:
+ .byte 0
+
+ .global sql_$(2:B)_len
+ .type sql_$(2:B)_len, @object
+sql_$(2:B)_len:
+ .int sql_$(2:B)_end - sql_$(2:B)_start" > $(1)
+}
+
+IMPORT $(__name__) : sql.embed.asm : : sql.embed.asm ;
+
diff --git a/p2pvr/daemon/Jamfile.jam b/p2pvr/daemon/Jamfile.jam
index 96f60cb..38e14f4 100644
--- a/p2pvr/daemon/Jamfile.jam
+++ b/p2pvr/daemon/Jamfile.jam
@@ -1,3 +1,5 @@
+import testing ;
+
cpp-pch pch : pch.hpp :
<library>../ice//p2pvrice
<library>../lib//p2pvrlib
@@ -7,9 +9,11 @@ cpp-pch pch : pch.hpp :
<library>../daemonbase//p2pvrdaemonbase
;
+lib boost_utf : : <name>boost_unit_test_framework ;
+
lib p2pvrdaemon :
pch
- [ glob-tree *.cpp *.sql ]
+ [ glob-tree *.cpp *.sql : dummy* test*.cpp ]
:
<library>../ice//p2pvrice
<library>../lib//p2pvrlib
@@ -20,3 +24,13 @@ lib p2pvrdaemon :
<library>../daemonbase//p2pvrdaemonbase
<implicit-dependency>../../libtmdb//tmdb
;
+
+unit-test testEmbedding :
+ testEmbedding.cpp
+ test/dummySelect.sql
+ :
+ <define>BOOST_TEST_DYN_LINK
+ <library>boost_utf
+ <library>../lib//p2pvrlib
+ ;
+
diff --git a/p2pvr/daemon/recordings.cpp b/p2pvr/daemon/recordings.cpp
index bad8032..73cf77d 100644
--- a/p2pvr/daemon/recordings.cpp
+++ b/p2pvr/daemon/recordings.cpp
@@ -5,11 +5,11 @@
#include <logger.h>
#include "sqlContainerCreator.h"
-ResourceString(Recording_Insert, daemon_sql_Recordings_insert_sql);
-ResourceString(Recording_InsertNewId, daemon_sql_Recordings_insertNewId_sql);
-ResourceString(Recording_Delete, daemon_sql_Recordings_delete_sql);
-ResourceString(Recording_GetStorage, daemon_sql_Recordings_getStorage_sql);
-ResourceString(Recording_GetAll, daemon_sql_Recordings_getAll_sql);
+ResourceString(Recording_Insert, sql_Recordings_insert);
+ResourceString(Recording_InsertNewId, sql_Recordings_insertNewId);
+ResourceString(Recording_Delete, sql_Recordings_delete);
+ResourceString(Recording_GetStorage, sql_Recordings_getStorage);
+ResourceString(Recording_GetAll, sql_Recordings_getAll);
template<>
void
diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp
index 90df59c..dab3917 100644
--- a/p2pvr/daemon/schedules.cpp
+++ b/p2pvr/daemon/schedules.cpp
@@ -12,14 +12,14 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include <instanceStore.impl.h>
-ResourceString(Schedules_GetCandidates, daemon_sql_Schedules_GetCandidates_sql);
-ResourceString(Schedules_insert, daemon_sql_Schedules_insert_sql);
-ResourceString(Schedules_insertNewId, daemon_sql_Schedules_insertNewId_sql);
-ResourceString(Schedules_update, daemon_sql_Schedules_update_sql);
-ResourceString(Schedules_delete, daemon_sql_Schedules_delete_sql);
-ResourceString(Schedules_selectAll, daemon_sql_Schedules_selectAll_sql);
-ResourceString(Schedules_selectById, daemon_sql_Schedules_selectById_sql);
-ResourceString(Schedules_scheduledToRecord, daemon_sql_Schedules_scheduledToRecord_sql);
+ResourceString(Schedules_GetCandidates, sql_Schedules_GetCandidates);
+ResourceString(Schedules_insert, sql_Schedules_insert);
+ResourceString(Schedules_insertNewId, sql_Schedules_insertNewId);
+ResourceString(Schedules_update, sql_Schedules_update);
+ResourceString(Schedules_delete, sql_Schedules_delete);
+ResourceString(Schedules_selectAll, sql_Schedules_selectAll);
+ResourceString(Schedules_selectById, sql_Schedules_selectById);
+ResourceString(Schedules_scheduledToRecord, sql_Schedules_scheduledToRecord);
std::string Schedules::SchedulerAlgorithm;
diff --git a/p2pvr/daemon/si.cpp b/p2pvr/daemon/si.cpp
index 9bda6c4..3259888 100644
--- a/p2pvr/daemon/si.cpp
+++ b/p2pvr/daemon/si.cpp
@@ -6,15 +6,15 @@
#include <linux/dvb/frontend.h>
#include <logger.h>
-ResourceString(SI_serviceNextUsed, daemon_sql_SI_serviceNextUsed_sql);
-ResourceString(SI_servicesSelectAll, daemon_sql_SI_servicesSelectAll_sql);
-ResourceString(SI_servicesSelectById, daemon_sql_SI_servicesSelectById_sql);
-ResourceString(SI_eventById, daemon_sql_SI_eventById_sql);
-ResourceString(SI_eventsOnNow, daemon_sql_SI_eventsOnNow_sql);
-ResourceString(SI_eventsInSchedule, daemon_sql_SI_eventsInSchedule_sql);
-ResourceString(SI_eventsInSchedules, daemon_sql_SI_eventsInSchedules_sql);
-ResourceString(SI_eventsInRange, daemon_sql_SI_eventsInRange_sql);
-ResourceString(SI_eventSearch, daemon_sql_SI_eventSearch_sql);
+ResourceString(SI_serviceNextUsed, sql_SI_serviceNextUsed);
+ResourceString(SI_servicesSelectAll, sql_SI_servicesSelectAll);
+ResourceString(SI_servicesSelectById, sql_SI_servicesSelectById);
+ResourceString(SI_eventById, sql_SI_eventById);
+ResourceString(SI_eventsOnNow, sql_SI_eventsOnNow);
+ResourceString(SI_eventsInSchedule, sql_SI_eventsInSchedule);
+ResourceString(SI_eventsInSchedules, sql_SI_eventsInSchedules);
+ResourceString(SI_eventsInRange, sql_SI_eventsInRange);
+ResourceString(SI_eventSearch, sql_SI_eventSearch);
P2PVR::Deliveries
SI::GetAllDeliveries(short type, const Ice::Current &)
diff --git a/p2pvr/daemon/test/dummySelect.sql b/p2pvr/daemon/test/dummySelect.sql
new file mode 100644
index 0000000..3f9397b
--- /dev/null
+++ b/p2pvr/daemon/test/dummySelect.sql
@@ -0,0 +1 @@
+SELECT stuff FROM things
diff --git a/p2pvr/daemon/testEmbedding.cpp b/p2pvr/daemon/testEmbedding.cpp
new file mode 100644
index 0000000..b0e01f1
--- /dev/null
+++ b/p2pvr/daemon/testEmbedding.cpp
@@ -0,0 +1,14 @@
+#define BOOST_TEST_MODULE embedding
+#include <boost/test/unit_test.hpp>
+
+#include "resources.h"
+
+ResourceString(DummySql, sql_dummySelect);
+
+BOOST_AUTO_TEST_CASE( embed )
+{
+ BOOST_REQUIRE_EQUAL(25, DummySql.length());
+ BOOST_REQUIRE_EQUAL(sql_dummySelect_len, DummySql.length());
+ BOOST_REQUIRE_EQUAL("SELECT stuff FROM things\n", DummySql);
+}
+
diff --git a/p2pvr/lib/resources.h b/p2pvr/lib/resources.h
index 301ad4b..18b1de2 100644
--- a/p2pvr/lib/resources.h
+++ b/p2pvr/lib/resources.h
@@ -2,8 +2,11 @@
#define RESOURCES_H
#define ResourceString(name, resource) \
-extern "C" { extern char _binary_##resource##_start, _binary_##resource##_end; } \
-static const std::string name(&_binary_##resource##_start, &_binary_##resource##_end);
+extern "C" { \
+ extern char resource##_start, resource##_end;\
+ extern unsigned int resource##_len; \
+} \
+static const std::string name(&resource##_start, &resource##_end);
#endif