Skip to content

Commit 71130da

Browse files
authored
XCode more changes : PG v40 (#504)
1 parent 6550a26 commit 71130da

6 files changed

Lines changed: 87 additions & 98 deletions

File tree

commandLine/src/defines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#define OFPROJECTGENERATOR_MAJOR_VERSION 0
22
#define OFPROJECTGENERATOR_MINOR_VERSION 12
3-
#define OFPROJECTGENERATOR_PATCH_VERSION 0
3+
#define OFPROJECTGENERATOR_PATCH_VERSION 1
44

commandLine/src/projects/baseProject.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,6 @@ bool baseProject::create(const fs::path & path, string templateName){
225225
}
226226
}
227227

228-
// only add unique paths
229-
// vector < fs::path > paths;
230-
// for (auto & f : fileNames) {
231-
// auto dir = fs::path(f).parent_path().filename();
232-
// if (std::find(paths.begin(), paths.end(), dir) == paths.end()) {
233-
// paths.emplace_back(dir);
234-
// addInclude(dir.string());
235-
// }
236-
// }
237228

238229
// FIXME: Port to std::list, so no comparison is needed.
239230
// only add unique paths

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 "39"
3+
#define PG_VERSION "40"
44

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

commandLine/src/projects/xcodeProject.cpp

