Common: Move version strings to their own header

Ideally Common.h wouldn't be a header in the Common library, and instead be renamed to something else, like PlatformCompatibility.h or something, but even then, there's still some things in the header that don't really fall under that label

This moves the version strings out to their own version header that doesn't dump a bunch of other unrelated things into scope, like what Common.h was doing.

This also places them into the Common namespace, as opposed to letting them sit in the global namespace.
This commit is contained in:
Lioncash
2017-09-09 15:52:35 -04:00
parent e86713ca67
commit 696e1b40b5
27 changed files with 101 additions and 58 deletions

View File

@ -31,6 +31,7 @@
#pragma once
#include <cstddef>
#include <limits>
#include <type_traits>

View File

@ -15,6 +15,7 @@
#include <array>
#include <cstddef>
#include <cstring>
#include <deque>
#include <list>
#include <map>

View File

@ -4,19 +4,6 @@
#pragma once
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
// Git version number
extern const std::string scm_desc_str;
extern const std::string scm_branch_str;
extern const std::string scm_rev_str;
extern const std::string scm_rev_git_str;
extern const std::string netplay_dolphin_ver;
extern const std::string scm_distributor_str;
// Force enable logging in the right modes. For some reason, something had changed
// so that debugfast no longer logged.
#if defined(_DEBUG) || defined(DEBUGFAST)

View File

@ -151,6 +151,7 @@
<ClInclude Include="TraversalClient.h" />
<ClInclude Include="TraversalProto.h" />
<ClInclude Include="UPnP.h" />
<ClInclude Include="Version.h" />
<ClInclude Include="WorkQueueThread.h" />
<ClInclude Include="x64ABI.h" />
<ClInclude Include="x64Emitter.h" />

View File

@ -68,6 +68,7 @@
<ClInclude Include="SysConf.h" />
<ClInclude Include="Thread.h" />
<ClInclude Include="Timer.h" />
<ClInclude Include="Version.h" />
<ClInclude Include="WorkQueueThread.h" />
<ClInclude Include="x64ABI.h" />
<ClInclude Include="x64Emitter.h" />

View File

@ -4,14 +4,15 @@
#pragma once
#include <algorithm>
#include <cstring>
#include <fstream>
#include <string>
#include <type_traits>
#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Version.h"
// On disk format:
// header{
@ -177,7 +178,8 @@ private:
{
// Null-terminator is intentionally not copied.
std::memcpy(&id, "DCAC", sizeof(u32));
std::memcpy(ver, scm_rev_git_str.c_str(), std::min(scm_rev_git_str.size(), sizeof(ver)));
std::memcpy(ver, Common::scm_rev_git_str.c_str(),
std::min(Common::scm_rev_git_str.size(), sizeof(ver)));
}
u32 id;

View File

@ -1,9 +1,15 @@
// This file is public domain, in case it's useful to anyone. -comex
#include "Common/TraversalClient.h"
#include <cstddef>
#include <cstring>
#include <random>
#include <string>
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/Timer.h"
static void GetRandomishBytes(u8* buf, size_t size)
{

View File

@ -1,12 +1,15 @@
// This file is public domain, in case it's useful to anyone. -comex
#pragma once
#include <enet/enet.h>
#include <functional>
#include <cstddef>
#include <list>
#include <memory>
#include <random>
#include "Common/Common.h"
#include <string>
#include <enet/enet.h>
#include "Common/CommonTypes.h"
#include "Common/Thread.h"
#include "Common/TraversalProto.h"

View File

@ -2,9 +2,14 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Common/Common.h"
#include "Common/Version.h"
#include <string>
#include "Common/scmrev.h"
namespace Common
{
#ifdef _DEBUG
#define BUILD_TYPE_STR "Debug "
#elif defined DEBUGFAST
@ -24,16 +29,16 @@ const std::string scm_rev_str = "Dolphin "
BUILD_TYPE_STR SCM_DESC_STR;
#endif
const std::string scm_rev_git_str = SCM_REV_STR;
const std::string scm_desc_str = SCM_DESC_STR;
const std::string scm_branch_str = SCM_BRANCH_STR;
const std::string scm_distributor_str = SCM_DISTRIBUTOR_STR;
#ifdef _WIN32
const std::string netplay_dolphin_ver = SCM_DESC_STR " Win";
#elif __APPLE__
const std::string netplay_dolphin_ver = SCM_DESC_STR " Mac";
#else
const std::string netplay_dolphin_ver = SCM_DESC_STR " Lin";
const std::string netplay_dolphin_ver = SCM_DESC_STR " Lin";
#endif
const std::string scm_rev_git_str = SCM_REV_STR;
const std::string scm_desc_str = SCM_DESC_STR;
const std::string scm_branch_str = SCM_BRANCH_STR;
const std::string scm_distributor_str = SCM_DISTRIBUTOR_STR;
} // namespace Common

View File

@ -0,0 +1,18 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <string>
namespace Common
{
// Git version number
extern const std::string scm_desc_str;
extern const std::string scm_branch_str;
extern const std::string scm_rev_str;
extern const std::string scm_rev_git_str;
extern const std::string scm_distributor_str;
extern const std::string netplay_dolphin_ver;
} // namespace Common