Skip to content

Commit

Permalink
Merge pull request #10 from mattcolegate/master
Browse files Browse the repository at this point in the history
Merge SwiftMetrics changes for Swift 3 GA
  • Loading branch information
tobespc authored Sep 30, 2016
2 parents 6587a77 + 703c454 commit 356c575
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
17 changes: 6 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import Foundation
import PackageDescription

#if os(Linux)
let fm = FileManager.default()
#else
let fm = FileManager.default
#endif

let fm = FileManager.default

///need to drill down into the omr-agentcore directory from where we are
if fm.currentDirectoryPath.contains("omr-agentcore") == false {
Expand Down Expand Up @@ -155,7 +150,7 @@ if fm.fileExists(atPath: "src/agentcore") == false {
let linuxVariations = ["defined(_Linux)", "defined(LINUX)", "defined(_LINUX)", "defined (_LINUX)"]
var fileEnum = fm.enumerator(atPath: srcDirPath)
while let fn = fileEnum?.nextObject() {
let fileName = String(fn)
let fileName = String(describing: fn)
///only want source files or header files
if fileName.hasSuffix(".cpp") || fileName.hasSuffix(".h") {
print(fileName)
Expand All @@ -181,7 +176,7 @@ if fm.fileExists(atPath: "src/agentcore") == false {
print("Attempting to enumerate " + targetWorkingDir)
fileEnum = fm.enumerator(atPath: targetWorkingDir)
while let fn = fileEnum?.nextObject() {
let fileName = String(fn)
let fileName = String(describing: fn)
if fileName != "include" {
var fileContents = try String(contentsOfFile: fileName, encoding: encoding)
fileContents = fileContents.replacingOccurrences(of: "#include \"MQTT",
Expand All @@ -205,7 +200,7 @@ if fm.fileExists(atPath: "src/agentcore") == false {
fileEnum = fm.enumerator(atPath: targetWorkingDir)
while let fn = fileEnum?.nextObject() {
print(fn)
let fileName = String(fn)
let fileName = String(describing: fn)
if fileName != "include" {
if fileName.hasSuffix(".cpp") {
source = fileName
Expand Down Expand Up @@ -238,7 +233,7 @@ if fm.fileExists(atPath: "src/agentcore") == false {
fileEnum = fm.enumerator(atPath: targetWorkingDir)
while let fn = fileEnum?.nextObject() {
print(fn)
let fileName = String(fn)
let fileName = String(describing: fn)
//ignore the include directory and anything that isn't a header or source file
if fileName.hasPrefix(IBMRAS_DIR) && (fileName.hasSuffix(".cpp") || fileName.hasSuffix(".h")) {
var fileContents = try String(contentsOfFile: fileName, encoding: encoding)
Expand Down Expand Up @@ -275,13 +270,13 @@ let package = Package(
Target(name: "cpuplugin", dependencies: [.Target(name: "agentcore")]),
Target(name: "envplugin", dependencies: [.Target(name: "agentcore")]),
Target(name: "memplugin", dependencies: [.Target(name: "agentcore")]),
Target(name: "ostreamplugin", dependencies: [.Target(name: "agentcore")]),
Target(name: "hcapiplugin", dependencies: [.Target(name: "agentcore")])
],
exclude: [ "src/agentcore/ibmras/common/port/aix",
"src/agentcore/ibmras/common/port/windows",
"src/agentcore/ibmras/common/data",
"src/agentcore/ibmras/common/util/memUtils.cpp",
"src/ostreamplugin",
"src/paho/Windows Build",
"src/paho/build",
"src/paho/doc",
Expand Down
8 changes: 7 additions & 1 deletion src/ibmras/common/util/LibraryUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ ibmras::common::util::LibraryUtils::Handle LibraryUtils::openLibrary(const std::
#if defined(WINDOWS)
handle.handle = LoadLibrary(lib.c_str());
#else
handle.handle = dlopen(lib.c_str(), RTLD_LAZY);
#if defined(__MACH__) || defined(__APPLE__)
std::size_t found = lib.rfind(".dylib", lib.size() - 6);
if (found == std::string::npos) {
return Handle();
}
#endif
handle.handle = dlopen(lib.c_str(), RTLD_LAZY);
#endif
return handle;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ibmras/monitoring/AgentExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ typedef struct loaderCoreFunctions {

} loaderCoreFunctions;

loaderCoreFunctions* loader_entrypoint();
DECL loaderCoreFunctions* loader_entrypoint();

typedef int (*PLUGIN_INITIALIZE)(const char* properties);
typedef pushsource* (*PUSH_SOURCE_REGISTER)(agentCoreFunctions aCF, unsigned int provID);
Expand Down
2 changes: 1 addition & 1 deletion src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ bool CpuPlugin::read_process_cpu_time(uint64* proctime, const uint32 NS_PER_HZ)
// of the running process. This can pose a problem if the filename
// has a space (i.e. (Passenger NodeA)). This checks to read the stream
// until the end parenthese is found.
while(dummyStr.back() != ')') {
while(dummyStr[dummyStr.length()-1] != ')') {
filestream >> dummyStr;
}

Expand Down

0 comments on commit 356c575

Please sign in to comment.