3 enum DirExpressionType { unknown, targetDir, intermediateObjectsDir }; // "type" is not right
5 class DirExpression : struct
8 DirExpressionType type;
15 property const char * dir
19 return dir ? dir : "";
25 dir = CopyString(value);
31 void Evaluate(const char * expression, Project project, CompilerConfig compiler, ProjectConfig config, int bitDepth)
34 const char * expr = expression;
40 expr = ideSettings.projectDefaultTargetDir;
41 else if(type == intermediateObjectsDir)
42 expr = ideSettings.projectDefaultIntermediateObjDir;
45 expr = defaultObjDirExpression;
47 if((len = strlen(expr)))
50 const char * configName = config && config.name && config.name[0] ? config.name : "Common";
51 const char * moduleName = project && project.moduleName ? project.moduleName : "";
52 const char * compilerName = (compiler && compiler.name) ? compiler.name : defaultCompilerName;
53 const char * targetPlatformName = compiler && compiler.targetPlatform ? compiler.targetPlatform : "";
54 char buffer[MAX_LOCATION];
55 for(c = 0, d = 0; c < len; c++)
57 if(expr[c] == '$' && c < len - 1 && expr[c + 1] == '(')
61 for(i = c + 2; i < len; i++)
68 if(!strnicmp(&expr[c + 2], "Config", n) || !strnicmp(&expr[c + 2], "Config", n))
71 strcat(buffer, configName);
72 CamelCase(&buffer[d]);
73 d += strlen(configName);
77 else if(!strnicmp(&expr[c + 2], "Module", n) || !strnicmp(&expr[c + 2], "Project", n))
80 strcat(buffer, moduleName);
81 //CamelCase(&buffer[d]);
82 d += strlen(moduleName);
86 else if(!strnicmp(&expr[c + 2], "Platform", n))
89 strcat(buffer, targetPlatformName);
90 CamelCase(&buffer[d]);
91 d += strlen(targetPlatformName);
95 else if(!strnicmp(&expr[c + 2], "Compiler", n))
98 strcat(buffer, compilerName);
99 CamelCase(&buffer[d]);
100 d += strlen(compilerName);
104 else if(!strnicmp(&expr[c + 2], "Debug_Suffix", n))
106 // We don't support .debug from the IDE yet...
110 else if(!strnicmp(&expr[c + 2], "Compiler_Suffix", n))
112 if(bitDepth || (compilerName[0] && strcmpi(compilerName, "default")))
114 if(compilerName[0] && strcmpi(compilerName, "default"))
118 strcat(buffer, compilerName);
119 CamelCase(&buffer[d]);
120 d += strlen(compilerName);
124 strcat(buffer, ".x32");
127 else if(bitDepth == 64)
129 strcat(buffer, ".x64");
136 else if(compiler && compiler.environmentVars && compiler.environmentVars.count)
138 for(ev : compiler.environmentVars;
139 ev.name && ev.string && ev.name[0] && ev.string[0] && !strnicmp(&expr[c + 2], ev.name, n) && strlen(ev.name) == n)
142 #if defined(__WIN32__)
143 ChangeCh(ev.string, '\\', '/');
145 strcat(buffer, ev.string);
146 #if defined(__WIN32__)
147 ChangeCh(ev.string, '/', '\\');
149 d += strlen(ev.string);
156 buffer[d++] = expr[c];
160 buffer[d++] = expr[c];
165 else if(expr[i] == '\\' || expr[i] == '/')
168 strncat(buffer, &expr[i], i - c);
176 buffer[d++] = expr[c];
180 buffer[d++] = expr[c];
184 if(dir && strcmp(buffer, dir))
187 dir = CopyString(buffer);
192 dir = CopyString("");
197 public enum TargetTypes { unset, executable, sharedLibrary, staticLibrary };
198 public enum OptimizationStrategy { unset, none, speed, size };
199 public enum WarningsOption { unset, normal, none, all }; // TOCHECK: More options?
200 public enum BuildBitDepth { all, bits32, bits64 };
202 Array<String> CopyArrayString(Array<String> array)
204 Array<String> copy = null;
208 for(s : array) copy.Add(CopyString(s));
213 public class ProjectOptions
217 property SetBool allWarnings
225 WarningsOption warnings;
229 SetBool noLineNumbers;
230 OptimizationStrategy optimization;
231 Array<String> preprocessorDefinitions;
232 property Array<String> includeDirs
238 if(value && value.count)
243 includeDirs.Add(CopyValidateMakefilePath(s));
250 get { return includeDirs; }
251 isset { return includeDirs && includeDirs.count; }
253 String defaultNameSpace;
254 SetBool strictNameSpaces;
257 TargetTypes targetType;
258 // NOTE: The JSON Parser deletes strings after setting a String property, so we do a copy here.
259 // (This behavior is different from Objects (class instances) values which are not deleted)
260 // Code calling these properties should *NOT* use CopyString().
261 property char * targetFileName
263 set { delete targetFileName; if(value && value[0]) targetFileName = CopyValidateMakefilePath(value); }
264 get { return targetFileName; }
265 isset { return targetFileName && targetFileName[0]; }
267 property char * targetDirectory
269 set { delete targetDirectory; if(value /*&& value[0]*/) targetDirectory = CopyValidateMakefilePath(value); }
270 get { return targetDirectory; }
271 isset { return targetDirectory != null/*&& targetDirectory[0]*/; }
273 property char * objectsDirectory
275 set { delete objectsDirectory; if(value /*&& value[0]*/) objectsDirectory = CopyValidateMakefilePath(value); }
276 get { return objectsDirectory; }
277 isset { return objectsDirectory != null/*&& objectsDirectory[0]*/; }
279 Array<String> libraries;
280 Array<String> compilerOptions;
281 Array<String> linkerOptions;
282 property Array<String> libraryDirs
288 if(value && value.count)
293 libraryDirs.Add(CopyValidateMakefilePath(s));
294 value.Free(); // why do I have to do this here? it's a property, shouldn't json deal with this?
300 get { return libraryDirs; }
301 isset { return libraryDirs && libraryDirs.count; }
306 // todo; move those to compiler/linker sections
307 SetBool excludeFromBuild;
308 BuildBitDepth buildBitDepth;
311 property Array<String> prebuildCommands
316 prebuildCommands.Free();
317 if(value && value.count)
319 if(!prebuildCommands)
320 prebuildCommands = { };
322 prebuildCommands.Add(CopyValidateMakefilePath(s));
327 delete prebuildCommands;
329 get { return prebuildCommands; }
330 isset { return prebuildCommands && prebuildCommands.count; }
332 property Array<String> postbuildCommands
336 if(postbuildCommands)
337 postbuildCommands.Free();
338 if(value && value.count)
340 if(!postbuildCommands)
341 postbuildCommands = { };
343 postbuildCommands.Add(CopyValidateMakefilePath(s));
348 delete postbuildCommands;
350 get { return postbuildCommands; }
351 isset { return postbuildCommands && postbuildCommands.count; }
353 property Array<String> installCommands
358 installCommands.Free();
359 if(value && value.count)
362 installCommands = { };
364 installCommands.Add(CopyValidateMakefilePath(s));
369 delete installCommands;
371 get { return installCommands; }
372 isset { return installCommands && installCommands.count; }
375 ProjectOptions Copy()
377 // TODO: We'll want some solution so that we can use OnCopy for copying containers (Array<String>)
382 memoryGuard = memoryGuard,
384 noLineNumbers = noLineNumbers;
385 optimization = optimization,
386 defaultNameSpace = CopyString(defaultNameSpace),
387 strictNameSpaces = strictNameSpaces,
388 targetType = targetType,
389 targetFileName = /*CopyString(*/targetFileName/*)*/,
390 targetDirectory = /*CopyString(*/targetDirectory/*)*/,
391 objectsDirectory = /*CopyString(*/objectsDirectory/*)*/,
394 excludeFromBuild = excludeFromBuild,
396 preprocessorDefinitions = CopyArrayString(preprocessorDefinitions),
397 includeDirs = CopyArrayString(includeDirs),
398 libraries = CopyArrayString(libraries),
399 compilerOptions = CopyArrayString(compilerOptions),
400 linkerOptions = CopyArrayString(linkerOptions),
401 libraryDirs = CopyArrayString(libraryDirs),
402 prebuildCommands = CopyArrayString(prebuildCommands),
403 postbuildCommands = CopyArrayString(postbuildCommands),
404 installCommands = CopyArrayString(installCommands)
411 PrintLn("warnings:", warnings);
412 PrintLn("debug:", debug);
413 PrintLn("memoryGuard:", memoryGuard);
414 PrintLn("profile:", profile);
415 //PrintLn("noLineNumbers:", noLineNumbers);
416 PrintLn("optimization:", optimization);
418 PrintLn("fastMath:", fastMath);
420 PrintLn("preprocessorDefinitions:", preprocessorDefinitions);
421 PrintLn("compilerOptions:", compilerOptions);
422 PrintLn("linkerOptions:", linkerOptions);
423 PrintLn("includeDirs:", includeDirs);
431 if(preprocessorDefinitions) { preprocessorDefinitions.Free(); delete preprocessorDefinitions; }
432 if(includeDirs) { includeDirs.Free(); delete includeDirs; }
433 delete defaultNameSpace;
434 delete targetFileName;
435 delete targetDirectory;
436 delete objectsDirectory;
437 if(libraries) { libraries.Free(); delete libraries; }
438 if(compilerOptions) { compilerOptions.Free(); delete compilerOptions; }
439 if(linkerOptions) { linkerOptions.Free(); delete linkerOptions; }
440 if(libraryDirs) { libraryDirs.Free(); delete libraryDirs; }
441 if(prebuildCommands) { prebuildCommands.Free(); delete prebuildCommands; }
442 if(postbuildCommands) { postbuildCommands.Free(); delete postbuildCommands; }
443 if(installCommands) { installCommands.Free(); delete installCommands; }
446 Array<String> includeDirs;
447 String targetFileName;
448 String targetDirectory;
449 String objectsDirectory;
450 Array<String> libraryDirs;
451 Array<String> prebuildCommands;
452 Array<String> postbuildCommands;
453 Array<String> installCommands;
455 property bool isEmpty
459 if(warnings == unset &&
461 memoryGuard == unset &&
463 noLineNumbers == unset &&
464 optimization == unset &&
465 !preprocessorDefinitions &&
466 (!includeDirs || !includeDirs.count) &&
468 strictNameSpaces == unset &&
469 targetType == unset &&
476 (!libraryDirs || !libraryDirs.count) &&
479 excludeFromBuild == unset &&
481 (!prebuildCommands || !prebuildCommands.count) &&
482 (!postbuildCommands || !postbuildCommands.count) &&
483 (!installCommands || !installCommands.count))
490 public class PlatformOptions
494 property ProjectOptions options { get { return options; } set { options = value; } isset { return options && !options.isEmpty; } }
502 PlatformOptions Copy()
507 options ? options.Copy() : null
511 ProjectOptions options;
514 class ProjectConfig : struct
518 property ProjectOptions options { get { return options; } set { options = value; } isset { return options && !options.isEmpty; } }
519 property Array<PlatformOptions> platforms
521 get { return platforms; }
524 if(platforms) { platforms.Free(); delete platforms; }
527 List<PlatformOptions> empty { };
528 Iterator<PlatformOptions> it { value };
530 for(p : platforms; !p.options || p.options.isEmpty) empty.Add(p);
531 for(p : empty; it.Find(p)) platforms.Delete(it.pointer);
541 if(p.options && !p.options.isEmpty)
550 ProjectOptions options;
552 bool compilingModified, linkingModified, symbolGenModified;
553 Array<PlatformOptions> platforms;
560 if(platforms) { platforms.Free(); delete platforms; }
565 Array<PlatformOptions> platforms = null;
569 for(p : this.platforms)
571 platforms.Add(p.Copy());
577 options ? options.Copy() : null,