projectGenerator
projectGenerator copied to clipboard
Special use cases (Xcode) – Add .app, custom build phase, Objective-C++ sources
Hello everybody,
I'm working on an addon with some special use cases for the PG. Right now I'm working on macOS (Xcode) side, and I would like to know if I can do the following in the addon_config.mk:
-
I would like to add an
.appbundle to the Xcode project and also add it to theCopy FilesBuild Phase with theFrameworksdirectory as destination. It's exactly what happens when you add a Framework toADDON_FRAMEWORKS. Sadly I it doesn't work when I add the .app bundle withADDON_FRAMEWORKS. -
I would like to add a custom
Run Scriptbuild phase. -
The addon uses sources which contain C++ and Objective-C code. In Xcode you have to declare the source file as
Objective-C++to compile correctly. Is there a way to tell the PG to declare a.cppasObjective-C++source file. I've already tiredADDON_OBJC_SOURCESwhich didn't work. (Changing the extension might lead to problems on the VS side of things)
If PG isn't able to do those things does anybody have a quick idea how to simply automate those steps, preferably without running another script?
Thanks a lot.
-
you can't specify copying something to the bundle but you can use a script i can imagine
-
you can add a run script phase using:
osx:
ADDON_AFTER = ...
plus commands you want to run.
- adding objc sources should be working now using ADDON_OBJC_SOURCES. there was an error before but it's solved now in master. you'll need to compile the PG yourself though
I'm going to close this but feel free to keep posting if you find any problem with the proposed solutions
Thanks for the reply. Sadly I couldn't get ADDON_AFTER and ADDON_OBJC_SOURCES to work. Initially I worked with of_0.9.8 but I now also work with GitHub master OF branch. And I also updated the projectGenerator submodule, so I have your latest commit.
-
ADDON_AFTER: with the new PG I saw a new Script Phase with AppStore stuff. But not another with my test string. -
ADDON_OBJC_SOURCES: the .cpp source file is still declared asC++ Sourceinstead ofObjective-C++ Source. Also wildcardsADDON_OBJC_SOURCES = src/*.cppwould be neat. -
On the Windows side of things: I need to copy a few recourses (some DLLs, some other) to the
bindirectory. There is alreadyADDON_DLLS_TO_COPYwhich is great. But my question is, can I somehow use a wildcard? WithADDON_DATAthe comment says "you can use wildcards like * and ?". This is sadly not working withADDON_DLLS_TO_COPYand I have a directory 'locales' which needs to be copied with over 100 files. Alternatively I also triedADDON_AFTERto see if something would show up in thePost-Build Eventswhere one could add anotherrobocopyline to achieve the same result, but also without any luck. -
With the new OF and PG I also noticed that the
Framework Search PathsforADDON_FRAMEWORKSis not getting set anymore, by adding it manually again the project builds again (macOS Xcode).
My current addon_config.mk:
…
common:
ADDON_INCLUDES_EXCLUDE = libs
ADDON_INCLUDES_EXCLUDE += libs/cef/include/%
ADDON_INCLUDES_EXCLUDE += libs/cef/lib
ADDON_INCLUDES_EXCLUDE += libs/cef/lib/%
ADDON_SOURCES_EXCLUDE = src/process_helper_mac.cpp
vs:
ADDON_LIBS_EXCLUDE = "libs/cef/export/vs/x64"
ADDON_LIBS_EXCLUDE = "libs/cef/export/vs/x64/%"
ADDON_AFTER = "THIS IS A TEST"
ADDON_DLLS_TO_COPY = "libs/cef/export/vs/x64/%"
ADDON_DLLS_TO_COPY += "libs/cef/export/vs/x64/*"
ADDON_DLLS_TO_COPY += "libs/cef/export/vs/x64/?"
ADDON_DLLS_TO_COPY += "libs/cef/export/vs/x64/chrome_elf.dll"
ADDON_DLLS_TO_COPY += "libs/cef/export/vs/x64/cef.pak"
osx:
ADDON_FRAMEWORKS = "../../../addons/ofxCef/libs/cef/lib/osx/Chromium Embedded Framework.framework"
ADDON_AFTER = "THIS IS A TEST"
ADDON_OBJC_SOURCES = src/ofxCEF.cpp
Thanks again!
mmh ok that's strange. thinking about it i believe the after rule might only work with makefiles but was never ported to work on the PG. about the rest. both objective c sources and wildcards with all the options should be working so not sure what' might be going on, i'll take a look when i have a moment
I did a bit of digging in the source, here some notes to possibly make it easier for you:
ADDON_AFTER: yeah I was already wondering because I didn't find any reference to it in the source. Any plans to implement it?
ADDON_OBJC_SOURCES: Can't find anything weird by quickly browsing through the code. I was just thinking if PG already finds the file as "ordinary" C++ source and then I declare it as Objective-C, could this lead to a weird situation?
ADDON_DLLS_TO_COPY: In 'visualStudioProject.cpp:430' I found this:
std::string dll = std::filesystem::absolute(addon.dllsToCopy[i], addon.addonPath).string();
ofFile(dll).copyTo(ofFilePath::join(projectDir,"bin/"),false,true);
As far as I can tell dllsToCopy contains the raw strings I define with ADDON_DLLS_TO_COPY. And I'm guessing that ofFile doesn't handle wildcards like this. And I just couldn't find out how ADDON_DATA does it's thing.
ADDON_OBJC_SOURCES: Can't find anything weird by quickly browsing through the code. I was just thinking if PG already finds the file as "ordinary" C++ source and then I declare it as Objective-C, could this lead to a weird situation?
ah yes, you probably need to exclude the files as source first so they are then recognized as objc sources. the PG should be doing this automatically but it doesn't yet
I couldn't get the exclusion to work. When I try to exclude a file with ADDON_SOURCES_EXCLUDE, it excluded the files for good. See ofAddon.cpp:417:
exclude(srcFiles,excludeSources);
exclude(csrcFiles,excludeSources);
exclude(cppsrcFiles,excludeSources);
exclude(objcsrcFiles,excludeSources);
exclude(headersrcFiles,excludeSources);
The only other thing I found where I could exclude something is ADDON_INCLUDES_EXCLUDE and as far as I know it only excluded paths from Header Search Paths.