-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathinjectLib.rb
More file actions
54 lines (48 loc) · 2.03 KB
/
injectLib.rb
File metadata and controls
54 lines (48 loc) · 2.03 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
require 'xcodeproj'
require 'json'
#############################################################################################################
########### This script provides a way to inject linker commands to .xcodeproj #
########### this way, you will be able to run xcode without depending on hbuild #
########### so, it is very important for debugging. #
########### WARNING: Do not attempt to change OTHER_LDFLAGS on XCode, since this #
########### this script gonna OVERRIDE it. If you have any reason to put a new LDFLAG, #
########### open an issue on github.com/MrcSnm/HipremeEngine for sending your custom linker flags. #
#############################################################################################################
LIB_INCLUDES_PATH = "D/libIncludes.json"
PROJECT_PATH = 'HipremeEngine.xcodeproj'
project = Xcodeproj::Project.open(PROJECT_PATH)
includes = []
removes = []
includesJSON = JSON.parse(File.read(LIB_INCLUDES_PATH))
includesJSON.each do |key, value|
theLib = key
if theLib[0..2] == 'lib' then
theLib = theLib[3..-1]
end
theLib = '-l' + theLib[0..-(File.extname(theLib).length+1)]
if value then
includes<<= theLib
else
removes<<= theLib
end
end
for arg in ARGV
includes <<= arg
end
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['OTHER_LDFLAGS'] = ['$(inherited)']
includes.each do |includeName|
if config.build_settings['OTHER_LDFLAGS'].index(includeName) == nil then
config.build_settings['OTHER_LDFLAGS'] << includeName
end
end
removes.each do |removeName|
idx = config.build_settings['OTHER_LDFLAGS'].index(removeName)
if idx != nil then
config.build_settings['OTHER_LDFLAGS'] -= removeName
end
end
end
end
project.save