Skip to content

Commit ecdb901

Browse files
authored
Fix XCode issue when html or random files are in src folders (#489)
1 parent 401064e commit ecdb901

8 files changed

Lines changed: 101 additions & 2 deletions

File tree

commandLine/commandLine.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@
265265
<ClCompile Include="src\main.cpp" />
266266
<ClCompile Include="src\addons\ofAddon.cpp" />
267267
<ClCompile Include="src\projects\androidStudioProject.cpp" />
268+
<ClCompile Include="src\projects\android2024.cpp" />
268269
<ClCompile Include="src\projects\baseProject.cpp" />
269270
<ClCompile Include="src\projects\CBLinuxProject.cpp" />
270271
<ClCompile Include="src\projects\CBWinProject.cpp" />
@@ -280,6 +281,7 @@
280281
<ClInclude Include="src\optionparser.h" />
281282
<ClInclude Include="src\addons\ofAddon.h" />
282283
<ClInclude Include="src\projects\androidStudioProject.h" />
284+
<ClInclude Include="src\projects\android2024.h" />
283285
<ClInclude Include="src\projects\baseProject.h" />
284286
<ClInclude Include="src\projects\CBLinuxProject.h" />
285287
<ClInclude Include="src\projects\CBWinProject.h" />

commandLine/commandLine.vcxproj.filters

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<ClCompile Include="src\main.cpp" />
55
<ClCompile Include="src\addons\ofAddon.cpp" />
66
<ClCompile Include="src\projects\androidStudioProject.cpp" />
7+
<ClCompile Include="src\projects\android2024.cpp" />
78
<ClCompile Include="src\projects\baseProject.cpp" />
89
<ClCompile Include="src\projects\CBLinuxProject.cpp" />
910
<ClCompile Include="src\projects\CBWinProject.cpp" />
@@ -20,6 +21,7 @@
2021
<ClInclude Include="src\optionparser.h" />
2122
<ClInclude Include="src\addons\ofAddon.h" />
2223
<ClInclude Include="src\projects\androidStudioProject.h" />
24+
<ClInclude Include="src\projects\android2024.h" />
2325
<ClInclude Include="src\projects\baseProject.h" />
2426
<ClInclude Include="src\projects\CBLinuxProject.h" />
2527
<ClInclude Include="src\projects\CBWinProject.h" />

commandLine/commandLine.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
03433CF32BF3B842001412CF /* android2024.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03433CF22BF3B842001412CF /* android2024.cpp */; };
1011
03B57CDD2AC5B1C6005F56E0 /* VSCodeProject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03B57CDB2AC5B1C6005F56E0 /* VSCodeProject.cpp */; };
1112
"1A7D4C46-3FD3-4E35-9025-D0E93ECAD7DD" /* qtcreatorproject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = "C5A3016A-B663-4FE7-B6E6-421C5F168447" /* qtcreatorproject.cpp */; };
1213
"200CCA92-FAEE-4CEB-903B-ABB0D56B991F" /* ofAddon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = "41F34CBC-2E3E-4C3D-B106-F9D6746B6FF0" /* ofAddon.cpp */; };
@@ -46,6 +47,8 @@
4647
/* End PBXCopyFilesBuildPhase section */
4748

