forked from MacDownApp/macdown
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPodfile
More file actions
123 lines (108 loc) · 5.58 KB
/
Copy pathPodfile
File metadata and controls
123 lines (108 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
platform :osx, "12.0"
source 'https://github.com/MacDownApp/cocoapods-specs.git' # Patched libraries.
source 'https://cdn.cocoapods.org/'
project 'MacDown.xcodeproj'
inhibit_all_warnings!
target "MacDown" do
use_frameworks!
pod 'handlebars-objc', '~> 1.4'
pod 'hoedown', '~> 3.0.7', :inhibit_warnings => false
pod 'JJPluralForm', '~> 2.1'
pod 'LibYAML', '~> 0.1'
pod 'M13OrderedDictionary', '~> 1.1'
pod 'MASPreferences', '~> 1.4'
# Sparkle 2.x: EdDSA signing, XPC-based installer, hardened-runtime friendly.
# Requires use_frameworks! (above) and a source-level migration away from
# SUUpdater to SPUStandardUpdaterController (see MainMenu.xib / MPMainController.m).
pod 'Sparkle', '~> 2.9', :inhibit_warnings => false
# No longer locked to 10.8; version bumped as part of dependency modernization.
pod 'PAPreferences', '~> 0.5'
end
target "MacDownTests" do
pod 'PAPreferences', '~> 0.5'
end
target "macdown-cmd" do
pod 'GBCli', '~> 1.1'
end
# Several of the pods above (GBCli, handlebars-objc, hoedown, JJPluralForm,
# LibYAML, M13OrderedDictionary, MASPreferences, PAPreferences) still ship
# with their own, much older MACOSX_DEPLOYMENT_TARGET (as low as 10.6),
# which is below Xcode's currently supported minimum (10.13) and well below
# this project's own target (12.0, set at the top of this file). Xcode
# doesn't build those targets against our deployment target automatically --
# it warns on every build instead. Force every pod sub-target up to ours,
# the same fix macdown3000 applies to the same dependency set.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
deployment_target = config.build_settings['MACOSX_DEPLOYMENT_TARGET']
if deployment_target && deployment_target.to_f < 12.0
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '12.0'
end
end
end
# Several pods include their own headers with quotes
# (#include/#import "Sibling.h"), which is fine for a plain static
# library but trips Clang's "double-quoted include in framework header,
# expected angle-bracketed instead" warning now that use_frameworks!
# builds them as actual Clang module frameworks. These are vendored and
# regenerated by every `pod install`, so patch the installed copies here
# instead of editing Pods/ directly, which would just get overwritten.
patch_quoted_framework_includes = lambda do |module_name, *glob_patterns|
glob_patterns.each do |pattern|
Dir.glob(File.join(installer.sandbox.root, pattern)).each do |path|
next unless File.exist?(path)
contents = File.read(path)
patched = contents.gsub(/#(include|import) "([A-Za-z0-9_]+\.h)"/,
"#\\1 <#{module_name}/\\2>")
File.write(path, patched) if patched != contents
end
end
end
patch_quoted_framework_includes.call('hoedown',
'hoedown/src/*.h',
'Target Support Files/hoedown/hoedown-umbrella.h')
patch_quoted_framework_includes.call('PAPreferences',
'Target Support Files/PAPreferences-framework/PAPreferences-framework-umbrella.h')
# inhibit_all_warnings! above works by attaching a per-file
# COMPILER_FLAGS override ("-w -Xanalyzer -analyzer-disable-all-checks")
# to every source file CocoaPods knows about at `pod install` time. But
# handlebars-objc.yy.m and y.tab.c aren't among them -- they're produced
# at *build* time by an Xcode Build Rule that turns handlebars-objc's
# .lm/.ym Lex/Yacc grammar files into .m/.c, so there's no file reference
# for CocoaPods to attach a per-file override to. Those generated files
# fall back to the handlebars-objc target's own OTHER_CFLAGS instead,
# which (confirmed by inspecting the generated xcconfig) carries no
# warning suppression at all. Add it there explicitly.
installer.pods_project.targets.each do |target|
next unless target.name == 'handlebars-objc'
target.build_configurations.each do |config|
cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited)'
next if cflags.include?('-Wno-everything')
config.build_settings['OTHER_CFLAGS'] = "#{cflags} -Wno-everything"
end
end
# MASPreferencesWindowController's -setSelectedViewController: (called
# whenever the user clicks a different Preferences toolbar tab) resizes
# the window with `animate:[self.window isVisible]`, i.e. animated
# whenever the window is on screen -- which is every real-world case.
# NSWindow frame animation is handed off to Core Animation/WindowServer,
# which does its compositing on its own background-QoS thread; the main
# thread (User-interactive, mid toolbar-click) then synchronously commits
# the subsequent setContentView:/recalculateKeyViewLoop calls and blocks
# on that thread via an internal NSConditionLock. That's the exact
# "Hang Risk" priority-inversion Xcode's Thread Performance Checker flags
# at MASPreferencesWindowController.m:222/311 -- nothing in MacDown's own
# code appears anywhere in that backtrace. Forcing the resize to be
# unanimated removes the CA/WindowServer handoff that creates the
# inversion in the first place.
masprefs_controller_path = File.join(
installer.sandbox.root, 'MASPreferences/Framework/MASPreferencesWindowController.m')
if File.exist?(masprefs_controller_path)
contents = File.read(masprefs_controller_path)
patched = contents.sub(
'setFrame:newFrame display:YES animate:[self.window isVisible]]',
'setFrame:newFrame display:YES animate:NO] /* patched: avoid Hang Risk, see Podfile */')
File.write(masprefs_controller_path, patched) if patched != contents
end
end