Skip to content

Commit 8bf7f5b

Browse files
committed
- Able to edit build settings
1 parent f7927ae commit 8bf7f5b

File tree

6 files changed

+836
-28
lines changed

6 files changed

+836
-28
lines changed

XCBuildConfiguration.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public class XCBuildConfiguration : PBXObject
1111
protected const string FRAMEWORK_SEARCH_PATHS_KEY = "FRAMEWORK_SEARCH_PATHS";
1212
protected const string OTHER_C_FLAGS_KEY = "OTHER_CFLAGS";
1313
protected const string OTHER_LD_FLAGS_KEY = "OTHER_LDFLAGS";
14+
protected const string GCC_ENABLE_CPP_EXCEPTIONS_KEY = "GCC_ENABLE_CPP_EXCEPTIONS";
15+
protected const string GCC_ENABLE_OBJC_EXCEPTIONS_KEY = "GCC_ENABLE_OBJC_EXCEPTIONS";
1416

1517
public XCBuildConfiguration( string guid, PBXDictionary dictionary ) : base( guid, dictionary )
1618
{
@@ -83,15 +85,15 @@ public bool AddFrameworkSearchPaths(PBXList paths, bool recursive = true)
8385

8486
public bool AddOtherCFlags( string flag )
8587
{
86-
Debug.Log( "INIZIO 1" );
88+
//Debug.Log( "INIZIO 1" );
8789
PBXList flags = new PBXList();
8890
flags.Add( flag );
8991
return AddOtherCFlags( flags );
9092
}
9193

9294
public bool AddOtherCFlags( PBXList flags )
9395
{
94-
Debug.Log( "INIZIO 2" );
96+
//Debug.Log( "INIZIO 2" );
9597

9698
bool modified = false;
9799

@@ -120,15 +122,15 @@ public bool AddOtherCFlags( PBXList flags )
120122

121123
public bool AddOtherLDFlags( string flag )
122124
{
123-
Debug.Log( "INIZIO A" );
125+
//Debug.Log( "INIZIO A" );
124126
PBXList flags = new PBXList();
125127
flags.Add( flag );
126128
return AddOtherLDFlags( flags );
127129
}
128130

129131
public bool AddOtherLDFlags( PBXList flags )
130132
{
131-
Debug.Log( "INIZIO B" );
133+
//Debug.Log( "INIZIO B" );
132134

133135
bool modified = false;
134136

@@ -154,6 +156,24 @@ public bool AddOtherLDFlags( PBXList flags )
154156

155157
return modified;
156158
}
159+
160+
public bool GccEnableCppExceptions (string value)
161+
{
162+
if (!ContainsKey (BUILDSETTINGS_KEY))
163+
this.Add (BUILDSETTINGS_KEY, new PBXDictionary ());
164+
165+
((PBXDictionary)_data [BUILDSETTINGS_KEY])[GCC_ENABLE_CPP_EXCEPTIONS_KEY] = value;
166+
return true;
167+
}
168+
169+
public bool GccEnableObjCExceptions (string value)
170+
{
171+
if (!ContainsKey (BUILDSETTINGS_KEY))
172+
this.Add (BUILDSETTINGS_KEY, new PBXDictionary ());
173+
174+
((PBXDictionary)_data [BUILDSETTINGS_KEY])[GCC_ENABLE_OBJC_EXCEPTIONS_KEY] = value;
175+
return true;
176+
}
157177

158178
// class XCBuildConfiguration(PBXType):
159179
// def add_search_paths(self, paths, base, key, recursive=True):

XCMod.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public ArrayList headerpaths {
5757
}
5858
}
5959

60-
public ArrayList linkers {
60+
public Hashtable buildSettings {
6161
get {
62-
return (ArrayList)_datastore["linkers"];
62+
return (Hashtable)_datastore["buildSettings"];
6363
}
6464
}
6565

@@ -92,7 +92,7 @@ public XCMod( string filename )
9292
path = System.IO.Path.GetDirectoryName( filename );
9393

9494
string contents = projectFileInfo.OpenText().ReadToEnd();
95-
_datastore = (Hashtable)MiniJSON.jsonDecode( contents );
95+
_datastore = (Hashtable)XMiniJSON.jsonDecode( contents );
9696

9797
// group = (string)_datastore["group"];
9898
// patches = (ArrayList)_datastore["patches"];

XCProject.cs

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,25 @@ public bool AddOtherLDFlags( PBXList flags )
258258
modified = true;
259259
return modified;
260260
}
261-
261+
262+
public bool GccEnableCppExceptions (string value)
263+
{
264+
foreach( KeyValuePair<string, XCBuildConfiguration> buildConfig in buildConfigurations ) {
265+
buildConfig.Value.GccEnableCppExceptions( value );
266+
}
267+
modified = true;
268+
return modified;
269+
}
270+
271+
public bool GccEnableObjCExceptions (string value)
272+
{
273+
foreach( KeyValuePair<string, XCBuildConfiguration> buildConfig in buildConfigurations ) {
274+
buildConfig.Value.GccEnableObjCExceptions( value );
275+
}
276+
modified = true;
277+
return modified;
278+
}
279+
262280
public bool AddHeaderSearchPaths( string path )
263281
{
264282
return AddHeaderSearchPaths( new PBXList( path ) );
@@ -354,12 +372,12 @@ public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tr
354372
// Debug.Log( "Is rooted: " + absPath );
355373
}
356374
else if( tree.CompareTo( "SDKROOT" ) != 0) {
357-
absPath = Path.Combine( Application.dataPath, filePath );
375+
absPath = Path.Combine( Application.dataPath.Replace("Assets", ""), filePath );
358376
// Debug.Log( "RElative: " + absPath );
359377
}
360378

361379
if( !( File.Exists( absPath ) || Directory.Exists( absPath ) ) && tree.CompareTo( "SDKROOT" ) != 0 ) {
362-
Debug.Log( "Missing file: " + filePath );
380+
Debug.Log( "Missing file: " + absPath + " > " + filePath );
363381
return results;
364382
}
365383
else if( tree.CompareTo( "SOURCE_ROOT" ) == 0 || tree.CompareTo( "GROUP" ) == 0 ) {
@@ -402,7 +420,7 @@ public PBXDictionary AddFile( string filePath, PBXGroup parent = null, string tr
402420
}
403421

404422
if ( !string.IsNullOrEmpty( absPath ) && File.Exists(absPath) && tree.CompareTo( "SOURCE_ROOT" ) == 0 ) {
405-
Debug.LogError(absPath);
423+
//Debug.LogError(absPath);
406424
string libraryPath = Path.Combine( "$(SRCROOT)", Path.GetDirectoryName( filePath ) );
407425
this.AddLibrarySearchPaths( new PBXList(libraryPath) );
408426
}
@@ -509,9 +527,10 @@ public bool AddFolder( string folderPath, PBXGroup parent = null, string[] exclu
509527
if( !Directory.Exists( folderPath ) )
510528
return false;
511529
DirectoryInfo sourceDirectoryInfo = new DirectoryInfo( folderPath );
512-
530+
513531
if( exclude == null )
514532
exclude = new string[] {};
533+
string regexExclude = string.Format( @"{0}", string.Join( "|", exclude ) );
515534

516535
PBXDictionary results = new PBXDictionary();
517536

@@ -524,6 +543,10 @@ public bool AddFolder( string folderPath, PBXGroup parent = null, string[] exclu
524543

525544
foreach( string directory in Directory.GetDirectories( folderPath ) )
526545
{
546+
if( Regex.IsMatch( directory, regexExclude ) ) {
547+
continue;
548+
}
549+
527550
// special_folders = ['.bundle', '.framework', '.xcodeproj']
528551
Debug.Log( "DIR: " + directory );
529552
if( directory.EndsWith( ".bundle" ) ) {
@@ -539,18 +562,15 @@ public bool AddFolder( string folderPath, PBXGroup parent = null, string[] exclu
539562
AddFolder( directory, newGroup, exclude, recursive, createBuildFile );
540563
}
541564
}
542-
543565
// Adding files.
544-
string regexExclude = string.Format( @"{0}", string.Join( "|", exclude ) );
545566
foreach( string file in Directory.GetFiles( folderPath ) ) {
546567
if( Regex.IsMatch( file, regexExclude ) ) {
547568
continue;
548569
}
549-
// Debug.Log( "--> " + file + ", " + newGroup );
570+
//Debug.Log( "--> " + file + ", " + newGroup );
550571
AddFile( file, newGroup, "SOURCE_ROOT", createBuildFile );
551572
}
552-
553-
573+
554574
modified = true;
555575
return modified;
556576
// def add_folder(self, os_path, parent=None, excludes=None, recursive=True, create_build_files=True):
@@ -947,14 +967,33 @@ public void ApplyMod( XCMod mod )
947967
this.AddHeaderSearchPaths( absoluteHeaderPath );
948968
}
949969

950-
Debug.Log( "Adding other linker flags..." );
951-
foreach( string linker in mod.linkers ) {
952-
string _linker = linker;
953-
if( !_linker.StartsWith("-") )
954-
_linker = "-" + _linker;
955-
this.AddOtherLDFlags( _linker );
970+
Debug.Log( "Configure build settings..." );
971+
Hashtable buildSettings = mod.buildSettings;
972+
if( buildSettings.ContainsKey("OTHER_LDFLAGS") )
973+
{
974+
Debug.Log( " Adding other linker flags..." );
975+
ArrayList otherLinkerFlags = (ArrayList) buildSettings["OTHER_LDFLAGS"];
976+
foreach( string linker in otherLinkerFlags )
977+
{
978+
string _linker = linker;
979+
if( !_linker.StartsWith("-") )
980+
_linker = "-" + _linker;
981+
this.AddOtherLDFlags( _linker );
982+
}
983+
}
984+
985+
if( buildSettings.ContainsKey("GCC_ENABLE_CPP_EXCEPTIONS") )
986+
{
987+
Debug.Log( " GCC_ENABLE_CPP_EXCEPTIONS = " + buildSettings["GCC_ENABLE_CPP_EXCEPTIONS"] );
988+
this.GccEnableCppExceptions( (string) buildSettings["GCC_ENABLE_CPP_EXCEPTIONS"] );
956989
}
957-
990+
991+
if( buildSettings.ContainsKey("GCC_ENABLE_OBJC_EXCEPTIONS") )
992+
{
993+
Debug.Log( " GCC_ENABLE_OBJC_EXCEPTIONS = " + buildSettings["GCC_ENABLE_OBJC_EXCEPTIONS"] );
994+
this.GccEnableObjCExceptions( (string) buildSettings["GCC_ENABLE_OBJC_EXCEPTIONS"] );
995+
}
996+
958997
this.Consolidate();
959998
}
960999

0 commit comments

Comments
 (0)