OSX export: Default to fat format, make it an enum

Since we want to distribute only the fat binary in the official templates, this should
make it work out of the box. 32 bits and 64 bits options are still available for people
that want them, but will throw an error if the binaries are not in the template zip.
This commit is contained in:
Rémi Verschelde 2016-07-09 00:46:10 +02:00
parent 69c8b583e7
commit 02aeac12d1
1 changed files with 27 additions and 21 deletions

View File

@ -48,6 +48,11 @@ class EditorExportPlatformOSX : public EditorExportPlatform {
String custom_release_package; String custom_release_package;
String custom_debug_package; String custom_debug_package;
enum BitsMode {
BITS_FAT,
BITS_64,
BITS_32
};
int version_code; int version_code;
@ -59,8 +64,7 @@ class EditorExportPlatformOSX : public EditorExportPlatform {
String version; String version;
String signature; String signature;
String copyright; String copyright;
bool use64; BitsMode bits_mode;
bool useFat;
bool high_resolution; bool high_resolution;
Ref<ImageTexture> logo; Ref<ImageTexture> logo;
@ -83,7 +87,7 @@ public:
virtual bool poll_devices() { return false;} virtual bool poll_devices() { return false;}
virtual int get_device_count() const { return 0; }; virtual int get_device_count() const { return 0; }
virtual String get_device_name(int p_device) const { return String(); } virtual String get_device_name(int p_device) const { return String(); }
virtual String get_device_info(int p_device) const { return String(); } virtual String get_device_info(int p_device) const { return String(); }
virtual Error run(int p_device,int p_flags=0); virtual Error run(int p_device,int p_flags=0);
@ -122,10 +126,8 @@ bool EditorExportPlatformOSX::_set(const StringName& p_name, const Variant& p_va
version=p_value; version=p_value;
else if (n=="application/copyright") else if (n=="application/copyright")
copyright=p_value; copyright=p_value;
else if (n=="application/64_bits") else if (n=="application/bits_mode")
use64=p_value; bits_mode=BitsMode(int(p_value));
else if (n=="application/fat_bits")
useFat=p_value;
else if (n=="display/high_res") else if (n=="display/high_res")
high_resolution=p_value; high_resolution=p_value;
else else
@ -158,10 +160,8 @@ bool EditorExportPlatformOSX::_get(const StringName& p_name,Variant &r_ret) cons
r_ret=version; r_ret=version;
else if (n=="application/copyright") else if (n=="application/copyright")
r_ret=copyright; r_ret=copyright;
else if (n=="application/64_bits") else if (n=="application/bits_mode")
r_ret=use64; r_ret=bits_mode;
else if (n=="application/fat_bits")
r_ret=useFat;
else if (n=="display/high_res") else if (n=="display/high_res")
r_ret=high_resolution; r_ret=high_resolution;
else else
@ -182,13 +182,9 @@ void EditorExportPlatformOSX::_get_property_list( List<PropertyInfo> *p_list) co
p_list->push_back( PropertyInfo( Variant::STRING, "application/short_version") ); p_list->push_back( PropertyInfo( Variant::STRING, "application/short_version") );
p_list->push_back( PropertyInfo( Variant::STRING, "application/version") ); p_list->push_back( PropertyInfo( Variant::STRING, "application/version") );
p_list->push_back( PropertyInfo( Variant::STRING, "application/copyright") ); p_list->push_back( PropertyInfo( Variant::STRING, "application/copyright") );
p_list->push_back( PropertyInfo( Variant::BOOL, "application/64_bits") ); p_list->push_back( PropertyInfo( Variant::INT, "application/bits_mode", PROPERTY_HINT_ENUM, "Fat (32 & 64 bits),64 bits,32 bits") );
p_list->push_back( PropertyInfo( Variant::BOOL, "application/fat_bits") );
p_list->push_back( PropertyInfo( Variant::BOOL, "display/high_res") ); p_list->push_back( PropertyInfo( Variant::BOOL, "display/high_res") );
//p_list->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Copy,Single Exec.,Pack (.pck),Bundles (Optical)"));
} }
void EditorExportPlatformOSX::_make_icon(const Image& p_icon,Vector<uint8_t>& icon) { void EditorExportPlatformOSX::_make_icon(const Image& p_icon,Vector<uint8_t>& icon) {
@ -321,7 +317,8 @@ Error EditorExportPlatformOSX::export_project(const String& p_path, bool p_debug
io2.opaque=&dst_f; io2.opaque=&dst_f;
zipFile dpkg=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io2); zipFile dpkg=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io2);
String binary_to_use="godot_osx_"+String(p_debug?"debug":"release")+"."+String(useFat?"fat":use64?"64":"32"); String binary_to_use = "godot_osx_" + String(p_debug ? "debug" : "release") + ".";
binary_to_use += String(bits_mode==BITS_FAT ? "fat" : bits_mode==BITS_64 ? "64" : "32");
print_line("binary: "+binary_to_use); print_line("binary: "+binary_to_use);
String pkg_name; String pkg_name;
@ -333,6 +330,8 @@ Error EditorExportPlatformOSX::export_project(const String& p_path, bool p_debug
pkg_name="Unnamed"; pkg_name="Unnamed";
bool found_binary = false;
while(ret==UNZ_OK) { while(ret==UNZ_OK) {
//get filename //get filename
@ -366,6 +365,7 @@ Error EditorExportPlatformOSX::export_project(const String& p_path, bool p_debug
ret = unzGoToNextFile(pkg); ret = unzGoToNextFile(pkg);
continue; //ignore! continue; //ignore!
} }
found_binary = true;
file="Contents/MacOS/"+pkg_name; file="Contents/MacOS/"+pkg_name;
} }
@ -420,6 +420,13 @@ Error EditorExportPlatformOSX::export_project(const String& p_path, bool p_debug
ret = unzGoToNextFile(pkg); ret = unzGoToNextFile(pkg);
} }
if (!found_binary) {
ERR_PRINTS("Requested template binary '"+binary_to_use+"' not found. It might be missing from your template archive.");
zipClose(dpkg,NULL);
unzClose(pkg);
return ERR_FILE_NOT_FOUND;
}
ep.step("Making PKG",1); ep.step("Making PKG",1);
@ -487,13 +494,12 @@ EditorExportPlatformOSX::EditorExportPlatformOSX() {
logo = Ref<ImageTexture>( memnew( ImageTexture )); logo = Ref<ImageTexture>( memnew( ImageTexture ));
logo->create_from_image(img); logo->create_from_image(img);
info="This Game is Nice"; info="Made with Godot Engine";
identifier="com.godot.macgame"; identifier="org.godotengine.macgame";
signature="godotmacgame"; signature="godotmacgame";
short_version="1.0"; short_version="1.0";
version="1.0"; version="1.0";
use64=false; bits_mode=BITS_FAT;
useFat=false;
high_resolution=false; high_resolution=false;
} }