2011-02-06 02:12:00 +01:00
|
|
|
|
/*
|
|
|
|
|
|
BasicSetup - elementary self-configuration of the application
|
|
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2011, Hermann Vosseler <Ichthyostega@web.de>
|
2011-02-06 02:12:00 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
**Lumiera** is free software; you can redistribute it and/or modify it
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
|
|
Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
|
option) any later version. See the file COPYING for further details.
|
2011-02-06 02:12:00 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
* *****************************************************************/
|
2011-02-06 02:12:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
2016-11-03 18:22:31 +01:00
|
|
|
|
/** @file basic-setup.cpp
|
2016-11-04 22:29:24 +01:00
|
|
|
|
** Implementation of self-configuration and bootstrap functionality.
|
|
|
|
|
|
** This allows the application to "find its parts" at startup.
|
|
|
|
|
|
** @note as of 2016, BasicSetup::BasicSetup(string) also reads
|
|
|
|
|
|
** and evaluates a simple `*.ini` file to provide a
|
|
|
|
|
|
** preliminary mechanism for application configuration.
|
|
|
|
|
|
** This implementation is based on Boost program options
|
|
|
|
|
|
**
|
|
|
|
|
|
** @see searchpath.hpp
|
2016-11-03 18:20:10 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-02-06 02:12:00 +01:00
|
|
|
|
#include "common/basic-setup.hpp"
|
|
|
|
|
|
#include "lib/searchpath.hpp"
|
|
|
|
|
|
#include "lib/error.hpp"
|
2025-04-27 23:54:21 +02:00
|
|
|
|
#include "lib/file.hpp"
|
2011-02-06 02:12:00 +01:00
|
|
|
|
#include "lib/util.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
}
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace lumiera {
|
|
|
|
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
using std::ifstream;
|
|
|
|
|
|
|
|
|
|
|
|
namespace opt = boost::program_options;
|
|
|
|
|
|
|
|
|
|
|
|
namespace { // details of the bootstrap process...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Helper to locate a module using a search path spec
|
|
|
|
|
|
using lib::resolveModulePath;
|
|
|
|
|
|
|
|
|
|
|
|
/** use the general mechanism for resolving a search path
|
|
|
|
|
|
* to get the absolute path of the \c setup.ini */
|
|
|
|
|
|
string
|
2025-04-27 23:54:21 +02:00
|
|
|
|
resolve (fs::path iniSpec)
|
2011-02-06 02:12:00 +01:00
|
|
|
|
{
|
2025-04-28 19:14:27 +02:00
|
|
|
|
string searchpath = iniSpec.parent_path().generic_string();
|
2012-10-13 05:07:46 +02:00
|
|
|
|
return resolveModulePath (iniSpec.filename(), searchpath);
|
2011-02-06 02:12:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}//(End) implementation details
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Creating the BasicSetup object performs the
|
|
|
|
|
|
* initial self-configuration of the Lumiera Application.
|
2018-04-02 02:56:08 +02:00
|
|
|
|
* For this, the `setup.ini` file is located relative to the
|
2011-02-06 02:12:00 +01:00
|
|
|
|
* current application executable, read in and parsed into a
|
2018-04-02 02:56:08 +02:00
|
|
|
|
* map of setup variables.
|
2011-02-06 02:12:00 +01:00
|
|
|
|
*/
|
|
|
|
|
|
BasicSetup::BasicSetup (string bootstrapIni)
|
|
|
|
|
|
: syntax("Lumiera installation and platform configuration")
|
|
|
|
|
|
, settings()
|
|
|
|
|
|
{
|
|
|
|
|
|
syntax.add_options()
|
2011-02-06 05:06:16 +01:00
|
|
|
|
("Lumiera.gui", opt::value<string>(),
|
|
|
|
|
|
"name of the Lumiera GUI plugin to load")
|
|
|
|
|
|
("Lumiera.modulepath", opt::value<string>(),
|
|
|
|
|
|
"search path for loadable modules. "
|
2015-05-27 04:01:09 +02:00
|
|
|
|
"May use $ORIGIN to refer to the EXE location")
|
2011-02-06 05:06:16 +01:00
|
|
|
|
("Lumiera.configpath", opt::value<string>(),
|
|
|
|
|
|
"search path for extended configuration. "
|
|
|
|
|
|
"Extended Config system not yet implemented "
|
|
|
|
|
|
"Ignored as of 2/2011")
|
2011-02-07 00:54:16 +01:00
|
|
|
|
("Lumiera.title", opt::value<string>(),
|
|
|
|
|
|
"title of the Lumiera Application, e.g. for windows")
|
2011-02-06 05:06:16 +01:00
|
|
|
|
("Lumiera.version", opt::value<string>(),
|
|
|
|
|
|
"Application version string")
|
2011-02-07 00:54:16 +01:00
|
|
|
|
("Lumiera.website", opt::value<string>(),
|
|
|
|
|
|
"URL of the Lumiera website")
|
|
|
|
|
|
("Lumiera.authors", opt::value<string>(),
|
|
|
|
|
|
"names of Lumiera authors, for 'about' dialog. Separated by '|'")
|
2013-10-30 02:35:20 +01:00
|
|
|
|
("Lumiera.copyright", opt::value<string>(),
|
|
|
|
|
|
"year(s) for the author's copyright claim")
|
2011-02-07 00:54:16 +01:00
|
|
|
|
|
|
|
|
|
|
("Gui.stylesheet", opt::value<string>(),
|
|
|
|
|
|
"name of the GTK stylesheet to use. Will be searched in resource path")
|
|
|
|
|
|
("Gui.iconpath", opt::value<string>(),
|
|
|
|
|
|
"search path for icons")
|
|
|
|
|
|
("Gui.resourcepath", opt::value<string>(),
|
|
|
|
|
|
"general search path for UI resources")
|
2011-02-06 02:12:00 +01:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
ifstream configIn (resolve(bootstrapIni).c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-02-07 00:54:16 +01:00
|
|
|
|
opt::parsed_options parsed = opt::parse_config_file (configIn, syntax);
|
2011-02-06 02:12:00 +01:00
|
|
|
|
|
|
|
|
|
|
opt::store (parsed, settings);
|
2018-04-02 02:56:08 +02:00
|
|
|
|
opt::notify(settings);
|
2011-02-06 02:12:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lumiera
|