Skip to content

Commit

Permalink
Support ADDON_DATA in addon_config.mk (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroMTB authored and arturoc committed May 30, 2019
1 parent 6b36107 commit 96d97bb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ofxProjectGenerator/src/addons/ofAddon.cpp
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
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
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

0 comments on commit 96d97bb

Please sign in to comment.