mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
ide: Now generating cocoa .app bundle iconset
git-svn-id: svn://ultimatepp.org/upp/trunk@12614 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
b20eaf3a40
commit
5c89fe1768
5 changed files with 98 additions and 26 deletions
|
|
@ -1,8 +1,12 @@
|
||||||
sooner:
|
sooner:
|
||||||
|
|
||||||
|
- .iml editor image kind switch
|
||||||
|
|
||||||
|
- Ctrl+O does not work
|
||||||
|
|
||||||
- tooltip in package organizer is too small
|
- tooltip in package organizer is too small
|
||||||
|
|
||||||
- Esc does not work to close console area in theide
|
- Esc does not work to close console area in theide, nor Assist popup
|
||||||
|
|
||||||
- lineedit d&d leaves artifacts (at I cursor)
|
- lineedit d&d leaves artifacts (at I cursor)
|
||||||
|
|
||||||
|
|
@ -29,7 +33,7 @@ sooner:
|
||||||
- Delete CocoDnD.cpp -> crash
|
- Delete CocoDnD.cpp -> crash
|
||||||
|
|
||||||
- bool SystemDraw::IsPaintingOp(const Rect& r) const
|
- bool SystemDraw::IsPaintingOp(const Rect& r) const
|
||||||
- download .scd files
|
- download .scd files (or put to bundle)
|
||||||
|
|
||||||
* apple debugger
|
* apple debugger
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ struct GccBuilder : CppBuilder {
|
||||||
String CompilerName() const;
|
String CompilerName() const;
|
||||||
String CmdLine(const String& package, const Package& pkg);
|
String CmdLine(const String& package, const Package& pkg);
|
||||||
void BinaryToObject(String objfile, CParser& binscript, String basedir, const String& package, const Package& pkg);
|
void BinaryToObject(String objfile, CParser& binscript, String basedir, const String& package, const Package& pkg);
|
||||||
|
void CocoaAppBundle();
|
||||||
|
|
||||||
String Info_plist; // apple bundle Info.plist
|
String Info_plist; // apple bundle Info.plist
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ file
|
||||||
MscBuilder.cpp,
|
MscBuilder.cpp,
|
||||||
JavaBuilder.cpp,
|
JavaBuilder.cpp,
|
||||||
ScriptBuilder.cpp,
|
ScriptBuilder.cpp,
|
||||||
|
Cocoa.cpp,
|
||||||
Android readonly separator,
|
Android readonly separator,
|
||||||
Android.h,
|
Android.h,
|
||||||
AndroidProject.cpp,
|
AndroidProject.cpp,
|
||||||
|
|
|
||||||
88
uppsrc/ide/Builders/Cocoa.cpp
Normal file
88
uppsrc/ide/Builders/Cocoa.cpp
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
#include "Builders.h"
|
||||||
|
#include <Draw/Draw.h>
|
||||||
|
#include <plugin/png/png.h>
|
||||||
|
|
||||||
|
void GccBuilder::CocoaAppBundle()
|
||||||
|
{
|
||||||
|
if(!HasFlag("OSX") || !HasFlag("GUI"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
String icns = GetFileFolder(GetFileFolder(target)) + "/Resources/icons.icns";
|
||||||
|
RealizePath(icns);
|
||||||
|
Time icns_tm = Nvl(GetFileTime(icns), Time::Low());
|
||||||
|
bool convert_icons = false;
|
||||||
|
|
||||||
|
SortedVectorMap<int, Image> imgs;
|
||||||
|
for(FindFile ff(PackageDirectory(mainpackage) + "/icon*.png"); ff; ff.Next()) {
|
||||||
|
Image m = StreamRaster::LoadFileAny(ff.GetPath());
|
||||||
|
Size sz = m.GetSize();
|
||||||
|
if(sz.cx == sz.cy) {
|
||||||
|
imgs.Add(sz.cx, m);
|
||||||
|
PutVerbose("Found icon " << ff.GetName());
|
||||||
|
if((Time)ff.GetLastWriteTime() >= icns_tm)
|
||||||
|
convert_icons = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(imgs.GetCount() && convert_icons) {
|
||||||
|
String icons = AppendFileName(outdir, "icons.iconset");
|
||||||
|
RealizeDir(icons);
|
||||||
|
PutConsole("Exporting bundle icons to " + icons);
|
||||||
|
|
||||||
|
bool icons_dirty = false;
|
||||||
|
|
||||||
|
for(String fn : {
|
||||||
|
"icon_16x16.png",
|
||||||
|
"icon_16x16@2x.png",
|
||||||
|
"icon_32x32.png",
|
||||||
|
"icon_32x32@2x.png",
|
||||||
|
"icon_128x128.png",
|
||||||
|
"icon_128x128@2x.png",
|
||||||
|
"icon_256x256.png",
|
||||||
|
"icon_256x256@2x.png",
|
||||||
|
"icon_512x512.png",
|
||||||
|
"icon_512x512@2x.png",
|
||||||
|
}) {
|
||||||
|
int n = atoi(~fn + strlen("icon_"));
|
||||||
|
if(fn.Find("@2x") >= 0)
|
||||||
|
n *= 2;
|
||||||
|
int q = imgs.FindLowerBound(n);
|
||||||
|
Image img = q >= 0 && q < imgs.GetCount() ? imgs[q] : imgs[imgs.GetCount() - 1];
|
||||||
|
PutVerbose(String() << "Exporting " << fn << " from "
|
||||||
|
<< img.GetSize().cx << "x" << img.GetSize().cx);
|
||||||
|
PNGEncoder().SaveFile(AppendFileName(icons, fn), Rescale(img, n, n));
|
||||||
|
}
|
||||||
|
|
||||||
|
Execute(String() << "iconutil --convert icns --output " << icns << " " << icons);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(IsNull(Info_plist)) {
|
||||||
|
Info_plist
|
||||||
|
<< "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
|
<< "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
||||||
|
<< "<plist version=\"1.0\">\n"
|
||||||
|
<< "<dict>\n"
|
||||||
|
<< " <key>CFBundleExecutable</key>\n"
|
||||||
|
<< " <string>" << GetFileName(target) << "</string>\n"
|
||||||
|
<< " <key>NSHighResolutionCapable</key>\n"
|
||||||
|
<< " <string>True</string>\n"
|
||||||
|
<< " <key>LSMinimumSystemVersion</key>\n"
|
||||||
|
<< " <string>10.13</string>\n"
|
||||||
|
;
|
||||||
|
if(imgs.GetCount())
|
||||||
|
Info_plist
|
||||||
|
<< " <key>CFBundleIconFile</key>\n"
|
||||||
|
<< " <string>icons.icns</string>\n"
|
||||||
|
;
|
||||||
|
Info_plist
|
||||||
|
<< "</dict>\n"
|
||||||
|
<< "</plist>\n"
|
||||||
|
;
|
||||||
|
}
|
||||||
|
String Info_plist_path = GetFileFolder(GetFileFolder(target)) + "/Info.plist";
|
||||||
|
if(LoadFile(Info_plist_path) != Info_plist) {
|
||||||
|
if(FileExists(Info_plist_path))
|
||||||
|
Execute("defaults delete " + Info_plist_path); // Force MacOS to reload plist
|
||||||
|
SaveFile(Info_plist_path, Info_plist);
|
||||||
|
PutConsole("Saving " << Info_plist_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -465,6 +465,7 @@ bool GccBuilder::Link(const Vector<String>& linkfile, const String& linkoptions,
|
||||||
return false;
|
return false;
|
||||||
PutLinking();
|
PutLinking();
|
||||||
int time = msecs();
|
int time = msecs();
|
||||||
|
CocoaAppBundle();
|
||||||
for(int i = 0; i < linkfile.GetCount(); i++)
|
for(int i = 0; i < linkfile.GetCount(); i++)
|
||||||
if(GetFileTime(linkfile[i]) > targettime) {
|
if(GetFileTime(linkfile[i]) > targettime) {
|
||||||
Vector<String> lib;
|
Vector<String> lib;
|
||||||
|
|
@ -561,30 +562,6 @@ bool GccBuilder::Link(const Vector<String>& linkfile, const String& linkoptions,
|
||||||
bool error = false;
|
bool error = false;
|
||||||
CustomStep(".pre-link", Null, error);
|
CustomStep(".pre-link", Null, error);
|
||||||
if(!error && Execute(lnk) == 0) {
|
if(!error && Execute(lnk) == 0) {
|
||||||
if(HasFlag("OSX") && HasFlag("GUI")) {
|
|
||||||
if(IsNull(Info_plist))
|
|
||||||
Info_plist
|
|
||||||
<< "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
|
||||||
<< "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
|
||||||
<< "<plist version=\"1.0\">\n"
|
|
||||||
<< "<dict>\n"
|
|
||||||
<< " <key>CFBundleExecutable</key>\n"
|
|
||||||
<< " <string>" << GetFileName(target) << "</string>\n"
|
|
||||||
<< " <key>NSHighResolutionCapable</key>\n"
|
|
||||||
<< " <string>True</string>\n"
|
|
||||||
<< " <key>LSMinimumSystemVersion</key>\n"
|
|
||||||
<< " <string>10.13</string>\n"
|
|
||||||
<< "</dict>\n"
|
|
||||||
<< "</plist>\n"
|
|
||||||
;
|
|
||||||
String Info_plist_path = GetFileFolder(GetFileFolder(target)) + "/Info.plist";
|
|
||||||
if(LoadFile(Info_plist_path) != Info_plist) {
|
|
||||||
if(FileExists(Info_plist_path))
|
|
||||||
Execute("defaults delete " + Info_plist_path); // Force MacOS to reload plist
|
|
||||||
SaveFile(Info_plist_path, Info_plist);
|
|
||||||
PutConsole("Saving " << Info_plist_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CustomStep(".post-link", Null, error);
|
CustomStep(".post-link", Null, error);
|
||||||
PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length
|
PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length
|
||||||
<< " B) linked in " << GetPrintTime(time));
|
<< " B) linked in " << GetPrintTime(time));
|
||||||
|
|
@ -595,6 +572,7 @@ bool GccBuilder::Link(const Vector<String>& linkfile, const String& linkoptions,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length
|
PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length
|
||||||
<< " B) is up to date.");
|
<< " B) is up to date.");
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue