diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..9f55b2c --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +3.0 diff --git a/Package.swift b/Package.swift index 556ee50..79caa17 100644 --- a/Package.swift +++ b/Package.swift @@ -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 { @@ -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) @@ -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", @@ -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 @@ -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) @@ -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", diff --git a/src/ibmras/common/util/LibraryUtils.cpp b/src/ibmras/common/util/LibraryUtils.cpp index d2fc718..c21e52f 100644 --- a/src/ibmras/common/util/LibraryUtils.cpp +++ b/src/ibmras/common/util/LibraryUtils.cpp @@ -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; } diff --git a/src/ibmras/monitoring/AgentExtensions.h b/src/ibmras/monitoring/AgentExtensions.h index db4434a..bef801c 100644 --- a/src/ibmras/monitoring/AgentExtensions.h +++ b/src/ibmras/monitoring/AgentExtensions.h @@ -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); diff --git a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp index 9988673..3965448 100644 --- a/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp +++ b/src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp @@ -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; }