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

Support ADDON_DATA in addon_config.mk #190

Merged
merged 6 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ofxProjectGenerator/src/addons/ofAddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void ofAddon::parseVariableValue(string variable, string value, bool addToValue,
}

if(variable == "ADDON_DATA"){
addReplaceStringVector(data,value,addonRelPath,addToValue);
addReplaceStringVector(data,value,"",addToValue);
}

if(variable == "ADDON_LIBS_EXCLUDE"){
Expand Down
36 changes: 36 additions & 0 deletions ofxProjectGenerator/src/projects/baseProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,43 @@ void baseProject::addAddon(std::string addonName){
auto standardPath = ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonName);
addon.fromFS(standardPath, target);
}

addAddon(addon);

// Process values from ADDON_DATA
if(addon.data.size()){

for(auto& d : addon.data){

filesystem::path path(ofFilePath::join(addon.addonPath, d));

if(filesystem::exists(path)){
if (filesystem::is_regular_file(path)){
ofFile src(path);
string dest = ofFilePath::join(projectDir, "bin/data/");
ofStringReplace(d, "data/", ""); // avoid to copy files at /data/data/*
bool success = src.copyTo(ofFilePath::join(dest, d), false, true);
if(success){
ofLogVerbose() << "adding addon data file: " << d;
}else {
ofLogWarning() << "Can not add addon data file: " << d;
}
}else if(filesystem::is_directory(path)){
ofDirectory dir(path);
string dest = ofFilePath::join(projectDir, "bin/data/");
ofStringReplace(d, "data/", ""); // avoid to copy files at /data/data/*
bool success = dir.copyTo(ofFilePath::join(dest, d), false, true);
if(success){
ofLogVerbose() << "adding addon data folder: " << d;
}else{
ofLogWarning() << "Can not add addon data folder: " << d;
}
}
}else{
ofLogWarning() << "addon data file does not exist, skipping: " << d;
}
}
}
}

void baseProject::addAddon(ofAddon & addon){
Expand Down
2 changes: 1 addition & 1 deletion ofxProjectGenerator/src/projects/baseProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class baseProject {
virtual void addDefine(std::string define, LibType libType = RELEASE_LIB) {}

virtual void addAddon(std::string addon);
virtual void addAddon(ofAddon & addon);
virtual void addAddon(ofAddon & addon);

std::string getName() { return projectName;}
std::string getPath() { return projectDir; }
Expand Down