@@ -315,6 +315,75 @@ void ofAddon::exclude(vector<LibraryBinary> & variables, vector<string> exclusio
315315 }
316316}
317317
318+
319+ void ofAddon::preParseConfig (){
320+ // alert ("ofAddon::parseConfig " + addonPath.string(), 33);
321+ fs::path fileName = isLocalAddon ?
322+ (pathToProject / addonPath / " addon_config.mk" ) :
323+ (addonPath / " addon_config.mk" )
324+ ;
325+
326+ if (!fs::exists (fileName)) {
327+ // ofLogError() << "ofAddon::parseConfig() " << fileName << " not found " << ofPathToString(fileName);
328+ return ;
329+ }
330+
331+ for (auto & line : fileToStrings (fileName)) {
332+ line = ofTrim (line);
333+
334+ if (line[0 ]==' #' || line == " " ) {
335+ continue ;
336+ } // discard comments
337+
338+
339+ // found section?
340+ if (line.back () == ' :' ){
341+ ofStringReplace (line, " :" , " " );
342+ currentParseState = line;
343+
344+ if (std::find (parseStates.begin (), parseStates.end (), currentParseState) == parseStates.end ()) {
345+ ofLogError () << " Error parsing " << name << " addon_config.mk" << " \n\t\t "
346+ // << "line " << lineNum << ": " << originalLine << "\n\t\t"
347+ << " sectionName " << currentParseState << " not recognized" ;
348+ }
349+ continue ;
350+ }
351+
352+ // found Variable
353+ if (line.find (" =" ) != string::npos){
354+ bool addToValue = false ;
355+ string variable, value;
356+ vector<string> varValue;
357+ if (line.find (" +=" ) != string::npos) {
358+ addToValue = true ;
359+ varValue = ofSplitString (line, " +=" );
360+ } else {
361+ varValue = ofSplitString (line, " =" );
362+ }
363+ variable = ofTrim (varValue[0 ]);
364+ value = ofTrim (varValue[1 ]);
365+
366+ // FIXME: This seems to be meaningless
367+ if (!checkCorrectPlatform (currentParseState)){
368+ continue ;
369+ }
370+
371+ if (!checkCorrectVariable (variable, currentParseState)){
372+ ofLogError () << " Error parsing " << name << " addon_config.mk" << " \n\t\t "
373+ // << "line " << lineNum << ": " << originalLine << "\n\t\t"
374+ << " variable " << variable << " not recognized for section " << currentParseState;
375+ continue ;
376+ }
377+
378+ if (variable == " ADDON_ADDITIONAL_LIBS" ) {
379+ additionalLibsFolder.emplace_back (value);
380+ // return;
381+ }
382+ // parseVariableValue(variable, value, addToValue, originalLine, lineNum);
383+ }
384+ }
385+ }
386+
318387void ofAddon::parseConfig (){
319388// alert ("ofAddon::parseConfig " + addonPath.string(), 33);
320389 fs::path fileName = isLocalAddon ?
@@ -541,7 +610,8 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){
541610 }
542611
543612
544- parseConfig ();
613+ // FIXME: MARK: - HACK:
614+ preParseConfig ();
545615
546616 parseLibsPath (libsPath, parentFolder);
547617
@@ -550,17 +620,13 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){
550620 parseLibsPath ((path / a), parentFolder);
551621 }
552622
553-
554623 paths.sort ();
555624
556625 for (auto & p : paths) {
557626 includePaths.emplace_back (p.string ());
558627 }
559628
560-
561- //
562- // FIXME: MARK: - HACK:
563- // parseConfig();
629+ parseConfig ();
564630
565631 exclude (includePaths, excludeIncludes);
566632 exclude (srcFiles, excludeSources);
0 commit comments