Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion commandLine/src/addons/ofAddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,9 @@ bool ofAddon::load(string addonName, const fs::path& projectDir, const string& t
// we want to set addonMakeName before cleaning the addon name, so it is preserved in the exact same way as it was passed, and the addons.make file can be (re)constructed properly
this->addonMakeName = addonName;

// addonName = cleanName(addonName);
if(parseCleanName){
addonName = cleanName(addonName);
}

if(addonName.empty()){
ofLogError("baseProject::addAddon") << "cant add addon with empty name";
Expand Down
11 changes: 10 additions & 1 deletion commandLine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ enum optionIndex { UNKNOWN,
GET_HOST_PLATFORM,
COMMAND,
BACKUP_PROJECT_FILES,
FRAMEWORKS
FRAMEWORKS,
CLEANNAME_DISABLE
};

constexpr option::Descriptor usage[] = {
Expand All @@ -50,6 +51,8 @@ constexpr option::Descriptor usage[] = {
{ BACKUP_PROJECT_FILES, 0, "b", "backup", option::Arg::None, " --backup, -b \tbackup project files when replacing with template" },

{ FRAMEWORKS, 0, "f", "frameworks", option::Arg::Optional, " --frameworks, -f \tframeworks list (such as Vision,ARKit)" },

{ CLEANNAME_DISABLE, 0, "n", "cleanname", option::Arg::Optional, " --cleanname, -f \tcleanname" },

{ 0, 0, 0, 0, 0, 0 }
};
Expand Down Expand Up @@ -90,6 +93,7 @@ bool bHelpRequested; // did we request help?
bool bListTemplates; // did we request help?
bool bDryRun; // do dry run (useful for debugging recursive update)
bool bBackup;
bool bCleanName = true;

void consoleSpace() {
std::cout << std::endl;
Expand Down Expand Up @@ -462,6 +466,11 @@ int main(int argc, char ** argv) {
if (options[DRYRUN].count() > 0) {
bDryRun = true;
}

if (options[CLEANNAME_DISABLE].count() > 0) {
bCleanName = false;
}
parseCleanName = bCleanName;

if (options[VERSION].count() > 0) {
printVersion();
Expand Down
9 changes: 6 additions & 3 deletions commandLine/src/projects/baseProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,12 @@ void baseProject::addAddon(const std::string & _addonName){
ofLogVerbose("baseProject::addAddon") << _addonName;
// alert( "baseProject::addAddon " + _addonName );

// auto addonName = ofAddon::cleanName(_addonName);
auto addonName = _addonName;

std::string addonName;
if(parseCleanName){
addonName = ofAddon::cleanName(_addonName);
} else {
addonName = _addonName;
}

// FIXME : not target, yes platform.
//#ifdef TARGET_WIN32
Expand Down
21 changes: 20 additions & 1 deletion commandLine/src/projects/visualStudioProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,27 @@ void visualStudioProject::addSrc(const fs::path & srcFile, const fs::path & fold
nodeAdded.append_attribute("Include").set_value(srcFile.c_str());
nodeAdded.append_child("Filter").append_child(pugi::node_pcdata).set_value(folder.c_str());*/

} else if (ext == ".storyboard" || ext == ".mm" || ext == ".m" || ext == ".swift" || ext == ".java" || ext == ".kotlin") {
} else if (ext == ".java" || ext == ".kotlin") {
// Do not add files for other platforms
} else if (
ext == ".storyboard" || // Xcode Interface Builder files
ext == ".xib" || // Xcode Interface Builder files
ext == ".xcassets" || // Xcode Asset catalogs
ext == ".xcconfig" || // Xcode build configuration files
ext == ".entitlements" || // Code signing entitlements (Apple-specific)
ext == ".plist" || // Property List files (Info.plist, macOS/iOS config)
ext == ".mm" || // Objective-C++
ext == ".m" || // Objective-C
ext == ".swift" || // Swift language files
ext == ".modulemap" || // Clang module definition (Xcode/Clang-specific)
ext == ".metal" || // Metal Shading Language (Apple GPU API)
ext == ".tbd" || // Text-based dynamic libraries (Apple SDKs)
ext == ".dylib" || // Dynamic libraries (macOS/iOS equivalent of .dll)
ext == ".framework" ||
ext == ".bundle" ||
ext == ".app" ||
ext == ".xcworkspace" ||
ext == ".xcodeproj") {
} else{
appendValue(doc, "ClCompile", "Include", srcFileString);

Expand Down
103 changes: 74 additions & 29 deletions commandLine/src/projects/xcodeProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ bool xcodeProject::createProjectFile(){
for (auto & f : {"openFrameworks-Info.plist", "of.entitlements"}) {
copyTemplateFiles.push_back({normalizePath(templatePath / f), normalizePath(projectDir / f)});
}
} else if (target == "ios" || target == "macos") {
} else if (target == "ios" || target == "tvos" || target == "visionos" || target == "catos" || target == "macos") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think macos template (target) doesnt have ofxiOS-Info.plist

for (auto & f : {"ofxiOS-Info.plist", "ofxiOS_Prefix.pch"}) {
copyTemplateFiles.push_back({normalizePath(templatePath / f), normalizePath(projectDir / f)});
try {
Expand Down Expand Up @@ -420,11 +420,7 @@ void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, Src
fp.addToBuildPhase = true;
fp.isSrc = true;

// if( type == DEFAULT ){
if( target == "ios" ){
fp.addToBuildPhase = true;
fp.addToResources = true;
}
if( type == DEFAULT ){

if (ext == ".h" || ext == ".hpp"){
fp.addToBuildPhase = false;
Expand All @@ -450,44 +446,93 @@ void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, Src
fp.addToBuildPhase = false;
fp.copyBundleResources = true;
}
else if( ext == ".plist" ){
fp.addToBuildPhase = true;
fp.copyBundleResources = true;
}
else if (ext == ".swift"){
fp.addToBuildPhase = true;
for (auto &c : buildConfigs) {
addCommand("Add :objects:" + c + ":buildSettings:OTHER_SWIFT_FLAGS: string -cxx-interoperability-mode=swift-5.9");
// mark all Swift files as C++ interop available :)
}
}
else if (ext == ".xcassets"){
fp.addToBuildResource = true;
fp.addToResources = true;
}
else if (ext == ".modulemap") {
fp.addToBuildPhase = false;
}
else if (ext == ".bundle") {
fp.addToBuildResource = true;
fp.addToResources = true;
}
else if (ext == ".tbd") {
fp.linkBinaryWithLibraries = true;
}


// }


}
string UUID {
addFile(srcFile, folder, fp)
};

if (ext == ".mm" || ext == ".m") {
addCompileFlagsForMMFile(srcFile);
} else if (ext == ".cpp") {
if (containsObjectiveCPlusPlus(srcFile)) {
addCompileFlagsForMMFile(srcFile);
}
}
}

void xcodeProject::addCompileFlagsForMMFile(const fs::path & srcFile) {

// This requires a moro thorough inspection on how to deal with these files, and determine if these need the -fno-objc-arc flag.
// This flag should be added on a file by file basis, rather than the way it is done below where these are added globally, as such messes up other things.
std::ifstream file(srcFile);
if (!file.is_open()) return;

// std::ifstream file(srcFile);
// std::string line;
// bool containsARCFunctions = false;
//#if __APPLE__
// std::regex arcRegex(R"(\b(alloc|dealloc)\b)");
//
// while (std::getline(file, line)) {
// if (std::regex_search(line, arcRegex)) {
// containsARCFunctions = true;
// break;
// }
// }
//#endif
// if (containsARCFunctions) {
// for (auto & c : buildConfigs) {
// addCommand("Add :objects:"+c+":buildSettings:OTHER_CPLUSPLUSFLAGS: string -fno-objc-arc");
// }
// }
bool requiresNoARC = false;

// Named regex for detecting ARC-related function calls in Objective-C++
const std::regex arcFunctionRegex(R"(\b(alloc|dealloc|retain|release|autorelease)\b)");

for (std::string line; std::getline(file, line); ) {
if (std::regex_search(line, arcFunctionRegex)) {
requiresNoARC = true;
break;
}
}

// Tag file as Objective-C++ in Xcode build settings
for (auto & c : buildConfigs) {
addCommand("Add :objects:" + c + ":buildSettings:OTHER_CPLUSPLUSFLAGS: string -x objective-c++");

if (requiresNoARC) {
addCommand("Add :objects:" + c + ":buildSettings:OTHER_CPLUSPLUSFLAGS: string -fno-objc-arc");
}
}

}

bool xcodeProject::containsObjectiveCPlusPlus(const fs::path &filePath) {
std::ifstream file(filePath);
if (!file.is_open()) return false;

// Objective-C++ specific keywords to check -- this will fix the really hard to debug objc++ linking obiguous
std::vector<std::string> objcKeywords = {
"#import", "@interface", "@implementation", "@property",
"@synthesize", "@end"
};

for (std::string line; std::getline(file, line); ) {
for (const auto &keyword : objcKeywords) {
if (line.find(keyword) != std::string::npos) {
return true;
}
}
}
return false;
}


Expand Down
6 changes: 6 additions & 0 deletions commandLine/src/projects/xcodeProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include "baseProject.h"
//#include <unordered_map>
#include <map>
#include <fstream>
#include <string>
#include <vector>
#include <regex>
using std::string;

class xcodeProject : public baseProject {
Expand Down Expand Up @@ -53,6 +57,8 @@ class xcodeProject : public baseProject {
void addFramework(const fs::path & path, const fs::path & folder, bool isRelativeToSDK = false) override;
void addXCFramework(const fs::path & path, const fs::path & folder);
void addDylib(const fs::path & path, const fs::path & folder);

bool containsObjectiveCPlusPlus(const fs::path &filePath);

void saveScheme();
void renameProject();
Expand Down
2 changes: 1 addition & 1 deletion commandLine/src/utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ unique_ptr<baseProject> getTargetProject(const string & targ) {
// cout << "getTargetProject :" << getTargetString(targ) << endl;
// typedef xcodeProject pgProject;

if (targ == "osx" || targ == "ios" || targ == "macos") {
if (targ == "osx" || targ == "ios" || targ == "macos" || targ == "tvos" || targ == "catos" || targ == "visionos" || targ == "watchos") {
return unique_ptr<xcodeProject>(new xcodeProject(targ));
} else if (targ == "msys2") {
// return unique_ptr<QtCreatorProject>(new QtCreatorProject(targ));
Expand Down
2 changes: 2 additions & 0 deletions commandLine/src/utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ using std::cout;
using std::endl;

static bool backupProjectFiles = false;
static bool parseCleanName = true;

static std::map <ofTargetPlatform, std::string> platformsToString {
{ OF_TARGET_ANDROID, "android" },
Expand Down Expand Up @@ -54,6 +55,7 @@ static std::vector < std::string > platformsOptions {
"msys2",
"osx",
"vs",
"tvos",
};

string generateUUID(const string & input);
Expand Down
92 changes: 47 additions & 45 deletions scripts/osx/test_cmdline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,57 +28,59 @@ else
echo "Application is already code-signed and valid"
fi

echo "Test auto path:"
echo "Test: projectGenerator building"
echo "Test 1: test examples templates - auto path to openFrameworks core"
./projectGenerator --recursive -posx ../../examples/templates
echo "Test 1: test examples templates - success"

echo "Test: projectGenerator building"
echo "Test 2: all examples - defined core openFrameworks path ../../"
./projectGenerator --recursive -posx -o../../ ../../examples/ ./projectGenerator
echo "Test 2: all examples - success"

echo "Test all"
./projectGenerator --recursive -posx -o../../ ../../examples/ ./projectGenerator
# echo "test out of folder -o [vs]";
# rm -rf ../../../../../pg2
# mkdir -p ../../../../../pg2
# if ! command -v rsync &> /dev/null
# then
# cp -a ./projectGenerator ../../../../../pg2
# else
# rsync -azp ./projectGenerator ../../../../../pg2
# fi
# cd ../../../../../pg2
# ls -a
# pwd
# ./projectGenerator --recursive -posx -o"./../openFrameworks" ./../openFrameworks/examples/
# errorcode=$?
# if [[ $errorcode -ne 0 ]]; then
# exit $errorcode
# fi

# ./projectGenerator --recursive -posx -o"./../openFrameworks" ./../openFrameworks/examples/
# errorcode=$?
# if [[ $errorcode -ne 0 ]]; then
# exit $errorcode
# fi

echo "test out of folder -o [vs]";
rm -rf ../../../../../pg2
mkdir -p ../../../../../pg2
if ! command -v rsync &> /dev/null
then
cp -a ./projectGenerator ../../../../../pg2
else
rsync -azp ./projectGenerator ../../../../../pg2
fi
cd ../../../../../pg2
ls -a
pwd
./projectGenerator --recursive -posx -o"./../openFrameworks" ./../openFrameworks/examples/
errorcode=$?
if [[ $errorcode -ne 0 ]]; then
exit $errorcode
fi

./projectGenerator --recursive -posx -o"./../openFrameworks" ./../openFrameworks/examples/
errorcode=$?
if [[ $errorcode -ne 0 ]]; then
exit $errorcode
fi
# echo "Test generate new just name"
# ./projectGenerator -o"../openFrameworks" -p"osx" "testingGenerate"
# errorcode=$?
# if [[ $errorcode -ne 0 ]]; then
# exit $errorcode
# fi
# echo "Test generate new / update full path"
# ./projectGenerator -o"../openFrameworks" -p"osx" "../openFrameworks/apps/myApps/testingGenerate"
# errorcode=$?
# if [[ $errorcode -ne 0 ]]; then
# exit $errorcode
# fi

echo "Test generate new just name"
./projectGenerator -o"../openFrameworks" -p"osx" "testingGenerate"
errorcode=$?
if [[ $errorcode -ne 0 ]]; then
exit $errorcode
fi
echo "Test generate new / update full path"
./projectGenerator -o"../openFrameworks" -p"osx" "../openFrameworks/apps/myApps/testingGenerate"
errorcode=$?
if [[ $errorcode -ne 0 ]]; then
exit $errorcode
fi

echo "Test generate full path"
./projectGenerator -o"../openFrameworks" -p"osx" "openFrameworks/apps/myApps/testingGenerate2"
errorcode=$?
if [[ $errorcode -ne 0 ]]; then
exit $errorcode
fi
# echo "Test generate full path"
# ./projectGenerator -o"../openFrameworks" -p"osx" "openFrameworks/apps/myApps/testingGenerate2"
# errorcode=$?
# if [[ $errorcode -ne 0 ]]; then
# exit $errorcode
# fi


echo "Successful projectGenerator tests for [osx]";