diff --git a/commandLine/src/main.cpp b/commandLine/src/main.cpp index 7a742565..3b600923 100644 --- a/commandLine/src/main.cpp +++ b/commandLine/src/main.cpp @@ -1,7 +1,8 @@ #include "ofMain.h" #include "optionparser.h" #include "defines.h" -enum optionIndex { UNKNOWN, HELP, PLUS, RECURSIVE, LISTTEMPLATES, PLATFORMS, ADDONS, OFPATH, VERBOSE, TEMPLATE, DRYRUN, VERSION }; +enum optionIndex { UNKNOWN, HELP, PLUS, RECURSIVE, LISTTEMPLATES, PLATFORMS, ADDONS, OFPATH, VERBOSE, TEMPLATE, DRYRUN, SRCEXTERNAL, VERSION}; + constexpr option::Descriptor usage[] = { {UNKNOWN, 0, "", "",option::Arg::None, "Options:\n" }, @@ -14,7 +15,8 @@ constexpr option::Descriptor usage[] = {VERBOSE, 0,"v","verbose",option::Arg::None, " --verbose, -v \trun verbose" }, {TEMPLATE, 0,"t","template",option::Arg::Optional, " --template, -t \tproject template" }, {DRYRUN, 0,"d","dryrun",option::Arg::None, " --dryrun, -d \tdry run, don't change files" }, - {VERSION, 0, "w", "version", option::Arg::None, " --version, -d \treturn the current version"}, + {SRCEXTERNAL, 0,"s","source",option::Arg::Optional, " --source, -s \trelative or absolute path to source or include folders external to the project (such as ../../../../common_utils/" }, + {VERSION, 0, "w", "version", option::Arg::None, " --version, -w \treturn the current version"}, {0,0,0,0,0,0} }; @@ -58,6 +60,7 @@ std::string directoryForRecursion; std::string projectPath; std::string ofPath; std::vector addons; +std::vector srcPaths; std::vector targets; std::string ofPathEnv; std::string currentWorkingDirectory; @@ -263,6 +266,12 @@ void updateProject(std::string path, ofTargetPlatform target, bool bConsiderPara ofLogNotice() << "parsing addons.make"; project->parseAddons(); } + + if(!bDryRun){ + for(auto & srcPath : srcPaths){ + project->addSrcRecursively(srcPath); + } + } if (!bDryRun) project->save(); } @@ -415,7 +424,12 @@ int main(int argc, char* argv[]){ } } - + if (options[SRCEXTERNAL].count() > 0){ + if (options[SRCEXTERNAL].arg != NULL){ + std::string srcString(options[SRCEXTERNAL].arg); + srcPaths = ofSplitString(srcString, ",", true, true); + } + } if (options[OFPATH].count() > 0){ if (options[OFPATH].arg != NULL){ @@ -571,6 +585,9 @@ int main(int argc, char* argv[]){ for(auto & addon: addons){ project->addAddon(addon); } + for(auto & srcPath : srcPaths){ + project->addSrcRecursively(srcPath); + } } if (!bDryRun) project->save(); diff --git a/frontend/app.js b/frontend/app.js index edb2f304..e7aed63a 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -28,7 +28,7 @@ var isFirstTimeSierra = false; var bVerbose = false; var localAddons = []; - +var numAddedSrcPaths = 1; //----------------------------------------------------------------------------------- // IPC @@ -92,6 +92,12 @@ ipc.on('setProjectPath', function(arg) { $("#projectName").trigger('change'); // checks if we need to be in update or generate mode }); +//------------------------------------------- +ipc.on('setSourceExtraPath', function(arg, index) { + checkAddSourcePath(index); + $("#sourceExtra-"+index).val(arg); +}); + //------------------------------------------- ipc.on('setGenerateMode', function(arg) { switchGenerateMode(arg); @@ -914,12 +920,23 @@ function generate() { addonValueArray.push(localAddons[i]); } + // extra source locations + var srcExtraArr = ""; + for(var i = 0; i < numAddedSrcPaths; i++){ + var srcExtra = $("#sourceExtra-"+i).val(); + if( srcExtra != '' ){ + srcExtraArr += ", " + srcExtra; + } + } + + var lengthOfPlatforms = platformValueArray.length; var gen = {}; gen['projectName'] = $("#projectName").val(); gen['projectPath'] = $("#projectPath").val(); + gen['sourcePath'] = srcExtraArr; gen['platformList'] = platformValueArray; gen['templateList'] = templateValueArray; gen['addonList'] = addonValueArray; //$("#addonsDropdown").val(); @@ -997,12 +1014,16 @@ function switchGenerateMode(mode) { console.log('Switching GenerateMode to Update...'); clearAddonSelection(); + clearExtraSourceList(); } // [default]: switch to createMode (generate new projects) else { // if previously in update mode, deselect Addons - if( $("#updateButton").is(":visible") ){ clearAddonSelection(); } + if( $("#updateButton").is(":visible") ){ + clearAddonSelection(); + clearExtraSourceList(); + } $("#generateButton").show(); $("#updateButton").hide(); @@ -1032,14 +1053,14 @@ function enableAdvancedMode(isAdvanced) { $('#platformsDropdown').removeClass("disabled"); $("body").addClass('advanced'); $('a.updateMultiMenuOption').show(); - + $('#sourceExtraSection').show(); $('#templateSection').show(); $('#templateSectionMulti').show(); } else { $('#platformsDropdown').addClass("disabled"); $('#platformsDropdown').dropdown('set exactly', defaultSettings['defaultPlatform']); - + $('#sourceExtraSection').hide(); $('#templateSection').hide(); $('#templateSectionMulti').hide(); $('#templateDropdown').dropdown('set exactly', ''); @@ -1114,7 +1135,6 @@ function browseOfPath() { } function browseProjectPath() { - var path = $("#projectPath").val(); if (path === ''){ path = $("#ofPath").val(); @@ -1122,6 +1142,37 @@ function browseProjectPath() { ipc.send('pickProjectPath', path); // current path could go here } +function clearExtraSourceList(){ + $("#sourceExtraSection").empty(); + $("#sourceExtraSection").append(""); + + checkAddSourcePath(-1); + numAddedSrcPaths = 1; +} + +function checkAddSourcePath(index){ + //if we don't have another field below us - add one + var nextFieldId = '#sourceExtra-'+(index+1); + if( $(nextFieldId).length == 0 ){ + var nextIndex = index+1; + var extrafield = '
\ +
\ + \ + \ +
\ +
'; + + $("#sourceExtraSection").append(extrafield); + numAddedSrcPaths++; + } +} + +function browseSourcePath(index) { + var path = $("#ofPath").val(); + ipc.send('pickSourcePath', path, index); // current path could go here +} + + function browseImportProject() { var path = $("#projectPath").val(); if (path === ''){ diff --git a/frontend/index.html b/frontend/index.html index 1b9df434..26bbb7d3 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -150,6 +150,15 @@ +
+ +
+
+ + +
+
+