Files
shaka-packager/packager/version/version.cc
KongQun Yang 05a5a41969 Support generation of libpackager.so (shared_library)
Shared libpackager can be built by setting libpackager_type to
shared_library, e.g.

GYP_DEFINES='libpackager_type=shared_library' gclient runhooks
ninja -C out/Debug

will generate libpackager.so in out/Debug/lib directory.

Here is a few other changes to make shared_library builds and
tests pass:

- Add several test parameters to packager.h, which is needed for
  testing.
- Create a protoc.gypi from build/protoc.gypi but depending on
  protobuf_full_do_not_use instead of protobuf_lite, since we need
  protobuf_full_do_not_use for text parsing and generation of media
  info proto. Somehow shared_library build does not allow mixed use
  of protobuf_full_do_not_use and protobuf_lite.
- Remove the use of LazyInstance in version/version.cc and use static
  variable directly. This is because LazyInstance needs AtExitManager
  which may not be easy to setup when calling GetVersion.
- Allow skipping testPackageWvmInputWithoutStrippingParameterSetNalus
  with flag --shared_library, which is needed as shared_library build
  does not support --strip_parameter_set_nalus flag yet.

Fixes #227

Change-Id: Iff05a50baa28134faa7218664c96114cb9e70329
2017-06-13 20:42:32 +00:00

67 lines
1.6 KiB
C++

// 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"
#include "packager/base/synchronization/read_write_lock.h"
namespace shaka {
namespace {
#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)
const char kPackagerGithubUrl[] = "https://github.com/google/shaka-packager";
class Version {
public:
Version() : version_(kPackagerVersion) {}
~Version() {}
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;
}
private:
Version(const Version&) = delete;
Version& operator=(const Version&) = delete;
base::subtle::ReadWriteLock lock_;
std::string version_;
};
} // namespace
static Version g_packager_version;
std::string GetPackagerProjectUrl(){
return kPackagerGithubUrl;
}
std::string GetPackagerVersion() {
return g_packager_version.GetVersion();
}
void SetPackagerVersionForTesting(const std::string& version) {
g_packager_version.SetVersion(version);
}
} // namespace shaka