autogen html.qrc before build
Change-Id: Iab3bd34b582281513ca42efda73337a636e6fc36
diff --git a/gui/chronosharegui.cpp b/gui/chronosharegui.cpp
index cc459a5..79d7a62 100644
--- a/gui/chronosharegui.cpp
+++ b/gui/chronosharegui.cpp
@@ -37,8 +37,11 @@
static const string HTTP_SERVER_ADDRESS = "localhost";
static const string HTTP_SERVER_PORT = "9001";
-//static const string DOC_ROOT = ":/html";
+#ifdef _DEBUG
static const string DOC_ROOT = "gui/html";
+#else
+static const string DOC_ROOT = ":/html";
+#endif
static const QString ICON_PICTURE_QSTRING(":/images/friends-group-icon.png");
INIT_LOGGER ("Gui");
diff --git a/gui/html.qrc b/gui/html.qrc
deleted file mode 100644
index 1d8d379..0000000
--- a/gui/html.qrc
+++ /dev/null
@@ -1,14 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>html/index.html</file>
-<!--
- <file>html/jquery.min.js</file>
- <file>html/load.gif</file>
- <file>html/ndn-js.js</file>
- <file>html/content.js</file>
- <file>html/detect.js</file>
- <file>html/style.css</file>
- <file>html/chronoshare.js</file>
--->
- </qresource>
-</RCC>
diff --git a/wscript b/wscript
index 8fd2b02..0120c7f 100644
--- a/wscript
+++ b/wscript
@@ -129,7 +129,33 @@
conf.write_config_header('src/config.h')
+def update_html_qrc(bld):
+ import os
+ from tempfile import NamedTemporaryFile
+ from waflib import Logs
+ try:
+ Logs.pprint('BLUE', '[Pre-build] Generating gui/html.qrc')
+ if os.path.exists('gui/html'):
+ tf = NamedTemporaryFile(delete=False)
+ tf.write('<RCC><qresource prefix="/">\n')
+ for root, dirs, files in os.walk('gui/html'):
+ # get rid of 'gui' at the beginning for each root
+ path = '/'.join(root.split('/')[1:])
+ for filename in files:
+ tf.write('\t<file>{0}/{1}</file>\n'.format(path, filename))
+
+ tf.write('</qresource></RCC>')
+ tf.close()
+ os.rename(tf.name, 'gui/html.qrc')
+
+ else:
+ bld.fatal('Can not find html directory: gui/html does not exist')
+ except os.error as e:
+ bld.fatal('Os exception! Errno: {0}, Error: {1}'.format(e.errno(), e.strerror()))
+
def build (bld):
+ bld.add_pre_fun(update_html_qrc)
+
executor = bld.objects (
target = "executor",
features = ["cxx"],
@@ -205,7 +231,7 @@
target = "ChronoShare",
features = "qt4 cxx cxxprogram",
defines = "WAF",
- source = bld.path.ant_glob(['gui/*.cpp', 'gui/*.cc', 'gui/*.qrc']),
+ source = bld.path.ant_glob(['gui/*.cpp', 'gui/*.cc', 'gui/images.qrc', 'gui/html.qrc']),
includes = "ccnx scheduler executor fs-watcher gui src adhoc server . ",
use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ccnx database chronoshare http_server"
)
@@ -266,3 +292,15 @@
def m_hook(self, node):
"""Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
return self.create_compiled_task('cxx', node)
+
+#from waflib.TaskGen import extension
+#from waflib.Task import Task
+#class RecursiveQrcTask(Task):
+# def run(self):
+# print "inside RecursiveQrcTask: %s" % self.inputs
+#
+#@extension('.qrc')
+#def rec_qrc(self, node):
+# print "inside rec_qc: %s" % node
+# return self.create_task('RecursiveQrcTask', node)
+