Skip to content
Open
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
2 changes: 1 addition & 1 deletion commandLine/src/defines.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define OFPROJECTGENERATOR_MAJOR_VERSION "0"
#define OFPROJECTGENERATOR_MINOR_VERSION "130"
#define OFPROJECTGENERATOR_MINOR_VERSION "131"
#define OFPROJECTGENERATOR_PATCH_VERSION "0"

#define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION)
Expand Down
18 changes: 16 additions & 2 deletions commandLine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ enum optionIndex { UNKNOWN,
EMSCRIPTEN_WASM,
APP_VERSION,
APP_BUILD,
BUNDLE_ID
BUNDLE_ID,
BUNDLE_DATA
};

constexpr option::Descriptor usage[] = {
Expand Down Expand Up @@ -77,6 +78,7 @@ constexpr option::Descriptor usage[] = {
{ APP_VERSION, 0, "", "app-version", option::Arg::Optional, " --app-version \tapp version, eg 1.2.3 (default 1.0): config.make / CMake APP_VERSION, Xcode MARKETING_VERSION, Android versionName" },
{ APP_BUILD, 0, "", "app-build", option::Arg::Optional, " --app-build \tbuild number, eg 42 (default 1): config.make / CMake APP_BUILD, Xcode CURRENT_PROJECT_VERSION, Android versionCode" },
{ BUNDLE_ID, 0, "", "bundle-id", option::Arg::Optional, " --bundle-id \tbundle id, eg com.example.myApp (default cc.openFrameworks.<name>): config.make / CMake APP_BUNDLE_ID, Xcode PRODUCT_BUNDLE_IDENTIFIER, Android applicationId" },
{ BUNDLE_DATA, 0, "", "bundle-data", option::Arg::Optional, " --bundle-data \tbundle the project's bin/data/ folder into the macOS .app on build: 1 (uncomment OF_BUNDLE_DATA_FOLDER in Project.xcconfig) | 0 (re-comment it). Only applied for osx / macos targets; empty leaves the xcconfig unchanged" },
{ 0, 0, 0, 0, 0, 0 }
};

Expand Down Expand Up @@ -114,6 +116,7 @@ string emscriptenWasm; // empty keeps the project's config.make value
string appVersion; // empty keeps the project's value
string appBuild;
string appBundleId; // empty keeps the project's value
string bundleDataFolder; // empty = leave Project.xcconfig alone; "1" uncomments OF_BUNDLE_DATA_FOLDER, "0" re-comments it
string ofPathEnv;
string templateName;
string msys2Env = "ucrt64";
Expand Down Expand Up @@ -290,6 +293,7 @@ void updateProject(const fs::path & path, const string & target, bool bConsiderP
project->setEmscriptenWasm(emscriptenWasm);
project->setAppVersion(appVersion, appBuild);
project->setAppBundleId(appBundleId);
project->setBundleDataFolder(bundleDataFolder);
project->setProjectDefinesPassed(bDefinesPassedIn);
project->setSystemFrameworks(frameworks, bFrameworksPassedIn, systemLibs, bSystemLibsPassedIn);
if (!project->create(path, templateName)) throw std::runtime_error("could not update project: " + path.string());
Expand Down Expand Up @@ -487,7 +491,7 @@ int pgMain(int argc, char ** argv) {
// optionparser only takes attached values (-posx, --platforms=osx); join -p osx / --platforms osx,
// but leave the last argument as the project path: -t"" <path> (scripts, the GUI) is an empty -t
static const std::string valueShort { "paotsmfDPkW" };
static const std::vector<std::string> valueLong { "platforms", "addons", "ofPath", "template", "source", "ofmenu", "frameworks", "system-libs", "defines", "postbuild", "msys2env", "emscripten-wasm", "app-version", "app-build", "bundle-id" };
static const std::vector<std::string> valueLong { "platforms", "addons", "ofPath", "template", "source", "ofmenu", "frameworks", "system-libs", "defines", "postbuild", "msys2env", "emscripten-wasm", "app-version", "app-build", "bundle-id", "bundle-data" };
std::vector<std::string> joinedArgs;
std::string platformBeforePath;
for (int i = 0; i < argc; i++) {
Expand Down Expand Up @@ -775,6 +779,15 @@ int pgMain(int argc, char ** argv) {
}
}

if (options[BUNDLE_DATA].count() > 0 && options[BUNDLE_DATA].arg != NULL) {
std::string v = ofTrim(options[BUNDLE_DATA].arg);
if (v == "0" || v == "1") {
bundleDataFolder = v;
} else {
ofLogWarning() << "bundle-data " << v << " should be 0 or 1 - keeping the project's Project.xcconfig";
}
}

if (options[POSTBUILD].count() > 0 && options[POSTBUILD].arg != NULL) {
postBuildScript = ofTrim(options[POSTBUILD].arg);
}
Expand Down Expand Up @@ -946,6 +959,7 @@ int pgMain(int argc, char ** argv) {
project->setEmscriptenWasm(emscriptenWasm);
project->setAppVersion(appVersion, appBuild);
project->setAppBundleId(appBundleId);
project->setBundleDataFolder(bundleDataFolder);
project->setProjectDefinesPassed(bDefinesPassedIn);
project->setSystemFrameworks(frameworks, bFrameworksPassedIn, systemLibs, bSystemLibsPassedIn);
if (!project->create(projectPath, templateName)) return EXIT_FAILURE;
Expand Down
4 changes: 4 additions & 0 deletions commandLine/src/projects/baseProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ class baseProject {
void setAppVersion(const std::string & version, const std::string & build) { appVersionOption = version; appBuildOption = build; }
// bundle id (--bundle-id), written to config.make APP_BUNDLE_ID; empty keeps the project's (default cc.openFrameworks.<name>)
void setAppBundleId(const std::string & bundleId) { appBundleIdOption = bundleId; }
// Bundle data folder (--bundle-data=0|1): toggle OF_BUNDLE_DATA_FOLDER in Project.xcconfig for osx / macos targets.
// Empty leaves the xcconfig unchanged; "1" uncomments the line so the macOS .app bundles bin/data/ on build; "0" re-comments it.
virtual void setBundleDataFolder(const std::string & value) { bundleDataFolderOption = value; }


#ifdef OFADDON_OUTPUT_JSON_DEBUG
Expand Down Expand Up @@ -214,6 +217,7 @@ class baseProject {
std::string appBundleIdOption; // from the CLI, empty = keep
std::string appBundleId; // value for this project, empty = the template's cc.openFrameworks.<name>
void saveAppBundleIdFiles();
std::string bundleDataFolderOption; // from --bundle-data, empty = leave Project.xcconfig alone, "1" / "0" = uncomment / comment OF_BUNDLE_DATA_FOLDER

//cached addons - if an addon is requested more than once, avoid loading from disk as it's quite slow
std::map<std::string,std::map<std::string, ofAddon>> addonsCache; //indexed by [platform][supplied path]
Expand Down
35 changes: 35 additions & 0 deletions commandLine/src/projects/xcodeProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2008,6 +2008,41 @@ bool xcodeProject::saveProjectFile() {
ofLogError(LOG_NAME) << "Cannot save Apple settings: " << e.what();
return false;
}
// --bundle-data=1|0 (osx / macos only): toggle the APPSTORE line that bundles bin/data/
// into the .app. The templates ship it commented out; this is applied after
// saveAppleSettings' merge so the explicit flag is the final word, overriding both the
// template default and any previous project state the merge would otherwise carry over.
// If the merge left multiple OF_BUNDLE_DATA_FOLDER lines (template-commented + user-
// uncommented), the first matching line is rewritten and the rest are dropped.
if ((target == "osx" || target == "macos") && !bundleDataFolderOption.empty()) {
fs::path xcconfig = projectDir / "Project.xcconfig";
if (fs::exists(xcconfig)) {
try {
static const std::regex lineRe(R"(^[ \t]*(?://)?[ \t]*OF_BUNDLE_DATA_FOLDER[ \t]*=.*$)");
string replacement = bundleDataFolderOption == "1" ? "OF_BUNDLE_DATA_FOLDER = 1" : "//OF_BUNDLE_DATA_FOLDER = 1";
std::vector<string> lines = fileToStrings(xcconfig);
bool wrote = false;
bool changed = false;
string updated;
for (auto & l : lines) {
if (std::regex_match(l, lineRe)) {
if (!wrote) {
if (l != replacement) changed = true;
updated += replacement + "\n";
wrote = true;
} else {
changed = true; // collapsing a duplicate
}
} else {
updated += l + "\n";
}
}
if (changed) writeSettingsFile(xcconfig, updated);
} catch (const std::exception & e) {
ofLogWarning(LOG_NAME) << "Cannot toggle OF_BUNDLE_DATA_FOLDER in Project.xcconfig: " << e.what();
}
}
}
}

// for (auto & c : commands) cout << c << endl;
Expand Down
17 changes: 16 additions & 1 deletion frontend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ ipcRenderer.on('setGenerateMode', (event, arg) => {

function clearProjectSettings() {
for (const id of ['appVersion', 'appBuild', 'bundleId', 'systemFrameworks', 'systemLibs', 'customDefines']) $('#' + id).val('');
$('#bundleData').prop('checked', false);
$('#bundleData').closest('.ui.checkbox').removeClass('checked');
$('#appVersionNote').text('').hide();
$('#rendererDropdown, #glDropdown, #webglDropdown, #glesDropdown').dropdown('set exactly', 'default');
loadedProjectSettings = null;
Expand All @@ -238,9 +240,14 @@ ipcRenderer.on('setProjectSettings', (event, values) => {
for (const [id, value] of Object.entries(fields)) {
if (!keepEdits || $('#' + id).val().trim() === loadedProjectSettings[id]) $('#' + id).val(value);
}
const bundleDataChecked = !!values.bundleDataFolder;
if (!keepEdits || $('#bundleData').is(':checked') === !!loadedProjectSettings?.bundleDataFolder) {
$('#bundleData').prop('checked', bundleDataChecked);
$('#bundleData').closest('.ui.checkbox').toggleClass('checked', bundleDataChecked);
}
$('#appVersionNote').text('').hide();
if (!keepEdits) $('#rendererDropdown, #glDropdown, #webglDropdown, #glesDropdown').dropdown('set exactly', 'default');
loadedProjectSettings = { projectName: values.projectName, projectPath: values.projectPath, ...fields };
loadedProjectSettings = { projectName: values.projectName, projectPath: values.projectPath, ...fields, bundleDataFolder: bundleDataChecked };
});

function projectFieldValue(id) {
Expand Down Expand Up @@ -972,6 +979,9 @@ function setup() {
$("#detachConsole").checkbox();
$("#detachConsole").prop('checked', !!defaultSettings['detachConsole']);
updateConsoleDockVisibility();

// bundle data folder (osx / macos): Semantic UI init; state is set by setProjectSettings
$("#bundleData").checkbox();
$("#detachConsole").on('change', function(){
const enabled = $(this).is(':checked');
defaultSettings['detachConsole'] = enabled;
Expand Down Expand Up @@ -1318,6 +1328,9 @@ function generate() {
appVersion: projectFieldValue('appVersion') || '',
appBuild: projectFieldValue('appBuild') || '',
appBundleId: projectFieldValue('bundleId') || '',
// osx / macos checkbox for OF_BUNDLE_DATA_FOLDER in Project.xcconfig; hidden = keep
// the project's current xcconfig (don't send the flag at all)
bundleDataFolder: $('#bundleDataField').css('display') !== 'none' ? ($('#bundleData').is(':checked') ? '1' : '0') : '',
// only for Apple targets; hidden = keep the project's config.make values
systemFrameworks: $('#systemFrameworksField').css('display') !== 'none' && projectFieldValue('systemFrameworks') !== null ? $('#systemFrameworks').val().split(/[\s,]+/).filter(Boolean) : null,
systemLibs: $('#systemFrameworksField').css('display') !== 'none' && projectFieldValue('systemLibs') !== null ? $('#systemLibs').val().split(/[\s,]+/).filter(Boolean) : null
Expand Down Expand Up @@ -1516,6 +1529,8 @@ function updateRendererFieldVisibility() {
// advanced only; hidden fields keep the project's values, so updating still keeps them
$('#appVersionField').css('display', defaultSettings.advancedMode ? 'flex' : 'none');
$('#bundleIdField').toggle(!!defaultSettings.advancedMode);
// bundle data folder checkbox is osx / macos only (the APPSTORE block it toggles only exists in those templates)
$('#bundleDataField').toggle(!!defaultSettings.advancedMode && selectedPlatforms.some((p) => ['osx', 'macos'].includes(p)));
$('#appVersionNote').toggle(!!defaultSettings.advancedMode && $('#appVersionNote').text().length > 0);
$('#systemFrameworksField').css('display', defaultSettings.advancedMode && selectedPlatforms.some((p) => ['osx', 'ios', 'macos', 'tvos'].includes(p)) ? 'flex' : 'none');

Expand Down
10 changes: 10 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,16 @@
</label>
<input type="text" id="bundleId" placeholder="cc.openFrameworks.myApp" autocomplete="off" spellcheck="false">
</div>
<div class="field" id="bundleDataField" style="display: none">
<div class="ui checkbox">
<input type="checkbox" id="bundleData">
<label><span data-i18n="checkbox.bundleData">Bundle data folder into .app (macOS)</span> &nbsp;
<a class="ui icon tooltip" href="#" data-i18n-content="tooltip.bundleData" data-content="Uncomments OF_BUNDLE_DATA_FOLDER = 1 in Project.xcconfig so Xcode copies bin/data/ into the built .app. Needed for App Store builds; unchecked leaves data/ next to the .app in bin/." data-position="right center">
<i class="help circle icon"></i>
</a>
</label>
</div>
</div>
<div class="two fields" id="systemFrameworksField" style="display: none">
<div class="field">
<label><span data-i18n="field.systemFrameworks">System frameworks:</span> &nbsp;
Expand Down
6 changes: 6 additions & 0 deletions frontend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,7 @@ ipcMain.on('downloadModularLibs', async (event, { ofPath, tag, names }) => {
* appVersion: string,
* appBuild: string,
* appBundleId: string,
* bundleDataFolder: string,
* systemFrameworks: Array<string>|null,
* systemLibs: Array<string>|null,
* }} GenerateArgument */
Expand All @@ -1793,6 +1794,7 @@ function generateFunction(event, generate) {
appVersion,
appBuild,
appBundleId,
bundleDataFolder,
systemFrameworks,
systemLibs,
} = generate;
Expand Down Expand Up @@ -1852,6 +1854,10 @@ function generateFunction(event, generate) {
if (appBundleId && /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$/.test(appBundleId)) {
args.push(`--bundle-id=${appBundleId}`);
}
// osx / macos bundle data folder checkbox; empty (hidden) keeps the project's Project.xcconfig
if (bundleDataFolder === '0' || bundleDataFolder === '1') {
args.push(`--bundle-data=${bundleDataFolder}`);
}

// null keeps the project's config.make PROJECT_FRAMEWORKS / PROJECT_SYSTEM_LIBS, empty removes them
if (Array.isArray(systemFrameworks)) {
Expand Down
2 changes: 2 additions & 0 deletions frontend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@
"field.bundleId": "Bundle ID:",
"tooltip.bundleId": "The app's bundle identifier (Xcode / Info.plist CFBundleIdentifier, Android applicationId), e.g. com.example.myApp. Saved in config.make APP_BUNDLE_ID. Empty keeps the project's (default cc.openFrameworks.<name>).",
"tooltip.bundleIdInvalid": "Bundle ID should be letters, digits, - and dots, e.g. com.example.myApp.",
"checkbox.bundleData": "Bundle data folder into .app (macOS)",
"tooltip.bundleData": "Uncomments OF_BUNDLE_DATA_FOLDER = 1 in Project.xcconfig so Xcode copies bin/data/ into the built .app. Needed for App Store builds; unchecked leaves data/ next to the .app in bin/.",
"field.systemFrameworks": "System frameworks:",
"field.systemLibs": "System libraries:",
"tooltip.systemFrameworks": "Apple SDK frameworks, comma-separated, e.g. Security, CoreBluetooth. Saved in config.make PROJECT_FRAMEWORKS.",
Expand Down
4 changes: 2 additions & 2 deletions frontend/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "projectGenerator",
"productName": "projectGenerator",
"version": "0.125.0",
"version": "0.126.0",
"description": "Build electron GUI openFrameworks projectGenerator",
"license": "MIT",
"main": "index.js",
Expand Down
5 changes: 4 additions & 1 deletion frontend/project-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function cflagDefines(value, settings) {

function readProjectSettings(folder, { platforms = [], ofPath = '' } = {}) {
const make = assignments(text(path.join(folder, 'config.make')));
const result = { version: '', build: '', bundleId: '', defines: words(make.PROJECT_DEFINES), frameworks: [], libs: [] };
const result = { version: '', build: '', bundleId: '', bundleDataFolder: false, defines: words(make.PROJECT_DEFINES), frameworks: [], libs: [] };
for (const item of words(make.PROJECT_FRAMEWORKS)) {
if (/^-l|^lib|\.(?:tbd|dylib)$/.test(item)) result.libs.push(cleanLibrary(item));
else result.frameworks.push(cleanFramework(item));
Expand Down Expand Up @@ -304,6 +304,9 @@ function readProjectSettings(folder, { platforms = [], ofPath = '' } = {}) {
result.version ||= unquote(make.APP_VERSION || last(cmake, /^\s*set\(\s*APP_VERSION\s+"?([0-9.]+)/gm) || appConfig.MARKETING_VERSION || last(gradle, /^\s*versionName\s+['"]([^'"]+)/gm));
result.build ||= unquote(make.APP_BUILD || last(cmake, /^\s*set\(\s*APP_BUILD\s+"?([0-9]+)/gm) || appConfig.CURRENT_PROJECT_VERSION || last(gradle, /^\s*versionCode\s+([0-9]+)/gm));
result.bundleId ||= unquote(make.APP_BUNDLE_ID || last(cmake, /^\s*set\(\s*APP_BUNDLE_ID\s+"?([^\s")]+)/gm) || appConfig.PRODUCT_BUNDLE_IDENTIFIER || last(gradle, /^\s*applicationId\s+['"]([^'"]+)/gm));
// OF_BUNDLE_DATA_FOLDER = 1 in Project.xcconfig (osx / macos): commented lines are stripped
// by assignments(), so a truthy value means it's actually uncommented and set to 1.
result.bundleDataFolder = scalar(xcconfig.OF_BUNDLE_DATA_FOLDER || appConfig.OF_BUNDLE_DATA_FOLDER || '').trim() === '1';
for (const key of ['version', 'build', 'bundleId']) if (result[key].includes('$')) result[key] = '';
result.defines = unique(result.defines.filter((define) => !define.includes('$')));
result.frameworks = unique(result.frameworks); result.libs = unique(result.libs);
Expand Down
Loading