Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated project to support macOS 13.3 and Xcode 14.3 #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
37 changes: 29 additions & 8 deletions XcodeClangFormat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
01A2121929F1D46000639A2B /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01A2121829F1D46000639A2B /* UniformTypeIdentifiers.framework */; };
01A2121A29F1D47D00639A2B /* XcodeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01A2120E29F1C40400639A2B /* XcodeKit.framework */; };
01A2121B29F1D47D00639A2B /* XcodeKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 01A2120E29F1C40400639A2B /* XcodeKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
559B23E31D7EBDA300937AB3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 559B23E21D7EBDA300937AB3 /* AppDelegate.m */; };
559B23E61D7EBDA300937AB3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 559B23E51D7EBDA300937AB3 /* main.m */; };
559B23E81D7EBDA300937AB3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 559B23E71D7EBDA300937AB3 /* Assets.xcassets */; };
Expand All @@ -29,6 +32,17 @@
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
01A2121C29F1D47E00639A2B /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
01A2121B29F1D47D00639A2B /* XcodeKit.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
559B240A1D7EBDB700937AB3 /* Embed App Extensions */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -43,6 +57,9 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
01A2120E29F1C40400639A2B /* XcodeKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XcodeKit.framework; path = Library/Frameworks/XcodeKit.framework; sourceTree = DEVELOPER_DIR; };
01A2121229F1C4D900639A2B /* configure */ = {isa = PBXFileReference; lastKnownFileType = text; path = configure; sourceTree = "<group>"; };
01A2121829F1D46000639A2B /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; };
552396A22473BCCB002F4098 /* ClangFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClangFormat.h; sourceTree = "<group>"; };
556DCDEF1D7EF694005956C8 /* XcodeClangFormat.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = XcodeClangFormat.entitlements; sourceTree = "<group>"; };
557D38B71D7F270E00708269 /* libcurses.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcurses.tbd; path = usr/lib/libcurses.tbd; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -77,6 +94,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
01A2121929F1D46000639A2B /* UniformTypeIdentifiers.framework in Frameworks */,
01A2121A29F1D47D00639A2B /* XcodeKit.framework in Frameworks */,
55BCFFFA1D80170F000EDB05 /* libcurses.tbd in Frameworks */,
559B24101D7EBDC400937AB3 /* Cocoa.framework in Frameworks */,
);
Expand All @@ -90,6 +109,7 @@
children = (
55BCFFF71D801362000EDB05 /* config.xcconfig */,
55C8203F1D87F81300006D07 /* LICENSE.md */,
01A2121229F1C4D900639A2B /* configure */,
559B23E01D7EBDA300937AB3 /* XcodeClangFormat */,
559B24111D7EBDC400937AB3 /* clang-format */,
559B23F71D7EBDB700937AB3 /* Frameworks */,
Expand Down Expand Up @@ -131,6 +151,8 @@
559B23F71D7EBDB700937AB3 /* Frameworks */ = {
isa = PBXGroup;
children = (
01A2121829F1D46000639A2B /* UniformTypeIdentifiers.framework */,
01A2120E29F1C40400639A2B /* XcodeKit.framework */,
557D38B71D7F270E00708269 /* libcurses.tbd */,
559B23F81D7EBDB700937AB3 /* Cocoa.framework */,
);
Expand Down Expand Up @@ -188,6 +210,7 @@
559B240B1D7EBDC400937AB3 /* Sources */,
559B240C1D7EBDC400937AB3 /* Frameworks */,
559B240D1D7EBDC400937AB3 /* Resources */,
01A2121C29F1D47E00639A2B /* Embed Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -311,11 +334,12 @@
/* Begin XCBuildConfiguration section */
559B23ED1D7EBDA300937AB3 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 55BCFFF71D801362000EDB05 /* config.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
Expand Down Expand Up @@ -345,7 +369,6 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
Expand All @@ -359,7 +382,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand All @@ -368,11 +391,12 @@
};
559B23EE1D7EBDA300937AB3 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 55BCFFF71D801362000EDB05 /* config.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
Expand Down Expand Up @@ -402,15 +426,14 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
Expand Down Expand Up @@ -469,7 +492,6 @@
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
INFOPLIST_FILE = "clang-format/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 1.2.1;
OTHER_CPLUSPLUSFLAGS = (
"--system-header-prefix=$(LLVM_INCLUDE_DIR)",
Expand Down Expand Up @@ -514,7 +536,6 @@
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
INFOPLIST_FILE = "clang-format/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 1.2.1;
OTHER_CPLUSPLUSFLAGS = (
"--system-header-prefix=$(LLVM_INCLUDE_DIR)",
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 = "1140"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
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 = "1140"
LastUpgradeVersion = "1430"
wasCreatedForAppExtension = "YES"
version = "1.3">
<BuildAction
Expand Down
16 changes: 8 additions & 8 deletions XcodeClangFormat/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ - (void)applicationWillFinishLaunching:(NSNotification*)notification {
}

if ([style isEqualToString:@"custom"]) {
self.customStyle.state = NSOnState;
self.customStyle.state = NSControlStateValueOn;
} else if ([style isEqualToString:@"google"]) {
self.googleStyle.state = NSOnState;
self.googleStyle.state = NSControlStateValueOn;
} else if ([style isEqualToString:@"chromium"]) {
self.chromiumStyle.state = NSOnState;
self.chromiumStyle.state = NSControlStateValueOn;
} else if ([style isEqualToString:@"mozilla"]) {
self.mozillaStyle.state = NSOnState;
self.mozillaStyle.state = NSControlStateValueOn;
} else if ([style isEqualToString:@"webkit"]) {
self.webkitStyle.state = NSOnState;
self.webkitStyle.state = NSControlStateValueOn;
} else {
self.llvmStyle.state = NSOnState;
self.llvmStyle.state = NSControlStateValueOn;
}

NSData* bookmark = [defaults dataForKey:@"file"];
Expand Down Expand Up @@ -65,7 +65,7 @@ - (void)applicationWillFinishLaunching:(NSNotification*)notification {
self.secondaryPathControl.URL = url;
} else {
// Remove the bookmark value from the storage
[defaults setNilValueForKey:@"regularBookmark"];
[defaults removeObjectForKey:@"regularBookmark"];
}
[defaults synchronize];
}
Expand Down Expand Up @@ -149,7 +149,7 @@ - (BOOL)selectURL:(NSURL*)url {
} else {
self.primaryPathControl.URL = url;
self.secondaryPathControl.URL = url;
self.customStyle.state = NSOnState;
self.customStyle.state = NSControlStateValueOn;

[defaults setValue:@"custom" forKey:@"style"];
[defaults setObject:bookmark forKey:@"file"];
Expand Down
21 changes: 11 additions & 10 deletions clang-format/ClangFormatCommand.mm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#import "ClangFormatCommand.h"

#import <AppKit/AppKit.h>
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>

#include "ClangFormat.h"

Expand All @@ -17,8 +18,8 @@ void updateOffsets(std::vector<size_t>& offsets, NSMutableArray<NSString*>* line
}

clang::format::FormatStyle::LanguageKind getLanguageKind(XCSourceTextBuffer* buffer) {
CFStringRef uti = (__bridge CFStringRef)buffer.contentUTI;
if (UTTypeEqual(uti, kUTTypeCHeader)) {
NSString *uti = buffer.contentUTI;
if ([UTTypeCHeader.identifier isEqualToString:uti]) {
// C header files could also be Objective-C. We attempt to detect typical Objective-C keywords.
for (NSString* line in buffer.lines) {
if ([line hasPrefix:@"#import"] || [line hasPrefix:@"@interface"] || [line hasPrefix:@"@protocol"] ||
Expand All @@ -27,15 +28,15 @@ void updateOffsets(std::vector<size_t>& offsets, NSMutableArray<NSString*>* line
}
}
}
if (UTTypeEqual(uti, kUTTypeCPlusPlusHeader) || UTTypeEqual(uti, kUTTypeCPlusPlusSource) ||
UTTypeEqual(uti, kUTTypeCHeader) || UTTypeEqual(uti, kUTTypeCSource)) {
if ([UTTypeCPlusPlusHeader.identifier isEqualToString:uti] ||
[UTTypeCPlusPlusSource.identifier isEqualToString:uti] ||
[UTTypeCHeader.identifier isEqualToString:uti] ||
[UTTypeCSource.identifier isEqualToString:uti]) {
return clang::format::FormatStyle::LK_Cpp;
} else if (UTTypeEqual(uti, kUTTypeObjectiveCSource) ||
UTTypeEqual(uti, kUTTypeObjectiveCPlusPlusSource)) {
} else if ([UTTypeObjectiveCSource.identifier isEqualToString:uti] ||
[UTTypeObjectiveCPlusPlusSource.identifier isEqualToString:uti]) {
return clang::format::FormatStyle::LK_ObjC;
} else if (UTTypeEqual(uti, kUTTypeJavaSource)) {
return clang::format::FormatStyle::LK_Java;
} else if (UTTypeEqual(uti, kUTTypeJavaScript)) {
} else if ([UTTypeJavaScript.identifier isEqualToString:uti]) {
return clang::format::FormatStyle::LK_JavaScript;
}

Expand Down Expand Up @@ -202,7 +203,7 @@ - (void)performCommandWithInvocation:(XCSourceEditorCommandInvocation*)invocatio
// Calculated replacements and apply them to the input buffer.
const llvm::StringRef filename("<stdin>");
clang::format::FormattingAttemptStatus status;
auto replaces = clang::format::reformat(format.GetLanguageStyle(language).getValueOr(format), code, ranges, filename, &status);
auto replaces = clang::format::reformat(*format.GetLanguageStyle(language), code, ranges, filename, &status);

if (!status.FormatComplete) {
// We could not apply the calculated replacements.
Expand Down
28 changes: 25 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,29 @@ set -e
set -o pipefail
set -u

LLVM_VERSION=10.0.0
LLVM_HASH=70a7d5ed3bb16a5b5310ea4bfe95a74894022a43abb96d28ef8e30ab1f41d47a
LLVM_VERSION=15.0.0

function llvmHash() {
arch=$1
if [ "$arch" = "arm64" ]; then
echo "76fbc61512e0d8002e2a127d932d02bc49722fecca4ebf71ec6230e3aff65356"
else
echo "21f964fe2ff70847d704cac98fa4dd19bd2bd5b126c9a9bca3bad9855e4a413e"
fi
}

function llvmURL() {
arch=$1
if [ "$arch" = "arm64" ]; then
echo "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-${MAC_OS_ARCH}-apple-darwin21.0.tar.xz"
else
echo "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-${MAC_OS_ARCH}-apple-darwin.tar.xz"
fi
}

#architecture should be passed as parameter or script will use host Mac architecture
MAC_OS_ARCH=${1:-$(uname -m)}
LLVM_HASH=$(llvmHash $MAC_OS_ARCH)
LLVM_CONFIG=${LLVM_CONFIG:-llvm-config}

command -v "${LLVM_CONFIG}" >/dev/null 2>&1 || {
Expand All @@ -14,7 +35,7 @@ command -v "${LLVM_CONFIG}" >/dev/null 2>&1 || {
mkdir -p "deps"
FILE="deps/clang-${LLVM_VERSION}.tar.xz"
if [ ! -f "${FILE}" ]; then
URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-apple-darwin.tar.xz"
URL=$(llvmURL $MAC_OS_ARCH)
echo "Downloading ${URL}..."
curl --retry 3 -# -S -L "${URL}" -o "${FILE}.tmp" && mv "${FILE}.tmp" "${FILE}"
fi
Expand All @@ -38,6 +59,7 @@ echo "// Do not modify this file. Instead, rerun ./configure" > config.xcconfig
echo "LLVM_LIBDIR=$(${LLVM_CONFIG} --libdir)" >> config.xcconfig
echo "LLVM_INCLUDE_DIR=$(${LLVM_CONFIG} --includedir)" >> config.xcconfig
echo "LLVM_CXXFLAGS=$(${LLVM_CONFIG} --cxxflags)" >> config.xcconfig
echo "ARCHS=$MAC_OS_ARCH" >> config.xcconfig

echo "Wrote config.xcconfig."

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy