Fix x11 exported executables not getting the +x flag

This commit is contained in:
Marcelo Fernandez 2017-09-17 14:40:58 -03:00
parent 574a5714dc
commit 3528b1e571
8 changed files with 43 additions and 4 deletions

View File

@ -292,7 +292,7 @@ String DirAccess::get_full_path(const String &p_path, AccessType p_access) {
return full; return full;
} }
Error DirAccess::copy(String p_from, String p_to) { Error DirAccess::copy(String p_from, String p_to, int chmod_flags) {
//printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data()); //printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data());
Error err; Error err;
@ -329,6 +329,11 @@ Error DirAccess::copy(String p_from, String p_to) {
fdst->store_8(fsrc->get_8()); fdst->store_8(fsrc->get_8());
} }
if (err == OK && chmod_flags != -1) {
fdst->close();
err = fdst->_chmod(p_to, chmod_flags);
}
memdelete(fsrc); memdelete(fsrc);
memdelete(fdst); memdelete(fdst);

View File

@ -89,7 +89,7 @@ public:
static bool exists(String p_dir); static bool exists(String p_dir);
virtual size_t get_space_left() = 0; virtual size_t get_space_left() = 0;
virtual Error copy(String p_from, String p_to); virtual Error copy(String p_from, String p_to, int chmod_flags = -1);
virtual Error rename(String p_from, String p_to) = 0; virtual Error rename(String p_from, String p_to) = 0;
virtual Error remove(String p_name) = 0; virtual Error remove(String p_name) = 0;

View File

@ -140,6 +140,8 @@ public:
virtual Error reopen(const String &p_path, int p_mode_flags); ///< does not change the AccessType virtual Error reopen(const String &p_path, int p_mode_flags); ///< does not change the AccessType
virtual Error _chmod(const String &p_path, int p_mod) {}
static FileAccess *create(AccessType p_access); /// Create a file access (for the current platform) this is the only portable way of accessing files. static FileAccess *create(AccessType p_access); /// Create a file access (for the current platform) this is the only portable way of accessing files.
static FileAccess *create_for_path(const String &p_path); static FileAccess *create_for_path(const String &p_path);
static FileAccess *open(const String &p_path, int p_mode_flags, Error *r_error = NULL); /// Create a file access (for the current platform) this is the only portable way of accessing files. static FileAccess *open(const String &p_path, int p_mode_flags, Error *r_error = NULL); /// Create a file access (for the current platform) this is the only portable way of accessing files.

View File

@ -274,6 +274,15 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) {
}; };
} }
Error FileAccessUnix::_chmod(const String &p_path, int p_mod) {
int err = chmod(p_path.utf8().get_data(), p_mod);
if (!err) {
return OK;
}
return FAILED;
}
FileAccess *FileAccessUnix::create_libc() { FileAccess *FileAccessUnix::create_libc() {
return memnew(FileAccessUnix); return memnew(FileAccessUnix);

View File

@ -78,6 +78,8 @@ public:
virtual uint64_t _get_modified_time(const String &p_file); virtual uint64_t _get_modified_time(const String &p_file);
virtual Error _chmod(const String &p_path, int p_mod);
FileAccessUnix(); FileAccessUnix();
virtual ~FileAccessUnix(); virtual ~FileAccessUnix();
}; };

View File

@ -1246,9 +1246,13 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr
} }
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->copy(template_path, p_path); Error err = da->copy(template_path, p_path, get_chmod_flags());
memdelete(da); memdelete(da);
if (err != OK) {
return err;
}
String pck_path = p_path.get_basename() + ".pck"; String pck_path = p_path.get_basename() + ".pck";
return save_pack(p_preset, pck_path); return save_pack(p_preset, pck_path);
@ -1302,5 +1306,17 @@ void EditorExportPlatformPC::get_platform_features(List<String> *r_features) {
} }
} }
EditorExportPlatformPC::EditorExportPlatformPC() { int EditorExportPlatformPC::get_chmod_flags() const {
return chmod_flags;
}
void EditorExportPlatformPC::set_chmod_flags(int p_flags) {
chmod_flags = p_flags;
}
EditorExportPlatformPC::EditorExportPlatformPC() {
chmod_flags = -1;
} }

View File

@ -319,6 +319,7 @@ class EditorExportPlatformPC : public EditorExportPlatform {
Set<String> extra_features; Set<String> extra_features;
bool use64; bool use64;
int chmod_flags;
public: public:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features); virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
@ -347,6 +348,9 @@ public:
void add_platform_feature(const String &p_feature); void add_platform_feature(const String &p_feature);
virtual void get_platform_features(List<String> *r_features); virtual void get_platform_features(List<String> *r_features);
int get_chmod_flags() const;
void set_chmod_flags(int p_flags);
EditorExportPlatformPC(); EditorExportPlatformPC();
}; };

View File

@ -50,6 +50,7 @@ void register_x11_exporter() {
platform->set_release_64("linux_x11_64_release"); platform->set_release_64("linux_x11_64_release");
platform->set_debug_64("linux_x11_64_debug"); platform->set_debug_64("linux_x11_64_debug");
platform->set_os_name("X11"); platform->set_os_name("X11");
platform->set_chmod_flags(0755);
EditorExport::get_singleton()->add_export_platform(platform); EditorExport::get_singleton()->add_export_platform(platform);
} }