2015-12-21 23:10:17 +00:00
|
|
|
// Copyright 2015 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
#include "packager/version/version.h"
|
|
|
|
|
2017-05-23 02:41:26 +00:00
|
|
|
#include "packager/base/synchronization/read_write_lock.h"
|
2016-07-07 19:34:07 +00:00
|
|
|
|
2017-05-23 02:41:26 +00:00
|
|
|
namespace shaka {
|
2016-07-07 19:34:07 +00:00
|
|
|
namespace {
|
2015-12-21 23:10:17 +00:00
|
|
|
|
|
|
|
#if defined(PACKAGER_VERSION)
|
|
|
|
// PACKAGER_VERSION is generated in gyp file using script
|
|
|
|
// generate_version_string.py.
|
|
|
|
#if defined(NDEBUG)
|
|
|
|
const char kPackagerVersion[] = PACKAGER_VERSION "-release";
|
|
|
|
#else
|
|
|
|
const char kPackagerVersion[] = PACKAGER_VERSION "-debug";
|
|
|
|
#endif // #if defined(NDEBUG)
|
|
|
|
#else
|
|
|
|
const char kPackagerVersion[] = "";
|
|
|
|
#endif // #if defined(PACKAGER_VERSION)
|
|
|
|
|
2022-03-07 19:56:34 +00:00
|
|
|
const char kPackagerGithubUrl[] =
|
|
|
|
"https://github.com/shaka-project/shaka-packager";
|
2016-07-07 19:34:07 +00:00
|
|
|
|
|
|
|
class Version {
|
|
|
|
public:
|
|
|
|
Version() : version_(kPackagerVersion) {}
|
|
|
|
~Version() {}
|
|
|
|
|
2017-05-23 02:41:26 +00:00
|
|
|
const std::string& GetVersion() {
|
|
|
|
base::subtle::AutoReadLock read_lock(lock_);
|
|
|
|
return version_;
|
|
|
|
}
|
|
|
|
void SetVersion(const std::string& version) {
|
|
|
|
base::subtle::AutoWriteLock write_lock(lock_);
|
|
|
|
version_ = version;
|
|
|
|
}
|
2016-07-07 19:34:07 +00:00
|
|
|
|
|
|
|
private:
|
2017-05-23 02:41:26 +00:00
|
|
|
Version(const Version&) = delete;
|
|
|
|
Version& operator=(const Version&) = delete;
|
|
|
|
|
|
|
|
base::subtle::ReadWriteLock lock_;
|
2016-07-07 19:34:07 +00:00
|
|
|
std::string version_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2017-05-23 02:41:26 +00:00
|
|
|
static Version g_packager_version;
|
2016-07-07 19:34:07 +00:00
|
|
|
|
|
|
|
std::string GetPackagerProjectUrl(){
|
|
|
|
return kPackagerGithubUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string GetPackagerVersion() {
|
2017-05-23 02:41:26 +00:00
|
|
|
return g_packager_version.GetVersion();
|
2016-07-07 19:34:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetPackagerVersionForTesting(const std::string& version) {
|
2017-05-23 02:41:26 +00:00
|
|
|
g_packager_version.SetVersion(version);
|
2016-07-07 19:34:07 +00:00
|
|
|
}
|
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|