Skip to content

Commit d2d2124

Browse files
committed
Added version info
1 parent ef8fafe commit d2d2124

9 files changed

+132
-5
lines changed

build.bat

+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
@ECHO OFF
2+
3+
python generate_wdversion.py
4+
15
gyp --depth . -G output_dir=. -D platform=desktop -D mode=release --generator-output=out/ wd.gyp

build.sh

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ else
2626
modes=$mode
2727
fi
2828

29+
#generate wdversion.cc
30+
python generate_wdversion.py
31+
2932
for platform in $platforms
3033
do
3134
for mode in $modes

generate_wdversion.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import subprocess as sp
2+
3+
filename = "./src/wdversion.cc"
4+
p = sp.Popen(["git", "describe" , "--abbrev=10", "--dirty", "--always"], stdin=sp.PIPE, stdout=sp.PIPE)
5+
6+
data = p.stdout.readline()
7+
8+
versionfile = open (filename, 'w')
9+
versionfile.write("namespace webdriver {\n")
10+
versionfile.write("extern const char kProductName[] = \"WebDriver-cisco-cmt\";\n")
11+
versionfile.write("extern const char kVersionNumber[] = \"0.2.0\";\n")
12+
versionfile.write("extern const char kBuildTime[] = __TIME__;\n")
13+
versionfile.write("extern const char kBuildDate[] = __DATE__;\n")
14+
versionfile.write("extern const char kLastChanges[] = \"" + data.strip() + "\";\n")
15+
versionfile.write("}")
16+
versionfile.close()
17+
18+
p.stdout.close()
19+
p.stdin.close()

inc/versioninfo.h

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef VERSIONINFO_H
2+
#define VERSIONINFO_H
3+
4+
#include <string>
5+
6+
namespace webdriver {
7+
8+
/// @brief This class contains information about version webdriver
9+
class VersionInfo {
10+
public:
11+
VersionInfo();
12+
~VersionInfo();
13+
14+
/// @return Name of webdriver, e.g. "WebDriver" or "Google Chrome".
15+
std::string Name() const;
16+
17+
/// @return Version number as a string, e.g. "0.1.0".
18+
std::string Version() const;
19+
20+
/// @return The git revision of this release.
21+
std::string LastChange() const;
22+
23+
/// @return The version string, which contains the name of webdriver, version number and git revision
24+
std::string CreateVersionString() const;
25+
26+
/// @return The date and time of last build.
27+
std::string BuildDateTime() const;
28+
};
29+
30+
}
31+
#endif // VERSIONINFO_H

src/webdriver/versioninfo.cc

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "versioninfo.h"
2+
#include "webdriver_version.h"
3+
4+
namespace webdriver {
5+
6+
VersionInfo::VersionInfo()
7+
{
8+
}
9+
10+
VersionInfo::~VersionInfo()
11+
{
12+
}
13+
14+
std::string VersionInfo::Name() const
15+
{
16+
return kProductName;
17+
}
18+
19+
std::string VersionInfo::Version() const
20+
{
21+
return kVersionNumber;
22+
}
23+
24+
std::string VersionInfo::LastChange() const
25+
{
26+
return kLastChanges;
27+
}
28+
29+
std::string VersionInfo::BuildDateTime() const
30+
{
31+
std::string buildTime = kBuildTime;
32+
std::string buildDate = kBuildDate;
33+
return buildDate + " " + buildTime;
34+
}
35+
36+
std::string VersionInfo::CreateVersionString() const
37+
{
38+
std::string current_version;
39+
current_version = "Version: "+ Name() + "-" + Version() +
40+
"\nBuild Time: "+ BuildDateTime() +
41+
"\nRevision: " + LastChange();
42+
return current_version;
43+
}
44+
45+
}

src/webdriver/webdriver_server.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525

2626
#include "webdriver_route_patterns.h"
2727
#include "url_command_wrapper.h"
28-
29-
28+
#include "versioninfo.h"
3029

3130
namespace webdriver {
3231

@@ -40,6 +39,7 @@ Server::Server()
4039
Server::~Server() {};
4140

4241
int Server::Init(int argc, char *argv[]) {
42+
base::AtExitManager exit;
4343
int ret_val = 0;
4444

4545
if (state_ != STATE_UNCONFIGURED) {
@@ -108,8 +108,9 @@ int Server::Init(int argc, char *argv[]) {
108108

109109
SessionManager::GetInstance()->set_url_base(url_base_);
110110

111-
std::string chromedriver_info = base::StringPrintf("ChromeDriver %s", "QtWebKit");
112-
GlobalLogger::Log(kInfoLogLevel, chromedriver_info);
111+
std::string driver_info = "*** Webdriver ****\nVersion: "+ version_info.Name() + "-" + version_info.Version() +
112+
"\nBuild Time: "+ version_info.BuildDateTime() ;
113+
GlobalLogger::Log(kInfoLogLevel, driver_info);
113114

114115
// set default route table
115116
routeTable_.reset(new DefaultRouteTable());

src/webdriver/webdriver_version.cc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace webdriver {
2+
extern const char kProductName[] = "WebDriver-cisco-cmt";
3+
extern const char kVersionNumber[] = "0.2.0";
4+
extern const char kBuildTime[] = __TIME__;
5+
extern const char kBuildDate[] = __DATE__;
6+
extern const char kLastChanges[] = "4e6d397080-dirty";
7+
}

src/webdriver/webdriver_version.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef WDVERSION_H
2+
#define WDVERSION_H
3+
4+
namespace webdriver
5+
{
6+
7+
extern const char kProductName[];
8+
extern const char kVersionNumber[];
9+
extern const char kBuildTime[];
10+
extern const char kBuildDate[];
11+
extern const char kLastChanges[];
12+
13+
}
14+
15+
#endif // WDVERSION_H

wd.gyp

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
'src/Test/WindowTest.cc',
5252
'src/Test/FindingTest.cc',
5353
'src/Test/CoordinatesTest.cc',
54-
'src/Test/ElementAttributeTest.cc',
54+
'src/Test/ElementAttributeTest.cc',
5555
'src/Test/ElementAttributeTest.h',
5656
'<(INTERMEDIATE_DIR)/moc_ElementAttributeTest.cc',
5757
],
@@ -323,6 +323,8 @@
323323
'src/webdriver/webdriver_util.cc',
324324
'src/webdriver/webdriver_view_runner.cc',
325325
'src/webdriver/url_command_wrapper.cc',
326+
'src/webdriver/versioninfo.cc',
327+
'src/webdriver/webdriver_version.cc',
326328

327329

328330
# TODO: files below belong to custom implementation

0 commit comments

Comments
 (0)