Win kiwix serve (#274)

Win kiwix serve
This commit is contained in:
Matthieu Gautier 2019-09-11 15:25:41 +02:00 committed by GitHub
commit 651cb9165c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 6 deletions

View File

@ -1,3 +1,8 @@
kiwix-lib 7.0.0
===============
* [API break] Add a argument to kiwix-serve to specify the library to use.
kiwix-lib 6.0.4
===============

View File

@ -26,7 +26,7 @@ task writePom {
project {
groupId 'org.kiwix.kiwixlib'
artifactId 'kiwixlib'
version '6.0.4' + (System.env.KIWIXLIB_BUILDVERSION == null ? '' : '-'+System.env.KIWIXLIB_BUILDVERSION)
version '7.0.0' + (System.env.KIWIXLIB_BUILDVERSION == null ? '' : '-'+System.env.KIWIXLIB_BUILDVERSION)
packaging 'aar'
name 'kiwixlib'
url 'https://github.com/kiwix/kiwix-lib'

View File

@ -2,6 +2,7 @@
#define KIWIXLIB_KIWIX_SERVE_H_
#include <memory>
#include <string>
class Subprocess;
namespace kiwix {
@ -9,7 +10,7 @@ namespace kiwix {
class KiwixServe
{
public:
KiwixServe(int port = 8181);
KiwixServe(const std::string& libraryPath, int port = 8181);
~KiwixServe();
void run();
@ -20,6 +21,7 @@ class KiwixServe
private:
std::unique_ptr<Subprocess> mp_kiwixServe;
int m_port;
std::string m_libraryPath;
};
}; //end namespace kiwix

View File

@ -1,5 +1,5 @@
project('kiwix-lib', 'cpp',
version : '6.0.4', # Also change this in android-kiwix-lib-publisher/kiwixLibAndroid/build.gradle
version : '7.0.0', # Also change this in android-kiwix-lib-publisher/kiwixLibAndroid/build.gradle
license : 'GPL',
default_options : ['c_std=c11', 'cpp_std=c++11', 'werror=true'])

View File

@ -14,7 +14,9 @@
namespace kiwix {
KiwixServe::KiwixServe(int port) : m_port(port)
KiwixServe::KiwixServe(const std::string& libraryPath, int port)
: m_port(port),
m_libraryPath(libraryPath)
{
}
@ -43,13 +45,12 @@ void KiwixServe::run()
// Try to use a potential installed kiwix-serve.
callCmd.push_back(KIWIXSERVE_CMD);
}
std::string libraryPath = getDataDirectory() + "/library.xml";
std::string attachProcessOpt = "-a" + to_string(pid);
std::string portOpt = "-p" + to_string(m_port);
callCmd.push_back(attachProcessOpt.c_str());
callCmd.push_back(portOpt.c_str());
callCmd.push_back("-l");
callCmd.push_back(libraryPath.c_str());
callCmd.push_back(m_libraryPath.c_str());
mp_kiwixServe = Subprocess::run(callCmd);
}