Lines changed: 80 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ xcodeProject::xcodeProject(const string & target) : baseProject(target){
1717
folderUUID = {
1818
{ "src", "E4B69E1C0A3A1BDC003C02F2" },
1919
{ "addons", "BB4B014C10F69532006C3DED" },
20-
{ "openFrameworks", "191EF70929D778A400F35F26" },
21-
// { "localAddons", "6948EE371B920CB800B5AC1A" },
20+
{ "openFrameworks", "191EF70929D778A400F35F26" },
2221
{ "", "E4B69B4A0A3A1720003C02F2" }
22+
// { "localAddons", "6948EE371B920CB800B5AC1A" },
2323
};
2424

2525
buildConfigurationListUUID = "E4B69B5A0A3A1756003C02F2";
@@ -47,8 +47,8 @@ xcodeProject::xcodeProject(const string & target) : baseProject(target){
4747
folderUUID = {
4848
{ "src", "E4D8936A11527B74007E1F53" },
4949
{ "addons", "BB16F26B0F2B646B00518274" },
50-
// { "localAddons", "6948EE371B920CB800B5AC1A" },
5150
{ "", "29B97314FDCFA39411CA2CEA" }
51+
// { "localAddons", "6948EE371B920CB800B5AC1A" },
5252
};
5353

5454
buildConfigurationListUUID = "1D6058900D05DD3D006BFB54"; //check
@@ -71,47 +71,33 @@ bool xcodeProject::createProjectFile(){
7171
}
7272
fs::create_directories(xcodeProject);
7373

74+
// if project is outside OF, rootReplacements is set to be used in XCode and make
75+
if (!fs::equivalent(getOFRoot(), fs::path{"../../.."})) {
76+
string root { ofPathToString(getOFRoot()) };
77+
rootReplacements = { "../../..", root };
78+
}
79+
7480
copyTemplateFiles.push_back({
7581
templatePath / "emptyExample.xcodeproj" / "project.pbxproj",
7682
xcodeProject / "project.pbxproj",
77-
{{ "emptyExample", projectName }}
83+
{{ "emptyExample", projectName },
84+
rootReplacements }
7885
});
7986

8087
copyTemplateFiles.push_back({
8188
templatePath / "Project.xcconfig",
82-
projectDir / "Project.xcconfig"
89+
projectDir / "Project.xcconfig",
90+
{ rootReplacements }
8391
});
84-
85-
for (auto & c : copyTemplateFiles) {
86-
c.run();
87-
}
88-
89-
fs::path binDirectory { projectDir / "bin" };
90-
fs::path dataDir { binDirectory / "data" };
91-
92-
if (!fs::exists(binDirectory)) {
93-
cout << "creating dataDir " << dataDir << endl;
94-
fs::create_directories(dataDir);
95-
}
96-
97-
if (fs::exists(binDirectory)) {
98-
// originally only on IOS
99-
//this is needed for 0.9.3 / 0.9.4 projects which have iOS media assets in bin/data/
100-
// TODO: Test on IOS
101-
fs::path srcDataDir { templatePath / "bin" / "data" };
102-
if (fs::exists(srcDataDir) && fs::is_directory(srcDataDir)) {
103-
baseProject::recursiveCopyContents(srcDataDir, dataDir);
104-
}
105-
}
106-
107-
if( target == "osx" ){
92+
93+
if (target == "osx") {
10894
// TODO: TEST
10995
for (auto & f : { "openFrameworks-Info.plist", "of.entitlements" }) {
110-
fs::copy(templatePath / f, projectDir / f, fs::copy_options::overwrite_existing);
96+
copyTemplateFiles.push_back({ templatePath / f, projectDir / f });
11197
}
112-
}else{
98+
} else {
11399
for (auto & f : { "ofxiOS-Info.plist", "ofxiOS_Prefix.pch" }) {
114-
fs::copy(templatePath / f, projectDir / f, fs::copy_options::overwrite_existing);
100+
copyTemplateFiles.push_back({ templatePath / f, projectDir / f });
115101
}
116102

117103
fs::path from = templatePath / "mediaAssets";
@@ -123,44 +109,45 @@ bool xcodeProject::createProjectFile(){
123109

124110
saveScheme();
125111

126-
if(target=="osx"){
112+
if(target == "osx"){
127113
saveMakefile();
128114
}
115+
116+
// Execute all file copy and replacements, including ones in saveScheme, saveMakefile
117+
for (auto & c : copyTemplateFiles) {
118+
c.run();
119+
}
120+
121+
122+
123+
// NOW only files being copied
124+
125+
fs::path projectDataDir { projectDir / "bin" / "data" };
129126

130-
// Calculate OF Root in relation to each project (recursively);
131-
// fs::path relRoot { getOFRoot() };
132-
133-
// // FIXME: maybe not needed anymore
134-
// if (ofIsPathInPath(projectDir, getOFRoot())) {
135-
// setOFRoot(fs::relative(getOFRoot(), projectDir));
136-
//// relRoot = fs::relative(getOFRoot(), projectDir);
137-
//// alert ("relRoot = " + relRoot.string());
138-
// } else {
139-
//// alert ("ofIsPathInPath not");
140-
// }
127+
if (!fs::exists(projectDataDir)) {
128+
cout << "creating dataDir " << projectDataDir << endl;
129+
fs::create_directories(projectDataDir);
130+
}
141131

132+
if (fs::exists(projectDataDir)) {
133+
// originally only on IOS
134+
//this is needed for 0.9.3 / 0.9.4 projects which have iOS media assets in bin/data/
135+
// TODO: Test on IOS
136+
fs::path templateDataDir { templatePath / "bin" / "data" };
137+
if (fs::exists(templateDataDir) && fs::is_directory(templateDataDir)) {
138+
baseProject::recursiveCopyContents(templateDataDir, projectDataDir);
139+
}
140+
}
142141

143142
addCommand("# ---- PG VERSION " + getPGVersion());
144143
addCommand("Add :openFrameworksProjectGeneratorVersion string " + getPGVersion());
145144

146145
fileProperties fp;
147146
addFile("App.xcconfig", "", fp);
148-
addFile(fs::path{"bin"} / "data", "", fp);
149147

148+
fp.absolute = true;
149+
addFile(fs::path{"bin"} / "data", "", fp);
150150

151-
if (!fs::equivalent(getOFRoot(), fs::path{"../../.."})) {
152-
string root { ofPathToString(getOFRoot()) };
153-
// alert ("fs not equivalent to ../../.. root = " + root);
154-
findandreplaceInTexfile(projectDir / (projectName + ".xcodeproj/project.pbxproj"), "../../..", root);
155-
findandreplaceInTexfile(projectDir / "Project.xcconfig", "../../..", root);
156-
if( target == "osx" ){
157-
findandreplaceInTexfile(projectDir / "Makefile", "../../..", root);
158-
// MARK: not needed because baseProject::save() does the same
159-
// findandreplaceInTexfile(projectDir / "config.make", "../../..", root);
160-
}
161-
} else {
162-
// alert ("fs equivalent " + relRoot.string());
163-
}
164151
return true;
165152
}
166153

@@ -173,38 +160,43 @@ void xcodeProject::saveScheme(){
173160
}
174161
fs::create_directories(schemeFolder);
175162

176-
if(target=="osx"){
177-
for (auto & f : { string("Release"), string("Debug") }) {
178-
auto fileFrom = templatePath / ("emptyExample.xcodeproj/xcshareddata/xcschemes/emptyExample " + f + ".xcscheme");
179-
auto fileTo = schemeFolder / (projectName + " " +f+ ".xcscheme");
180-
fs::copy(fileFrom, fileTo);
181-
findandreplaceInTexfile(fileTo, "emptyExample", projectName);
163+
if (target == "osx") {
164+
for (auto & f : { "Release", "Debug" }) {
165+
copyTemplateFiles.push_back({
166+
templatePath / ("emptyExample.xcodeproj/xcshareddata/xcschemes/emptyExample " + string(f) + ".xcscheme"),
167+
schemeFolder / (projectName + " " +f+ ".xcscheme"),
168+
{{ "emptyExample", projectName }}
169+
});
182170
}
183171

184-
auto fileTo = projectDir / (projectName + ".xcodeproj/project.xcworkspace");
185-
auto fileFrom = templatePath / "emptyExample.xcodeproj/project.xcworkspace";
186-
fs::copy(fileFrom, fileTo);
187-
}else{
172+
copyTemplateFiles.push_back({
173+
projectDir / (projectName + ".xcodeproj/project.xcworkspace"),
174+
templatePath / "emptyExample.xcodeproj/project.xcworkspace"
175+
});
176+
} else {
188177

189178
// MARK:- IOS sector;
190-
auto fileFrom = templatePath / "emptyExample.xcodeproj/xcshareddata/xcschemes/emptyExample.xcscheme";
191-
auto fileTo = schemeFolder / (projectName + ".xcscheme");
192-
fs::copy(fileFrom, fileTo);
193-
findandreplaceInTexfile(fileTo, "emptyExample", projectName);
179+
copyTemplateFiles.push_back({
180+
templatePath / "emptyExample.xcodeproj/xcshareddata/xcschemes/emptyExample.xcscheme",
181+
schemeFolder / (projectName + ".xcscheme"),
182+
{{ "emptyExample", projectName }}
183+
});
194184
}
195185
}
196186

197187
void xcodeProject::saveMakefile(){
198188
// alert ("saveMakefile " , 35);
199-
for (auto & f : { "Makefile", "config.make" }) {
200-
fs::path fileFrom = templatePath / f;
201-
fs::path fileTo = projectDir / f;
202-
// Always overwrite for now, so we can have the original file from template before substituting anything
203-
// if (!fs::exists(fileTo))
204-
{
205-
fs::copy(fileFrom, fileTo, fs::copy_options::overwrite_existing);
206-
}
207-
}
189+
copyTemplateFiles.push_back({
190+
templatePath / "Makefile",
191+
projectDir / "Makefile",
192+
{ rootReplacements }
193+
});
194+
copyTemplateFiles.push_back({
195+
templatePath / "config.make",
196+
projectDir / "config.make"
197+
});
198+
199+
208200
}
209201

210202
bool xcodeProject::loadProjectFile(){ //base
@@ -286,8 +278,7 @@ string xcodeProject::getFolderUUID(const fs::path & folder, bool isFolder, fs::p
286278

287279
if (folder.begin()->string() == "addons") {
288280
addCommand("Add :objects:"+thisUUID+":sourceTree string <group>");
289-
// fs::path addonFolder = fs::relative(fullPath, "addons");
290-
fs::path addonFolder = fs::path(fullPath).filename();
281+
fs::path addonFolder { fs::path(fullPath).filename() };
291282
addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(addonFolder));
292283
// alert ("group " + folder.string() + " : " + base.string() + " : " + addonFolder.string(), 32);
293284
} else {
@@ -749,11 +740,14 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con
749740
// }
750741
addCommand("Add :objects:"+UUID+":fileEncoding string 4");
751742
addCommand("Add :objects:"+UUID+":isa string PBXFileReference");
752-
// addCommand("Add :objects:"+UUID+":sourceTree string <group>");
753-
addCommand("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT");
754743
addCommand("Add :objects:"+UUID+":lastKnownFileType string " + fileType);
755-
addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path));
756744
addCommand("Add :objects:"+UUID+":name string " + ofPathToString(path.filename()));
745+
if (fp.absolute) {
746+
addCommand("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT");
747+
addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path));
748+
} else {
749+
addCommand("Add :objects:"+UUID+":sourceTree string <group>");
750+
}
757751

758752
string folderUUID;
759753
if (fp.isSrc) {

commandLine/src/projects/xcodeProject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class xcodeProject : public baseProject {
3636

3737

3838
struct fileProperties {
39+
bool absolute = false;
3940
bool reference = true;
4041
bool addToBuildPhase = false;
4142
bool codeSignOnCopy = false;
@@ -86,4 +87,7 @@ class xcodeProject : public baseProject {
8687

8788
// TODO: Phase out relRoot. totally
8889
fs::path relRoot = "../../..";
90+
91+
std::pair<string, string> rootReplacements;
92+
8993
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#include "LibraryBinary.h"
22

33
const std::vector<std::string> LibraryBinary::archs { "x86", "Win32", "x64", "armv7", "ARM64", "ARM64EC" };
4-
const std::vector<std::string> LibraryBinary::targets{ "Debug","Release" };
4+
const std::vector<std::string> LibraryBinary::targets{ "Debug", "Release" };

0 commit comments

Comments
 (0)