diff --git a/source/dub/generators/visuald.d b/source/dub/generators/visuald.d index 75b393e..82724cc 100644 --- a/source/dub/generators/visuald.d +++ b/source/dub/generators/visuald.d @@ -22,8 +22,8 @@ import dub.packagemanager; import dub.generators.generator; -// version = VISUALD_SEPERATE_PROJECT_FILES; -version = VISUALD_SINGLE_PROJECT_FILE; +version = VISUALD_SEPERATE_PROJECT_FILES; +//version = VISUALD_SINGLE_PROJECT_FILE; // Dubbing is developing dub... //version = DUBBING; @@ -33,7 +33,6 @@ Project m_app; PackageManager m_pkgMgr; string[string] m_projectUuids; - bool[string] m_generatedProjects; } this(Project app, PackageManager mgr) { @@ -148,9 +147,10 @@ version(VISUALD_SEPERATE_PROJECT_FILES) { - m_generatedProjects[main.name] = true; + bool[string] generatedProjects; + generatedProjects[main.name] = true; performOnDependencies(main, (const Package dependency) { - if(dependency.name in m_generatedProjects) + if(dependency.name in generatedProjects) return; generateProjects(dependency, buildPlatform); } ); @@ -169,17 +169,16 @@ // Several configurations (debug, release, unittest) generateProjectConfiguration(ret, pack, Config.Debug, buildPlatform); generateProjectConfiguration(ret, pack, Config.Release, buildPlatform); - // generateProjectConfiguration(ret, pack, Config.Unittest); + generateProjectConfiguration(ret, pack, Config.Unittest, buildPlatform); // Add all files bool[SourceFile] sourceFiles; - void gatherSources(const(Package) pack, string prefix) { - logDebug("Gather sources for %s", pack.name); - if(prefix != "") prefix = "|" ~ prefix ~ "|"; + void gatherSources(const(Package) pack, bool prefixPkgId) { + logTrace("Gathering sources for %s", pack.name); foreach(source; pack.sources) { - SourceFile f = { pack.name, Path(pack.name)~source, pack.path ~ source }; + SourceFile f = { pack.name, prefixPkgId? Path(pack.name)~source : source, pack.path ~ source }; sourceFiles[f] = true; - logDebug("pkg file: %s", source); + logTrace(" pkg file: %s", source); } } @@ -192,14 +191,14 @@ if(package_.name in gathered) return; gathered[package_.name] = true; - gatherSources(package_, ""/*package_.name*/); + gatherSources(package_, true); performOnDependencies(package_, (const Package dependency) { gatherAll(dependency); }); } gatherAll(pack); } version(VISUALD_SEPERATE_PROJECT_FILES) { // gather sources for this package only - gatherSources(pack, ""); + gatherSources(pack, false); } // Create folders and files @@ -240,14 +239,63 @@ auto settings = m_app.getBuildSettings(platform, m_app.getDefaultConfiguration(platform)); string[] getSettings(string setting)(){ return __traits(getMember, settings, setting); } - // Specify build configuration name - ret.formattedWrite(" - ", to!string(type)); + foreach(architecture; platform.architecture) { + string arch; + switch(architecture) { + default: logWarn("Unsupported platform('%s'), defaulting to x86", architecture); + case "x86": arch = "Win32"; break; + case "x64": arch = "x64"; break; + } + ret.formattedWrite(" + ", to!string(type), arch); - ret.formattedWrite(" + // debug and optimize setting + ret.formattedWrite(" + %s + %s", type != Config.Release? "1":"0", type != Config.Debug? "1":"0"); + + // Lib or exe? + bool createLib = pack != m_app.mainPackage(); + string libIdentifier = createLib? "1" : "0"; + string debugSuffix = type == Config.Debug? "_d" : ""; + string extension = createLib? "lib" : "exe"; + ret.formattedWrite(" + %s + bin\\$(ProjectName)%s.%s", libIdentifier, debugSuffix, extension); + + // include paths and string imports + string imports = join(getSettings!"importPaths"(), " "); + string stringImports = join(getSettings!"stringImportPaths"(), " "); + ret.formattedWrite(" + %s + %s", imports, stringImports); + + // Compiler? + string compiler = "$(DMDInstallDir)windows\\bin\\dmd.exe"; + string dflags = join(getSettings!"dflags"(), " "); + ret.formattedWrite(" + %s + %s", compiler, dflags); + + // Add version identifiers + string versions = join(getSettings!"versions"(), " "); + ret.formattedWrite(" + %s", versions); + + // Add libraries, system libs need to be suffixed by ".lib". + string linkLibs = join(map!(a => a~".lib")(getSettings!"libs"()), " "); + string addLinkFiles = join(getSettings!"files"(), " "); + ret.formattedWrite(" + %s", linkLibs ~ " " ~ addLinkFiles); + + // Unittests + ret.formattedWrite(" + %s", type == Config.Unittest? "1" : "0"); + + // Not yet dynamic stuff + ret.formattedWrite(" 0 0 - 0 0 0 0 @@ -255,14 +303,7 @@ 0 0 0 - 0"); - - // debug and optimize setting - ret.formattedWrite(" - %s - %s", type != Config.Release? "1":"0", type != Config.Debug? "1":"0"); - - ret.formattedWrite(" + 0 0 0 0 @@ -279,7 +320,6 @@ 0 0 0 - 0 0 0 0 @@ -293,23 +333,7 @@ 2 0 0 - 0"); - - // include paths and string imports - string imports = join(getSettings!"importPaths"(), " "); - string stringImports = join(getSettings!"stringImportPaths"(), " "); - ret.formattedWrite(" - %s - %s", imports, stringImports); - - // Compiler? - string compiler = "$(DMDInstallDir)windows\\bin\\dmd.exe"; - string dflags = join(getSettings!"dflags"(), " "); - ret.formattedWrite(" - %s - %s", compiler, dflags); - - ret.formattedWrite(" + 0 $(ConfigurationName) $(OutDir) @@ -326,14 +350,7 @@ $(IntDir)\\$(TargetName).json 0 0 - "); // version ids ? - - // Add version identifiers - string versions = join(getSettings!"versions"(), " "); - ret.formattedWrite(" - %s", versions); - - ret.formattedWrite(" + 0 0 0 @@ -341,10 +358,7 @@ 0 - "); - - // TODO: Mago? Debugger settings! - ret.formattedWrite(" + 1 $(VisualDInstallDir)cv2pdb\\cv2pdb.exe 0 @@ -352,29 +366,15 @@ 0 - "); - - // Add libraries, system libs need to be suffixed by ".lib". - string linkLibs = join(map!(a => a~".lib")(getSettings!"libs"()), " "); - string addLinkFiles = join(getSettings!"files"(), " "); - ret.formattedWrite(" - %s", linkLibs ~ " " ~ addLinkFiles); - - // Add library paths ( not necessary, libraries have absolute path ) - ret.formattedWrite(" + - bin\\$(ProjectName)_d.exe - "); - - // Add a post build command to copy files - ret.formattedWrite(" - "); - - ret.formattedWrite(" + + *.obj;*.cmd;*.build;*.json;*.dep "); + } // foreach(architecture) } void performOnDependencies(const Package main, void delegate(const Package pack) op) {