aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-03-19 14:33:07 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-03-19 14:33:07 +0100
commit5b72a6b5787a360e36d137fe2d52f47be926a588 (patch)
tree935a36f13e6287ca5492a1e172e1cf287eccb501
parentBlocker rewrites (diff)
downloadsmolbote-5b72a6b5787a360e36d137fe2d52f47be926a588.tar.xz
Added build script
Additional locations are searched for configuration
-rwxr-xr-xmach51
-rw-r--r--smolbote.qbs16
-rw-r--r--src/browser.cpp28
-rw-r--r--src/mainwindow.cpp2
-rw-r--r--src/settings.h2
l---------test/poi.conf1
6 files changed, 83 insertions, 17 deletions
diff --git a/mach b/mach
new file mode 100755
index 0000000..c99c47a
--- /dev/null
+++ b/mach
@@ -0,0 +1,51 @@
+#!/usr/bin/env ruby
+# DISCLAIMER: this is not Mozilla's mach
+
+require 'optparse'
+
+options = {
+ :settings => "#{ENV['HOME']}/.config/QtProject/qbs/1.7.1",
+ :profile => 'qt5',
+ :buildDir => '../build',
+ :installDir => '/usr/local'
+}
+
+OptionParser.new do |opts|
+ opts.banner = "Usage: ./mach [options]"
+
+ opts.on("-h", "--help", "Prints this help") do
+ puts opts
+ puts "Options: #{options}"
+ puts 'Commands: build, install'
+ exit
+ end
+
+ opts.on("--profile", "Set profile") do |profile|
+ options[:profile] = profile
+ end
+
+ opts.on("-d", "--build DIRECTORY", "Build location") do |dir|
+ options[:buildDir] = dir
+ end
+
+ opts.on("-i", "--install DIRECTORY", "Install location") do |dir|
+ options[:installDir] = dir
+ end
+
+end.parse!
+
+if not ARGV.empty? then
+ ARGV.each do|arg|
+ case arg
+ when 'build'
+ system "qbs build -d #{options[:buildDir]} profile:#{options[:profile]} release"
+ when 'install'
+ system "sudo qbs install -d #{options[:buildDir]} --install-root #{options[:installDir]} --settings-dir #{options[:settings]} profile:#{options[:profile]} release"
+ else
+ puts "Unknown argument #{a}; use ./mach -h for more details"
+ end
+ end
+
+else
+ puts 'No arguments; use ./mach -h for more details'
+end
diff --git a/smolbote.qbs b/smolbote.qbs
index 4d538eb..5ad9008 100644
--- a/smolbote.qbs
+++ b/smolbote.qbs
@@ -37,17 +37,12 @@ Project {
}
}
- // Platform-specifics go like this
-// Properties {
-// condition: qbs.targetOS.contains("windows")
-// }
-
cpp.includePaths: ['src', 'src/3rd-party']
cpp.defines: {
if(project.deprecatedWarnings)
defines.push("QT_DEPRECATED_WARNINGS", "QT_DISABLE_DEPRECATED_BEFORE="+project.deprecatedBefore);
if(git.found)
- defines.push('VERSION="'+git.version+'"');
+ defines.push('VERSION="'+git.version+'"', 'DESCRIBE="'+git.describe+'"');
return defines;
}
Depends { name: "Qt"; submodules: ["core", "widgets", "webengine", "webenginewidgets"] }
@@ -100,19 +95,20 @@ Project {
"src/xbel/xbel.h",
]
- // Properties for the produced executable
Group {
- fileTagsFilter: product.type // filter selects produced executable
- qbs.install: true // install it
+ name: "Executable"
+ fileTagsFilter: product.type
+ qbs.install: true
+ qbs.installDir: "bin"
}
- // config
Group {
name: "Configuration"
files: [
"data/poi.conf"
]
qbs.install: true
+ qbs.installDir: "share/smolbote"
}
}
}
diff --git a/src/browser.cpp b/src/browser.cpp
index 4697ac5..41c6355 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -125,12 +125,30 @@ DownloadDialog *Browser::downloads()
void Browser::setConfigPath(const QString &path)
{
- if(path.isEmpty()) {
- // set default config path
- m_settings = new Settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/poi.conf");
- } else {
- // set custom config path
+ // set custom config path if any
+ if(!path.isEmpty()) {
m_settings = new Settings(path);
+ return;
+ }
+
+ // check if config file exists for this user
+ QString cpath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/poi.conf";
+ if(QFile::exists(cpath)) {
+ m_settings = new Settings(cpath);
+ }
+
+ // check system-specific locations
+#ifdef Q_OS_LINUX
+ else if(QFile::exists("/usr/share/smolbote/poi.conf")) {
+ m_settings = new Settings("/usr/share/smolbote/poi.conf");
+ }
+ else if(QFile::exists("/usr/local/share/smolbote/poi.conf")) {
+ m_settings = new Settings("/usr/local/share/smolbote/poi.conf");
+ }
+#endif
+
+ else {
+ m_settings = new Settings();
}
}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index f455fae..087c5f8 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -161,7 +161,7 @@ void MainWindow::about()
"<p>This program comes with ABSOLUTELY NO WARRANTY. "
"This is free software, and you are welcome to redistribute it under the conditions set by the GNU GPLv3.</p>"
"<p>Configuration lives in: %2</p>")
- .arg(qApp->applicationVersion()).arg(sSettings->filePath()));
+ .arg(DESCRIBE).arg(sSettings->filePath()));
}
void MainWindow::loadProfile(const QString &name)
diff --git a/src/settings.h b/src/settings.h
index 12c508b..54a3917 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -27,7 +27,7 @@
class Settings
{
public:
- Settings(const QString &configFile);
+ Settings(const QString &configFile = QString());
~Settings();
QString filePath() const;
diff --git a/test/poi.conf b/test/poi.conf
new file mode 120000
index 0000000..2266797
--- /dev/null
+++ b/test/poi.conf
@@ -0,0 +1 @@
+../data/poi.conf \ No newline at end of file