@@ -153,126 +153,129 @@ void ofAddon::addReplaceStringVector(vector<LibraryBinary> & variable, string va
153153 }
154154}
155155
156- void ofAddon::parseVariableValue (string variable, string value, bool addToValue, string line, int lineNum){
157- if (variable == " ADDON_NAME" ){
158- if (value!=name){
156+ void ofAddon::parseVariableValue (const string & variable, const string & value, bool addToValue, const string & line, int lineNum){
157+
158+
159+ if (variable == " ADDON_NAME" ){
160+ if (value != name){
159161 ofLogError () << " Error parsing " << name << " addon_config.mk" << " \n\t\t "
160162 << " line " << lineNum << " : " << line << " \n\t\t "
161163 << " addon name in filesystem " << name << " doesn't match with addon_config.mk " << value;
162164 }
163165 return ;
164166 }
165167
166-
167- fs::path addonRelPath;
168- if (!isLocalAddon) {
169- addonRelPath = pathToOF / " addons" / name;
170- } else {
171- addonRelPath = addonPath;
172- }
168+ fs::path addonRelPath = isLocalAddon ? addonPath : (pathToOF / " addons" / name);
173169
174170 if (variable == " ADDON_ADDITIONAL_LIBS" ) {
175171 additionalLibsFolder.emplace_back (value);
176172 return ;
177173 }
178174
179- if (variable == " ADDON_DESCRIPTION" ){
180- addReplaceString (description,value,addToValue);
175+ else if (variable == " ADDON_DESCRIPTION" ) {
176+ addReplaceString (description, value, addToValue);
181177 return ;
182178 }
183179
184- if (variable == " ADDON_AUTHOR" ){
180+ else if (variable == " ADDON_AUTHOR" ){
185181 addReplaceString (author,value,addToValue);
186182 return ;
187183 }
188184
189- if (variable == " ADDON_TAGS" ){
185+ else if (variable == " ADDON_TAGS" ){
190186 addReplaceStringVector (tags,value," " ,addToValue);
191187 return ;
192188 }
193189
194- if (variable == " ADDON_URL" ){
190+ else if (variable == " ADDON_URL" ){
195191 addReplaceString (url,value,addToValue);
196192 return ;
197193 }
198194
199- if (variable == " ADDON_DEPENDENCIES" ){
195+ else if (variable == " ADDON_DEPENDENCIES" ){
200196 addReplaceStringVector (dependencies,value," " ,addToValue);
201197 }
202198
203- if (variable == " ADDON_INCLUDES" ){
199+ else if (variable == " ADDON_INCLUDES" ){
200+ // if (!addToValue) {
201+ // alert ("CLEAR " + variable, 36);
202+ // alert ("value " + value, 36);
203+ // }
204+ // cout << includePaths.size() << endl;
204205 addReplaceStringVector (includePaths, value, addonRelPath.string (), addToValue);
206+ // cout << includePaths.size() << endl;
207+ // cout << "----" << endl;
205208 }
206209
207- if (variable == ADDON_CFLAGS){
210+ else if (variable == ADDON_CFLAGS){
208211 addReplaceStringVector (cflags,value," " ,addToValue);
209212 }
210213
211- if (variable == ADDON_CPPFLAGS){
214+ else if (variable == ADDON_CPPFLAGS){
212215 addReplaceStringVector (cppflags,value," " ,addToValue);
213216 }
214217
215- if (variable == ADDON_LDFLAGS){
218+ else if (variable == ADDON_LDFLAGS){
216219 addReplaceStringVector (ldflags,value," " ,addToValue);
217220 }
218221
219- if (variable == ADDON_LIBS){
222+ else if (variable == ADDON_LIBS){
220223 addReplaceStringVector (libs, value, addonRelPath.string (), addToValue);
221224 }
222225
223- if (variable == ADDON_DLLS_TO_COPY){
226+ else if (variable == ADDON_DLLS_TO_COPY){
224227 addReplaceStringVector (dllsToCopy,value," " ,addToValue);
225228 }
226229
227- if (variable == ADDON_PKG_CONFIG_LIBRARIES){
230+ else if (variable == ADDON_PKG_CONFIG_LIBRARIES){
228231 addReplaceStringVector (pkgConfigLibs,value," " ,addToValue);
229232 }
230233
231- if (variable == ADDON_FRAMEWORKS){
234+ else if (variable == ADDON_FRAMEWORKS){
232235 addReplaceStringVector (frameworks,value," " ,addToValue);
233236 }
234237
235- if (variable == ADDON_SOURCES){
238+ else if (variable == ADDON_SOURCES){
236239 addReplaceStringVector (srcFiles, value, addonRelPath.string () ,addToValue);
237240 }
238241
239- if (variable == ADDON_C_SOURCES){
242+ else if (variable == ADDON_C_SOURCES){
240243 addReplaceStringVector (csrcFiles, value, addonRelPath.string () ,addToValue);
241244 }
242245
243- if (variable == ADDON_CPP_SOURCES){
246+ else if (variable == ADDON_CPP_SOURCES){
244247 addReplaceStringVector (cppsrcFiles, value, addonRelPath.string () ,addToValue);
245248 }
246249
247- if (variable == ADDON_HEADER_SOURCES){
250+ else if (variable == ADDON_HEADER_SOURCES){
248251 addReplaceStringVector (headersrcFiles, value, addonRelPath.string () ,addToValue);
249252 }
250253
251- if (variable == ADDON_OBJC_SOURCES){
254+ else if (variable == ADDON_OBJC_SOURCES){
252255 addReplaceStringVector (objcsrcFiles, value, addonRelPath.string () ,addToValue);
253256 }
254257
255- if (variable == ADDON_DATA){
258+ else if (variable == ADDON_DATA){
256259 addReplaceStringVector (data,value," " ,addToValue);
257260 }
258261
259- if (variable == ADDON_LIBS_EXCLUDE){
262+ else if (variable == ADDON_LIBS_EXCLUDE){
260263 addReplaceStringVector (excludeLibs,value," " ,addToValue);
261264 }
262265
263- if (variable == ADDON_SOURCES_EXCLUDE){
266+ else if (variable == ADDON_SOURCES_EXCLUDE){
264267 addReplaceStringVector (excludeSources,value," " ,addToValue);
265268 }
266269
267- if (variable == ADDON_INCLUDES_EXCLUDE){
270+ else if (variable == ADDON_INCLUDES_EXCLUDE){
268271 addReplaceStringVector (excludeIncludes,value," " ,addToValue);
269272 }
270273
271- if (variable == ADDON_FRAMEWORKS_EXCLUDE) {
274+ else if (variable == ADDON_FRAMEWORKS_EXCLUDE) {
272275 addReplaceStringVector (excludeFrameworks, value, " " , addToValue);
273276 }
274277
275- if (variable == ADDON_DEFINES) {
278+ else if (variable == ADDON_DEFINES) {
276279 addReplaceStringVector (defines, value, " " , addToValue);
277280 }
278281}
@@ -313,15 +316,17 @@ void ofAddon::exclude(vector<LibraryBinary> & variables, vector<string> exclusio
313316}
314317
315318void ofAddon::parseConfig (){
316- fs::path fileName;
317- if (isLocalAddon){
318- fileName = pathToProject / addonPath / " addon_config.mk" ;
319- }else {
320- fileName = addonPath / " addon_config.mk" ;
319+ // alert ("ofAddon::parseConfig " + addonPath.string(), 33);
320+ fs::path fileName = isLocalAddon ?
321+ (pathToProject / addonPath / " addon_config.mk" ) :
322+ (addonPath / " addon_config.mk" )
323+ ;
324+
325+ if (!fs::exists (fileName)) {
326+ // ofLogError() << "ofAddon::parseConfig() " << fileName << " not found " << ofPathToString(fileName);
327+ return ;
321328 }
322329
323- if (!fs::exists (fileName)) return ;
324-
325330 int lineNum = 0 ;
326331
327332 for (auto & originalLine : fileToStrings (fileName)) {
@@ -380,8 +385,6 @@ void ofAddon::parseConfig(){
380385 parseVariableValue (variable, value, addToValue, originalLine, lineNum);
381386 }
382387 }
383-
384-
385388}
386389
387390void ofAddon::parseLibsPath (const fs::path & libsPath, const fs::path & parentFolder) {
@@ -392,7 +395,6 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
392395 return ;
393396 }
394397
395- vector <fs::path> libFiles;
396398
397399 getLibsRecursively (libsPath, libFiles, libs, platform);
398400 if (platform == " osx" || platform == " ios" ){
@@ -471,6 +473,10 @@ void ofAddon::parseLibsPath(const fs::path & libsPath, const fs::path & parentFo
471473bool ofAddon::fromFS (const fs::path & path, const string & platform){
472474 // alert("ofAddon::fromFS path : " + path.string());
473475
476+ if (!fs::exists (path)) {
477+ return false ;
478+ }
479+
474480 clear ();
475481 this ->platform = platform;
476482
@@ -481,10 +487,6 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){
481487 name = path.filename ().string ();
482488 }
483489
484- if (!fs::exists (path)) {
485- return false ;
486- }
487-
488490 fs::path srcPath { path / " src" };
489491 if (fs::exists (srcPath)) {
490492 getFilesRecursively (srcPath, srcFiles);
@@ -493,7 +495,7 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){
493495 // MARK: srcFiles to fs::path
494496 // not possible today because there are string based exclusion functions
495497
496- fs::path parentFolder = path.parent_path ();
498+ fs::path parentFolder { path.parent_path () } ;
497499
498500 for (auto & s : srcFiles) {
499501 fs::path sFS { s };
@@ -508,21 +510,15 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){
508510 filesToFolders[s] = folder.string ();
509511 }
510512
513+
511514 if (platform == " vs" || platform == " msys2" ) {
512515 // here addonPath is the same as path.
513516 getPropsRecursively (addonPath, propsFiles, platform);
514517 }
515518
516519
517- parseConfig ();
518-
519- fs::path libsPath = path / " libs" ;
520- parseLibsPath (libsPath, parentFolder);
521520
522- for (auto & a : additionalLibsFolder) {
523- // parseLibsPath(fs::weakly_canonical(path / a), parentFolder);
524- parseLibsPath ((path / a), parentFolder);
525- }
521+ fs::path libsPath { path / " libs" };
526522
527523 // paths that are needed for the includes.
528524 std::list < fs::path > paths;
@@ -544,16 +540,28 @@ bool ofAddon::fromFS(const fs::path & path, const string & platform){
544540 }
545541 }
546542
543+
544+ parseConfig ();
545+
546+ parseLibsPath (libsPath, parentFolder);
547+
548+ for (auto & a : additionalLibsFolder) {
549+ // parseLibsPath(fs::weakly_canonical(path / a), parentFolder);
550+ parseLibsPath ((path / a), parentFolder);
551+ }
552+
547553
548554 paths.sort ();
549555
550556 for (auto & p : paths) {
551557 includePaths.emplace_back (p.string ());
552558 }
553-
554-
555-
556559
560+
561+ //
562+ // FIXME: MARK: - HACK:
563+ // parseConfig();
564+
557565 exclude (includePaths, excludeIncludes);
558566 exclude (srcFiles, excludeSources);
559567 exclude (csrcFiles, excludeSources);
0 commit comments