Skip to content

Commit f9cad1a

Browse files
authored
changes android2024
1 parent ccda652 commit f9cad1a

File tree

5 files changed

+54
-49
lines changed

5 files changed

+54
-49
lines changed

commandLine/src/projects/CBLinuxProject.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
std::string CBLinuxProject::LOG_NAME { "CBLinuxProject" };
1414

1515
bool CBLinuxProject::createProjectFile(){
16-
// FIXME: This only exists here, not other projects. I think it should be removed
17-
if (!fs::exists(projectDir)) {
18-
fs::create_directory(projectDir);
19-
}
20-
2116
vector < std::pair <fs::path, fs::path > > fromTo {
2217
{ templatePath / ("emptyExample_" + target + ".cbp"), projectDir / (projectName + ".cbp") },
2318
{ templatePath / ("emptyExample_" + target + ".workspace"), projectDir / (projectName + ".workspace") },

commandLine/src/projects/android2024.cpp

+46-31
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,60 @@ android2024Project::android2024Project(const std::string & target) : baseProject
1111

1212
bool android2024Project::createProjectFile(){
1313
// Make sure project name doesn't include "-"
14-
std::string packageName { projectName };
15-
ofStringReplace(packageName, "-", "");
14+
// std::string packageName { projectName };
15+
// ofStringReplace(packageName, "-", "");
1616

17-
if (!fs::exists(projectDir)) {
18-
fs::create_directory(projectDir);
17+
18+
for (auto & f : vector<fs::path> {
19+
"build.gradle",
20+
"gradle",
21+
"gradle.properties",
22+
"local.properties",
23+
"ofApp/gradle.properties",
24+
"ofApp/proguard-rules.pro",
25+
"proguard.cfg",
26+
"settings.gradle",
27+
}) {
28+
copyTemplateFiles.push_back({
29+
templatePath / f,
30+
projectDir / f
31+
});
1932
}
2033

21-
// std::vector <std::string> fileNames {
22-
// "build.gradle",
23-
// "settings.gradle",
24-
// "AndroidManifest.xml",
25-
// ".gitignore",
26-
// "gradlew",
27-
// "gradlew.bat",
28-
// };
34+
copyTemplateFiles.push_back({
35+
templatePath / "ofApp" / "build.gradle",
36+
projectDir / "ofApp" / "build.gradle",
37+
{ { "emptyExample", projectName } }
38+
});
2939

40+
// copy and replace where needed
41+
for (auto & c : copyTemplateFiles) {
42+
c.run();
43+
}
44+
45+
// TODO: try
46+
fs::create_directory(projectDir / "ofApp");
47+
// copy recursively and try not overwrite code.
3048
try {
31-
fs::copy(templatePath, projectDir, fs::copy_options::overwrite_existing | fs::copy_options::recursive);
32-
} catch (std::exception& e) {
33-
std::cout << e.what();
34-
std::cout << "unable to copy android2024 template recursively" << std::endl;
49+
fs::copy(
50+
templatePath / "ofApp" / "src",
51+
projectDir / "ofApp" / "src",
52+
fs::copy_options::recursive | fs::copy_options::skip_existing
53+
);
54+
} catch(fs::filesystem_error & e) {
55+
ofLogError() << "copy failed " << e.what() << endl;
3556
}
3657

37-
// for (auto & f : fileNames) {
38-
// fs::path to { projectDir / f };
39-
// if (!fs::exists(to)) {
40-
// fs::path from { templatePath / f };
41-
// try {
42-
// fs::copy(from, to);
43-
// } catch(fs::filesystem_error & e) {
44-
// if (f == "AndroidManifest.xml") {
45-
// findandreplaceInTexfile(to, "TEMPLATE_PACKAGE_NAME", packageName);
46-
// } else {
47-
// ofLogError(LOG_NAME) << "error copying template from " << from << " to " << to << e.what();
48-
// }
49-
// }
50-
// }
58+
59+
// Leftovers from other
60+
61+
// try {
62+
// fs::copy(templatePath, projectDir, fs::copy_options::overwrite_existing | fs::copy_options::recursive);
63+
// } catch (std::exception& e) {
64+
// std::cout << e.what();
65+
// std::cout << "unable to copy android2024 template recursively" << std::endl;
5166
// }
52-
//
67+
5368
// for (auto & p : { string("res") , string("srcJava"), string("gradle") }) {
5469
// fs::copy (templatePath / p, projectDir / p, fs::copy_options::recursive);
5570
// }

commandLine/src/projects/androidStudioProject.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ bool AndroidStudioProject::createProjectFile(){
1414
std::string packageName { projectName };
1515
ofStringReplace(packageName, "-", "");
1616

17-
if (!fs::exists(projectDir)) {
18-
fs::create_directory(projectDir);
19-
}
2017

2118
std::vector <std::string> fileNames {
2219
"build.gradle",

commandLine/src/projects/baseProject.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,25 @@ bool baseProject::create(const fs::path & path, string templateName){
143143
projectDir = path;
144144
auto projectPath = fs::canonical(fs::current_path() / path);
145145
projectName = projectPath.filename().string();
146-
147-
// cout << "templatePath " << templatePath << endl;
148-
// cout << "projectDir " << projectDir << endl;
149-
// cout << "projectPath " << projectPath << endl;
150-
// cout << "projectName = " << projectName << endl;
151-
//
146+
147+
148+
// we had this in some projects. if we decide to keep this is the place
149+
// if (!fs::exists(projectDir)) {
150+
// fs::create_directory(projectDir);
151+
// }
152152
bool bDoesDirExist = false;
153153

154154
fs::path project { projectDir / "src" };
155155

156156
if (fs::exists(project) && fs::is_directory(project)) {
157157
bDoesDirExist = true;
158158
} else {
159-
for (auto & p : { string("src") , string("bin") }) {
159+
for (auto & p : { fs::path("src") , fs::path("bin") }) {
160160
fs::copy (templatePath / p, projectDir / p, fs::copy_options::recursive);
161161
}
162162
}
163163

164+
164165
bool ret = createProjectFile();
165166
if(!ret) return false;
166167

commandLine/src/projects/qtcreatorproject.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ QtCreatorProject::QtCreatorProject(const std::string & target) : baseProject(tar
1111

1212
bool QtCreatorProject::createProjectFile(){
1313
// alert("QtCreatorProject::createProjectFile " + projectDir.string());
14-
if (!fs::exists(projectDir)) {
15-
fs::create_directory(projectDir);
16-
}
1714

1815
fs::path qbsFile { fs::path { projectName + ".qbs" } };
1916
vector < std::pair <fs::path, fs::path > > fromTo {

0 commit comments

Comments
 (0)