4849
/* Begin PBXFileReference section */
50+
03433CF12BF3B842001412CF /* android2024.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = android2024.h; sourceTree = "<group>"; };
51+
03433CF22BF3B842001412CF /* android2024.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = android2024.cpp; sourceTree = "<group>"; };
4952
03B57CDB2AC5B1C6005F56E0 /* VSCodeProject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VSCodeProject.cpp; sourceTree = "<group>"; };
5053
03B57CDC2AC5B1C6005F56E0 /* VSCodeProject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VSCodeProject.h; sourceTree = "<group>"; };
5154
"0C9DC8B7-7304-4A82-BAED-18F7A422ECA1" /* xcodeProject.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = xcodeProject.h; path = src/projects/xcodeProject.h; sourceTree = SOURCE_ROOT; };
@@ -143,6 +146,8 @@
143146
"DDA07621-E95C-4267-B1B9-0127E0215328" /* CBLinuxProject.h */,
144147
"D8A84D0F-1123-44F7-9D8D-79F8E2A0BFF4" /* CBWinProject.cpp */,
145148
"1CFE3EC7-9370-47FF-A02D-1932663E6C10" /* CBWinProject.h */,
149+
03433CF22BF3B842001412CF /* android2024.cpp */,
150+
03433CF12BF3B842001412CF /* android2024.h */,
146151
"FFD740F7-8E04-4563-A856-D4E402AF9C0E" /* androidStudioProject.cpp */,
147152
"7D752B3A-9B2F-45F6-94D3-60D5A9600B13" /* androidStudioProject.h */,
148153
"247AA402-B7FD-4D0C-BB21-F3A90A35ADE7" /* baseProject.cpp */,
@@ -317,6 +322,7 @@
317322
"7F2BBCD1-F22D-454A-9100-33D1C12BEA70" /* androidStudioProject.cpp in Sources */,
318323
"E79B31E1-CF27-4D77-B2F2-6AEC329A9F50" /* baseProject.cpp in Sources */,
319324
"1A7D4C46-3FD3-4E35-9025-D0E93ECAD7DD" /* qtcreatorproject.cpp in Sources */,
325+
03433CF32BF3B842001412CF /* android2024.cpp in Sources */,
320326
"C2428661-BDEC-41D7-8150-C9BA5EE86C0C" /* visualStudioProject.cpp in Sources */,
321327
"DBD7E2AC-672A-4FD9-B0A4-DF24111D17FB" /* xcodeProject.cpp in Sources */,
322328
"B07B8E19-F9DE-4E97-8833-859CD9267D30" /* LibraryBinary.cpp in Sources */,
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include "android2024.h"
2+
#include "ofLog.h"
3+
#include "ofFileUtils.h"
4+
#include "Utils.h"
5+
#include "ofUtils.h"
6+
#include <regex>
7+
8+
std::string android2024Project::LOG_NAME = "android2024Project";
9+
10+
android2024Project::android2024Project(const std::string & target) : baseProject(target) {}
11+
12+
bool android2024Project::createProjectFile(){
13+
// Make sure project name doesn't include "-"
14+
std::string packageName { projectName };
15+
ofStringReplace(packageName, "-", "");
16+
17+
if (!fs::exists(projectDir)) {
18+
fs::create_directory(projectDir);
19+
}
20+
21+
// std::vector <std::string> fileNames {
22+
// "build.gradle",
23+
// "settings.gradle",
24+
// "AndroidManifest.xml",
25+
// ".gitignore",
26+
// "gradlew",
27+
// "gradlew.bat",
28+
// };
29+
30+
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;
35+
}
36+
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+
// }
51+
// }
52+
//
53+
// for (auto & p : { string("res") , string("srcJava"), string("gradle") }) {
54+
// fs::copy (templatePath / p, projectDir / p, fs::copy_options::recursive);
55+
// }
56+
//
57+
// findandreplaceInTexfile( projectDir / "res/values/strings.xml", "TEMPLATE_APP_NAME", projectName);
58+
//
59+
// fs::path from { projectDir / "srcJava/cc/openframeworks/APP_NAME" };
60+
// fs::path to { projectDir / ("srcJava/cc/openframeworks/" + projectName) };
61+
// // TODO: try catch
62+
// fs::rename ( from, to );
63+
// findandreplaceInTexfile(to / "OFActivity.java", "TEMPLATE_APP_NAME", projectName);
64+
65+
return true;
66+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include "baseProject.h"
4+
5+
class android2024Project : public baseProject {
6+
public:
7+
android2024Project(const std::string & target);
8+
9+
bool createProjectFile();
10+
void addInclude(std::string includeName){}
11+
void addLibrary(const LibraryBinary & lib){}
12+
void addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type=DEFAULT){};
13+
bool loadProjectFile() { return false; };
14+
bool saveProjectFile(){ return false; };
15+
static std::string LOG_NAME;
16+
};

commandLine/src/projects/baseProject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#define PG_VERSION "34"
3+
#define PG_VERSION "35"
44

55
#include "ofAddon.h"
66
#include "ofFileUtils.h"

commandLine/src/projects/xcodeProject.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con
745745
if (fileType == "") {
746746
if (fs::is_directory(path)) {
747747
fileType = "folder";
748+
} else {
749+
return {};
748750
}
749751
}
750752

commandLine/src/utils/Utils.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "Utils.h"
99
#include "ofUtils.h"
1010

11+
#include "android2024.h"
1112
#include "androidStudioProject.h"
1213
#include "CBWinProject.h"
1314
#include "visualStudioProject.h"
@@ -422,8 +423,12 @@ unique_ptr<baseProject> getTargetProject(const string & targ) {
422423
) {
423424
// return unique_ptr<QtCreatorProject>(new QtCreatorProject(targ));
424425
return unique_ptr<VSCodeProject>(new VSCodeProject(targ));
425-
} else if (targ == "android") {
426+
}
427+
else if (targ == "android") {
426428
return unique_ptr<AndroidStudioProject>(new AndroidStudioProject(targ));
429+
}
430+
else if (targ == "android2024") {
431+
return unique_ptr<android2024Project>(new android2024Project(targ));
427432
} else if (targ == "vscode") {
428433
return unique_ptr<VSCodeProject>(new VSCodeProject(targ));
429434
} else if (targ == "qtcreator") {

0 commit comments

Comments
 (0)