Skip to content

Commit c739083

Browse files
authored
Fix for VS broken in OF/OF (#451)
1 parent 63975db commit c739083

6 files changed

Lines changed: 80 additions & 65 deletions

File tree

commandLine/src/addons/ofAddon.cpp

Lines changed: 69 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -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

315318
void 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

387390
void 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
471473
bool 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);

commandLine/src/addons/ofAddon.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class ofAddon {
116116
bool fromFS(const fs::path & path, const string & platform);
117117
void parseLibsPath(const fs::path & path, const fs::path & parentFolder);
118118
vector <fs::path> additionalLibsFolder;
119+
vector <fs::path> libFiles;
119120

120121
// void fromXML(string installXmlName);
121122
void clear();
@@ -168,7 +169,7 @@ class ofAddon {
168169
string currentParseState { "" };
169170

170171
void parseConfig();
171-
void parseVariableValue(string variable, string value, bool addToValue, string line, int lineNum);
172+
void parseVariableValue(const string & variable, const string & value, bool addToValue, const string & line, int lineNum);
172173
void addReplaceString(string & variable, string value, bool addToVariable);
173174
void addReplaceStringVector(vector<string> & variable, string value, string prefix, bool addToVariable);
174175
void addReplaceStringVector(vector<LibraryBinary> & variable, string value, string prefix, bool addToVariable);

commandLine/src/projects/baseProject.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ fs::path baseProject::getPlatformTemplateDir() {
3434
) {
3535
folder = "vscode";
3636
}
37+
38+
// if ( target == "qtcreator" ) {
39+
// return getOFRoot()
40+
// }
41+
3742
return getOFRoot() / templatesFolder / folder;
3843
}
3944

commandLine/src/projects/baseProject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#define PG_VERSION "30"
3+
#define PG_VERSION "31"
44

55
#include "ofAddon.h"
66
#include "ofFileUtils.h"

commandLine/src/projects/visualStudioProject.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,9 @@ void visualStudioProject::addSrc(const fs::path & srcFile, const fs::path & fold
257257
}
258258

259259
void visualStudioProject::addInclude(string includeName){
260+
// alert ("visualStudioProject::addInclude " + includeName, 35);
261+
260262
fixSlashOrder(includeName);
261-
// alert ("addInclude " + includeName, 35);
262263

263264
pugi::xpath_node_set source = doc.select_nodes("//ClCompile/AdditionalIncludeDirectories");
264265
for (pugi::xpath_node_set::const_iterator it = source.begin(); it != source.end(); ++it){

commandLine/src/utils/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void getPropsRecursively(const fs::path & path, std::vector < fs::path > & props
236236
}
237237
}
238238

239-
void getDllsRecursively(const fs::path & path, std::vector < string > & dlls, string platform) {
239+
void getDllsRecursively(const fs::path & path, std::vector<string> & dlls, string platform) {
240240
// alert ("getDllsRecursively " + path.string(), 34);
241241
// if (!fs::exists(path) || !fs::is_directory(path)) return;
242242
if (!fs::exists(path) || !fs::is_directory(path)) {

0 commit comments

Comments
 (0)