Skip to content

Commit 96d97bb

Browse files
hiroMTBarturoc
authored andcommitted
Support ADDON_DATA in addon_config.mk (#190)
1 parent 6b36107 commit 96d97bb

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

ofxProjectGenerator/src/addons/ofAddon.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ void ofAddon::parseVariableValue(string variable, string value, bool addToValue,
310310
}
311311

312312
if(variable == "ADDON_DATA"){
313-
addReplaceStringVector(data,value,addonRelPath,addToValue);
313+
addReplaceStringVector(data,value,"",addToValue);
314314
}
315315

316316
if(variable == "ADDON_LIBS_EXCLUDE"){

ofxProjectGenerator/src/projects/baseProject.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,43 @@ void baseProject::addAddon(std::string addonName){
254254
auto standardPath = ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonName);
255255
addon.fromFS(standardPath, target);
256256
}
257+
257258
addAddon(addon);
259+
260+
// Process values from ADDON_DATA
261+
if(addon.data.size()){
262+
263+
for(auto& d : addon.data){
264+
265+
filesystem::path path(ofFilePath::join(addon.addonPath, d));
266+
267+
if(filesystem::exists(path)){
268+
if (filesystem::is_regular_file(path)){
269+
ofFile src(path);
270+
string dest = ofFilePath::join(projectDir, "bin/data/");
271+
ofStringReplace(d, "data/", ""); // avoid to copy files at /data/data/*
272+
bool success = src.copyTo(ofFilePath::join(dest, d), false, true);
273+
if(success){
274+
ofLogVerbose() << "adding addon data file: " << d;
275+
}else {
276+
ofLogWarning() << "Can not add addon data file: " << d;
277+
}
278+
}else if(filesystem::is_directory(path)){
279+
ofDirectory dir(path);
280+
string dest = ofFilePath::join(projectDir, "bin/data/");
281+
ofStringReplace(d, "data/", ""); // avoid to copy files at /data/data/*
282+
bool success = dir.copyTo(ofFilePath::join(dest, d), false, true);
283+
if(success){
284+
ofLogVerbose() << "adding addon data folder: " << d;
285+
}else{
286+
ofLogWarning() << "Can not add addon data folder: " << d;
287+
}
288+
}
289+
}else{
290+
ofLogWarning() << "addon data file does not exist, skipping: " << d;
291+
}
292+
}
293+
}
258294
}
259295

260296
void baseProject::addAddon(ofAddon & addon){

ofxProjectGenerator/src/projects/baseProject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class baseProject {
6666
virtual void addDefine(std::string define, LibType libType = RELEASE_LIB) {}
6767

6868
virtual void addAddon(std::string addon);
69-
virtual void addAddon(ofAddon & addon);
69+
virtual void addAddon(ofAddon & addon);
7070

7171
std::string getName() { return projectName;}
7272
std::string getPath() { return projectDir; }

0 commit comments

Comments
 (0)