summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml5
-rw-r--r--SConstruct1
-rw-r--r--build/depends.py6
-rw-r--r--build/features.py35
-rw-r--r--src/util/battery/battery.cpp6
5 files changed, 46 insertions, 7 deletions
diff --git a/.travis.yml b/.travis.yml
index 6ef8d06092..807f223847 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -42,6 +42,9 @@ before_install:
- export CXX=g++-4.8
- export CC=gcc-4.8
install:
- - scons test=1 mad=1 localecompare=1
+ # TODO(rryan): libupower-glib-dev is currently not whitelisted by travis so we cannot
+ # test building with battery support.
+ # https://github.com/travis-ci/apt-package-whitelist/issues/2806
+ - scons test=1 mad=1 localecompare=1 battery=0
script:
- ./mixxx-test
diff --git a/SConstruct b/SConstruct
index 8c7180cfe1..df706c5848 100644
--- a/SConstruct
+++ b/SConstruct
@@ -56,6 +56,7 @@ available_features = [features.Mad,
features.ColorDiagnostics,
features.AddressSanitizer,
features.LocaleCompare,
+ features.Battery,
# "Features" of dubious quality
features.PerfTools,
diff --git a/build/depends.py b/build/depends.py
index 71d11de8ee..d90a435782 100644
--- a/build/depends.py
+++ b/build/depends.py
@@ -1081,7 +1081,6 @@ class MixxxCore(Feature):
map(Qt.uic(build), ui_files)
if build.platform_is_windows:
- sources.append("util/battery/batterywindows.cpp")
# Add Windows resource file with icons and such
# force manifest file creation, apparently not necessary for all
# people but necessary for this committers handicapped windows
@@ -1092,9 +1091,6 @@ class MixxxCore(Feature):
# Need extra room for code signing (App Store)
build.env.Append(LINKFLAGS="-Wl,-headerpad,ffff")
build.env.Append(LINKFLAGS="-Wl,-headerpad_max_install_names")
- sources.append("util/battery/batterymac.cpp")
- elif build.platform_is_linux:
- sources.append("util/battery/batterylinux.cpp")
return sources
@@ -1297,7 +1293,7 @@ class MixxxCore(Feature):
return [SoundTouch, ReplayGain, PortAudio, PortMIDI, Qt, TestHeaders,
FidLib, SndFile, FLAC, OggVorbis, OpenGL, TagLib, ProtoBuf,
Chromaprint, RubberBand, SecurityFramework, CoreServices,
- QtScriptByteArray, Reverb, FpClassify, IOKit, UPower]
+ QtScriptByteArray, Reverb, FpClassify]
def post_dependency_check_configure(self, build, conf):
"""Sets up additional things in the Environment that must happen
diff --git a/build/features.py b/build/features.py
index b09b1a5adf..0f5c9153b2 100644
--- a/build/features.py
+++ b/build/features.py
@@ -82,7 +82,7 @@ class HID(Feature):
def configure(self, build, conf):
if not self.enabled(build):
return
-
+
if build.platform_is_linux:
# Try using system lib
if not conf.CheckLib(['hidapi-libusb', 'libhidapi-libusb']):
@@ -1251,3 +1251,36 @@ class LocaleCompare(Feature):
if not conf.CheckLib(['sqlite3']):
raise Exception('Missing libsqlite3 -- exiting!')
build.env.Append(CPPDEFINES='__SQLITE3__')
+
+class Battery(Feature):
+ def description(self):
+ return "Battery meter support."
+
+ def enabled(self, build):
+ build.flags['battery'] = util.get_flags(build.env, 'battery', 1)
+ if int(build.flags['battery']):
+ return True
+ return False
+
+ def add_options(self, build, vars):
+ vars.Add('battery',
+ 'Set to 1 to enable battery meter support.')
+
+ def configure(self, build, conf):
+ if not self.enabled(build):
+ return
+
+ build.env.Append(CPPDEFINES='__BATTERY__')
+
+ def sources(self, build):
+ if build.platform_is_windows:
+ return ["util/battery/batterywindows.cpp"]
+ elif build.platform_is_osx:
+ return ["util/battery/batterymac.cpp"]
+ elif build.platform_is_linux:
+ return ["util/battery/batterylinux.cpp"]
+ else:
+ raise Exception('Battery support is not implemented for the target platform.')
+
+ def depends(self, build):
+ return [depends.IOKit, depends.UPower]
diff --git a/src/util/battery/battery.cpp b/src/util/battery/battery.cpp
index 48c11696cf..21c7ed416c 100644
--- a/src/util/battery/battery.cpp
+++ b/src/util/battery/battery.cpp
@@ -1,5 +1,8 @@
#include "util/battery/battery.h"
+// Do not include platform-specific battery implementation unless we are built
+// with battery support (__BATTERY__).
+#ifdef __BATTERY__
#ifdef Q_OS_LINUX
#include "util/battery/batterylinux.h"
#elif defined(Q_OS_WIN)
@@ -7,6 +10,7 @@
#elif defined(Q_OS_MAC)
#include "util/battery/batterymac.h"
#endif
+#endif
#include "util/math.h"
// interval (in ms) of the timer which calls update()
@@ -26,12 +30,14 @@ Battery::~Battery() {
}
Battery* Battery::getBattery(QObject* parent) {
+#ifdef __BATTERY__
#ifdef Q_OS_LINUX
return new BatteryLinux(parent);
#elif defined(Q_OS_WIN)
return new BatteryWindows(parent);
#elif defined(Q_OS_MAC)
return new BatteryMac(parent);
+#endif
#else
return nullptr;
#endif