@@ -73,42 +73,48 @@ fileJson cppProperties;
7373std::string VSCodeProject::LOG_NAME = " VSCodeProject" ;
7474
7575bool VSCodeProject::createProjectFile (){
76- workspace.fileName = projectDir / (projectName + " .code-workspace" );
77- cppProperties.fileName = projectDir / " .vscode/c_cpp_properties.json" ;
7876
79- // Copy all files from template, recursively
77+ # if defined(__MINGW32__) || defined(__MINGW64__)
8078 try {
81- // dangerous as its copying src/ and bin/ into existing project files
82- // fs::copy(templatePath, projectDir, fs::copy_options::overwrite_existing | fs::copy_options::recursive);
83-
84- // tmp fix for now - explicit copy of files needed
85- fs::copy (templatePath / " .vscode" , projectDir / " .vscode" , fs::copy_options::overwrite_existing | fs::copy_options::recursive);
86- fs::copy (templatePath / " Makefile" , projectDir, fs::copy_options::skip_existing | fs::copy_options::recursive);
87- fs::copy (templatePath / " config.make" , projectDir, fs::copy_options::skip_existing | fs::copy_options::recursive);
88- fs::copy (templatePath / " emptyExample.code-workspace" , projectDir, fs::copy_options::overwrite_existing | fs::copy_options::recursive);
89- fs::copy (templatePath / " template.config" , projectDir, fs::copy_options::overwrite_existing | fs::copy_options::recursive);
90-
79+ fs::remove_all (projectDir / " .vscode" );
9180 } catch (fs::filesystem_error& e) {
92- ofLogError (LOG_NAME) << " error copying folder " << templatePath << " : " << projectDir << " : " << e.what ();
81+ ofLogError (LOG_NAME) << " error removing folder .vscode " << e.what ();
9382 return false ;
9483 }
84+ #endif
85+
86+ // Copy all files from template, recursively
87+ // dangerous as its copying src/ and bin/ into existing project files
88+ // fs::copy(templatePath, projectDir, fs::copy_options::overwrite_existing | fs::copy_options::recursive);
9589
96-
97- auto templateConfig { projectDir / " template.config" };
98- try {
99- fs::remove ( templateConfig );
100- } catch (fs::filesystem_error& e) {
101- ofLogError (LOG_NAME) << " error removing file " << " : " << templateConfig << " : " << e.what ();
102- }
103-
104-
105- // Rename Project Workspace
10690 try {
107- fs::rename (projectDir / " emptyExample.code-workspace " , workspace. fileName );
91+ fs::copy (templatePath / " .vscode " , projectDir / " .vscode " , fs::copy_options::overwrite_existing | fs::copy_options::recursive );
10892 } catch (fs::filesystem_error& e) {
109- ofLogError (LOG_NAME) << " error renaming project " << " : " << workspace. fileName << " : " << e.what ();
93+ ofLogError (LOG_NAME) << " error copying folder " << templatePath << " : " << projectDir << " : " << e.what ();
11094 return false ;
11195 }
96+
97+
98+ workspace.fileName = projectDir / (projectName + " .code-workspace" );
99+ cppProperties.fileName = projectDir / " .vscode/c_cpp_properties.json" ;
100+
101+ copyTemplateFiles.push_back ({
102+ templatePath / " Makefile" ,
103+ projectDir / " Makefile"
104+ });
105+ copyTemplateFiles.push_back ({
106+ templatePath / " config.make" ,
107+ projectDir / " config.make"
108+ });
109+ copyTemplateFiles.push_back ({
110+ templatePath / " emptyExample.code-workspace" ,
111+ projectDir / workspace.fileName
112+ });
113+
114+ for (auto & c : copyTemplateFiles) {
115+ c.run ();
116+ }
117+
112118 return true ;
113119}
114120
@@ -133,18 +139,7 @@ void VSCodeProject::addAddon(ofAddon & addon) {
133139
134140
135141bool VSCodeProject::saveProjectFile (){
136- // alert("VSCodeProject::saveProjectFile() ");
137- // alert("--- VSCodeProject::extSrcPaths() ");
138- // for (auto & e : extSrcPaths) {
139- // cout << e << endl;
140- // workspace.addPath(e);
141- //
142- // }
143- // alert("--- VSCodeProject::extSrcPaths() ");
144-
145-
146142 workspace.data [" openFrameworksProjectGeneratorVersion" ] = getPGVersion ();
147-
148143 workspace.save ();
149144 cppProperties.save ();
150145 return true ;
0 commit comments