Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple flags are correctly read into VS projects, added support for preprocessor definitions in addons #214

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion ofxProjectGenerator/src/addons/ofAddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,15 @@ void ofAddon::parseVariableValue(string variable, string value, bool addToValue,
addReplaceStringVector(includePaths,value,addonRelPath,addToValue);
}


if(variable == "ADDON_CFLAGS"){
addReplaceStringVector(cflags,value,"",addToValue);
}

if (variable == "ADDON_PREPROCESSOR_DEFINITIONS") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this reference to ADDON_PREPROCESSOR_DEFINITIONS should go as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so, then adding ADDON_PREPROCESSOR_DEFINITIONS is useful?

Since I changed
additionalOptions = items[i].node().child("ClCompile").child("AdditionalOptions");
for
additionalOptions = items[i].node().child("ClCompile").child("PreprocessorDefinitions");

Should we leave it like this or should we use the seperate preprocessor flag?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no sorry, what i meant is it should go away

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already is in the latest commit

addReplaceStringVector(preprocessorDefinitions, value, "", addToValue);
}

if(variable == "ADDON_CPPFLAGS"){
addReplaceStringVector(cppflags,value,"",addToValue);
}
Expand Down Expand Up @@ -310,7 +315,7 @@ void ofAddon::parseVariableValue(string variable, string value, bool addToValue,
}

if(variable == "ADDON_DATA"){
addReplaceStringVector(data,value,"",addToValue);
addReplaceStringVector(data,value,addonRelPath,addToValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this? doesn't seem related to any of the problems explained in the PR no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, sorry I don't really know why that happened.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, fixed it.

}

if(variable == "ADDON_LIBS_EXCLUDE"){
Expand Down
1 change: 1 addition & 0 deletions ofxProjectGenerator/src/addons/ofAddon.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ofAddon {
std::vector < std::string > frameworks; // osx only
std::vector < std::string > data;
std::vector < std::string > defines;
std::vector < std::string > preprocessorDefinitions; // vs only
brinoausrino marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is still missing, it should go away to. there should be no changes in ofAddon.h only on visualStudioProject

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excuse the inconvenience.


// metadata
std::string name;
Expand Down
13 changes: 8 additions & 5 deletions ofxProjectGenerator/src/projects/visualStudioProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ void visualStudioProject::addCFLAG(std::string cflag, LibType libType){
if(!additionalOptions){
items[i].node().child("ClCompile").append_child("AdditionalOptions").append_child(pugi::node_pcdata).set_value(cflag.c_str());
}else{
additionalOptions.set_value((std::string(additionalOptions.value()) + " " + cflag).c_str());
additionalOptions.first_child().set_value((std::string(additionalOptions.first_child().value()) + " " + cflag).c_str());
}
}

Expand All @@ -357,7 +357,7 @@ void visualStudioProject::addCPPFLAG(std::string cppflag, LibType libType){
if(!additionalOptions){
items[i].node().child("ClCompile").append_child("AdditionalOptions").append_child(pugi::node_pcdata).set_value(cppflag.c_str());
}else{
additionalOptions.set_value((std::string(additionalOptions.value()) + " " + cppflag).c_str());
additionalOptions.first_child().set_value((std::string(additionalOptions.first_child().value()) + " " + cppflag).c_str());
}
}

Expand All @@ -371,19 +371,19 @@ void visualStudioProject::addDefine(std::string define, LibType libType)
bool found = false;
std::string condition(items[i].node().attribute("Condition").value());
if (libType == RELEASE_LIB && condition.find("Debug") != std::string::npos) {
additionalOptions = items[i].node().child("ClCompile").child("AdditionalOptions");
additionalOptions = items[i].node().child("ClCompile").child("PreprocessorDefinitions");
found = true;
}
else if (libType == DEBUG_LIB && condition.find("Release") != std::string::npos) {
additionalOptions = items[i].node().child("ClCompile").child("AdditionalOptions");
additionalOptions = items[i].node().child("ClCompile").child("PreprocessorDefinitions");
found = true;
}
if (!found) continue;
if (!additionalOptions) {
items[i].node().child("ClCompile").append_child("PreprocessorDefinitions").append_child(pugi::node_pcdata).set_value(define.c_str());
}
else {
additionalOptions.set_value((std::string(additionalOptions.value()) + " " + define).c_str());
additionalOptions.first_child().set_value((std::string(additionalOptions.first_child().value()) + " " + define).c_str());
}
}
}
Expand Down Expand Up @@ -451,6 +451,8 @@ void visualStudioProject::addAddon(ofAddon & addon){
addCFLAG(addon.cflags[i],RELEASE_LIB);
addCFLAG(addon.cflags[i],DEBUG_LIB);
}



for(int i=0;i<(int)addon.cppflags.size();i++){
ofLogVerbose() << "adding addon cppflags: " << addon.cppflags[i];
Expand All @@ -463,4 +465,5 @@ void visualStudioProject::addAddon(ofAddon & addon){
addDefine(addon.defines[i], RELEASE_LIB);
addDefine(addon.defines[i], DEBUG_LIB);
}

}