Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ xcuserdata/
# End of https://www.toptal.com/developers/gitignore/api/xcode

build/
build.xcresult/
build.xcresult/
/archive.xcarchive
2 changes: 1 addition & 1 deletion MacDependency/ArchitectureModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <Cocoa/Cocoa.h>
#import "MachOModel.h"
#include "macho/machoarchitecture.h"
#include "MachO/machoarchitecture.h"
#include "MachO/machoheader.h"

@class MyDocument;
Expand Down
18 changes: 12 additions & 6 deletions MacDependency/MacDependency.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 53;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -263,7 +263,8 @@
2A37F4A9FDCFA73011CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1310;
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "Konrad Windszus";
};
buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "MacDependency" */;
Expand Down Expand Up @@ -399,11 +400,12 @@
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
INFOPLIST_FILE = Info.plist;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = "com.googlecode.${PRODUCT_NAME:identifier}";
PRODUCT_NAME = MacDependency;
SDKROOT = macosx;
Expand All @@ -416,10 +418,11 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_IDENTITY = "-";
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_MODEL_TUNING = G5;
INFOPLIST_FILE = Info.plist;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = "com.googlecode.${PRODUCT_NAME:identifier}";
PRODUCT_NAME = MacDependency;
SDKROOT = macosx;
Expand All @@ -430,6 +433,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
Expand All @@ -450,6 +454,7 @@
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEAD_CODE_STRIPPING = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = c99;
Expand Down Expand Up @@ -478,7 +483,7 @@
/opt/local/include,
./../,
);
MACOSX_DEPLOYMENT_TARGET = 10.7;
MACOSX_DEPLOYMENT_TARGET = 10.13;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
Expand Down Expand Up @@ -509,6 +514,7 @@
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEAD_CODE_STRIPPING = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -521,7 +527,7 @@
/opt/local/include,
./../,
);
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.13;
SDKROOT = macosx;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
9 changes: 4 additions & 5 deletions MacDependency/MachOModel.mm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these changes, but prefer the systemPurpleColor colour as used by the original suggester for the warning colour.

Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ - (id) initWithFilename:(std::string&)filename command:(DylibCommand*)aCommand d
NSString* log = [NSString stringWithFormat:NSLocalizedString(@"ERR_ARCHITECTURE_MISMATCH", nil), filename.c_str(), [parent name]];
[aDocument appendLogLine:log withModel:self state:state];
}

} catch (MachOException& exc) {
[self setStateWithWarning:isWeakReference];
} catch (MachOException& exc) {
[self setStateWithWarning:isWeakReference || exc.isWarning()];
NSString* log = [NSString stringWithStdString:exc.getCause()];
[aDocument appendLogLine:log withModel:self state:state];
// distinguish between weak and strong. In both cases append to tree with a status color
Expand Down Expand Up @@ -176,10 +175,10 @@ - (NSColor*) textColor {
NSColor* color;
switch(state) {
case StateWarning:
color = [NSColor systemOrangeColor];
color = [NSColor systemYellowColor];
break;
case StateError:
color = [NSColor systemOrangeColor];
color = [NSColor systemRedColor];
break;
default:
color = [NSColor labelColor];
Expand Down
4 changes: 2 additions & 2 deletions MachO/MachO.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.13;
OTHER_LDFLAGS = "-Wl,-search_paths_first";
PRODUCT_BUNDLE_IDENTIFIER = "com.googlecode.${PRODUCT_NAME:identifier}";
PRODUCT_NAME = MachO;
Expand All @@ -417,7 +417,7 @@
GCC_PREFIX_HEADER = MachO_Prefix.h;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.13;
OTHER_LDFLAGS = "-Wl,-search_paths_first";
PRODUCT_BUNDLE_IDENTIFIER = "com.googlecode.${PRODUCT_NAME:identifier}";
PRODUCT_NAME = MachO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
12 changes: 9 additions & 3 deletions MachO/internalfile.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "internalfile.h"
#include "machoexception.h"

#include <dlfcn.h>

// use reference counting to reuse files for all used architectures
InternalFile* InternalFile::create(InternalFile* file) {
file->counter++;
Expand All @@ -24,9 +26,13 @@ filename(filename), counter(1)
// open file handle
file.open(this->filename, std::ios_base::in | std::ios_base::binary);
if (file.fail()) {
std::ostringstream error;
error << "Couldn't open file '" << filename << "'.";
throw MachOException(error.str());
void* dylib = dlopen(this->filename.c_str(), RTLD_LAZY);
if (dylib) {
dlclose(dylib);
throw MachOException("System cached library '" + filename + "'.", true);
} else {
throw MachOException("Couldn't open file '" + filename + "'.");
}
}

struct stat buffer;
Expand Down
5 changes: 4 additions & 1 deletion MachO/machoexception.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "machoexception.h"

MachOException::MachOException(const std::string& cause) : cause(cause)
MachOException::MachOException(const std::string& cause) : cause(cause), warning(false)
{
}

MachOException::MachOException(const std::string& cause, bool warning) : cause(cause), warning(warning)
{
}
3 changes: 3 additions & 0 deletions MachO/machoexception.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ class EXPORT MachOException
{
public:
MachOException(const std::string&);
MachOException(const std::string&, bool warning);
const std::string& getCause() { return cause; }
const bool isWarning() { return warning; }
private:
const std::string cause;
bool warning;
};

#endif // MACHOEXCEPTION_H