Windows compatibility

pull/7/head
Karroffel 2017-03-15 23:19:58 +01:00
parent bce9ac109d
commit 8d63048c6d
35 changed files with 259 additions and 43 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ include/godot.h
include/godot include/godot
*.os *.os
*.so *.so
*.obj

View File

@ -126,6 +126,15 @@ fn generate_class_header(used_classes: &HashSet<&String>, class: &GodotClass) ->
contents = contents + "#define "; contents = contents + "#define ";
contents = contents + strip_name(&class.name).to_string().to_uppercase().as_str() + "_H\n\n"; contents = contents + strip_name(&class.name).to_string().to_uppercase().as_str() + "_H\n\n";
contents = contents + "#if defined(_WIN32) && defined(_GD_CPP_BINDING_IMPL)\n";
contents = contents + "# define GD_CPP_BINDING_API __declspec(dllexport)\n";
contents = contents + "#elif defined(_WIN32)\n";
contents = contents + "# define GD_CPP_BINDING_API __declspec(dllimport)\n";
contents = contents + "#else\n";
contents = contents + "# define GD_CPP_BINDING_API\n";
contents = contents + "#endif\n\n";
contents = contents + "\n#include \"core/CoreTypes.hpp\"\n"; contents = contents + "\n#include \"core/CoreTypes.hpp\"\n";
contents = contents + "\n#include <godot.h>\n\n\n"; contents = contents + "\n#include <godot.h>\n\n\n";
@ -154,7 +163,7 @@ fn generate_class_header(used_classes: &HashSet<&String>, class: &GodotClass) ->
name name
}; };
contents = contents + "class " + strip_name(&class.name); contents = contents + "class GD_CPP_BINDING_API " + strip_name(&class.name);
if class.base_class != "" { if class.base_class != "" {
contents = contents + " : public " + strip_name(&class.base_class); contents = contents + " : public " + strip_name(&class.base_class);
@ -234,7 +243,7 @@ fn generate_class_header(used_classes: &HashSet<&String>, class: &GodotClass) ->
if class.base_class == "" { if class.base_class == "" {
// Object // Object
contents = contents + "\ninline Variant::operator Object() const\n{\n\n"; contents = contents + "\ninline\n#if defined(_WIN32)\n# ifdef _GD_CPP_BINDING_IMPL\n __declspec(dllexport)\n# else\n __declspec(dllimport)\n# endif\n#endif\nVariant::operator Object() const\n{\n\n";
contents = contents + "\treturn Object(godot_variant_as_object(&_godot_variant));\n\n"; contents = contents + "\treturn Object(godot_variant_as_object(&_godot_variant));\n\n";
@ -551,7 +560,7 @@ fn generate_icall_implementation(icalls: &HashSet<(String, Vec<String>)>) -> Str
contents = contents + "\t" + if !is_core_type(ret) && !is_primitive(ret) { "godot_object*" } else { strip_name(ret) } + " ret;\n"; contents = contents + "\t" + if !is_core_type(ret) && !is_primitive(ret) { "godot_object*" } else { strip_name(ret) } + " ret;\n";
} }
contents = contents + "\tconst void *args[] = {\n"; contents = contents + "\tconst void *args[" + if args.len() == 0 { "1" } else { "" } + "] = {\n";
let mut j = 0; let mut j = 0;
for arg in args { for arg in args {

BIN
include/.sconsign.dblite Normal file

Binary file not shown.

View File

@ -3,15 +3,24 @@ import os
env = Environment() env = Environment()
if ARGUMENTS.get("use_llvm", "yes") == "yes": if ARGUMENTS.get("use_llvm", "no") == "yes":
env["CXX"] = "clang++" env["CXX"] = "clang++"
target = ARGUMENTS.get("target", "core") target = ARGUMENTS.get("target", "core")
platform = ARGUMENTS.get("p", "linux")
if (target == "core"): if (target == "core"):
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14']) if platform == "linux":
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14'])
env.Append(CPPPATH=['.', './godot']) env.Append(CPPPATH=['.', './godot'])
if platform == "windows":
env.Append(LIBS=['godot.windows.tools.64.lib'])
env.Append(CPPFLAGS=['-D_GD_CPP_CORE_API_IMPL'])
sources = [ sources = [
'godot_cpp/core/Array.cpp', 'godot_cpp/core/Array.cpp',
'godot_cpp/core/Basis.cpp', 'godot_cpp/core/Basis.cpp',
@ -38,18 +47,20 @@ if (target == "core"):
Default(library) Default(library)
elif target == "bindings": elif target == "bindings":
if env["CXX"] == "clang++": if platform == "linux":
env.Append(CCFLAGS = ['-Wno-writable-strings']) if env["CXX"] == "clang++":
else: env.Append(CCFLAGS = ['-Wno-writable-strings'])
env.Append(CCFLAGS = ['-Wno-write-strings', '-Wno-return-local-addr']) else:
env.Append(CCFLAGS = ['-Wno-write-strings', '-Wno-return-local-addr'])
env.Append(CCFLAGS = ['-g','-O3', '-std=c++14']) env.Append(CCFLAGS = ['-g','-O3', '-std=c++14'])
env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN/\''])
env.Append(CPPPATH=['.', './godot', './godot_cpp']) env.Append(CPPPATH=['.', './godot', './godot_cpp'])
env.Append(LINKFLAGS = ['-Wl,-R,\'$$ORIGIN/\'']) env.Append(LIBS=['godot_cpp_core', 'godot.windows.tools.64'])
env.Append(LIBS=['godot_cpp_core'])
env.Append(LIBPATH=["."]) env.Append(LIBPATH=["."])
env.Append(CPPFLAGS=['-D_GD_CPP_BINDING_IMPL'])
sources = [os.path.join("godot_cpp/impl/", f) for f in os.listdir("godot_cpp/impl/") if f.endswith('.cpp')] sources = [os.path.join("godot_cpp/impl/", f) for f in os.listdir("godot_cpp/impl/") if f.endswith('.cpp')]

Binary file not shown.

View File

@ -1,6 +1,16 @@
#ifndef ARRAY_H #ifndef ARRAY_H
#define ARRAY_H #define ARRAY_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include <godot/godot_array.h> #include <godot/godot_array.h>
#include "String.hpp" #include "String.hpp"
@ -18,7 +28,7 @@ class PoolColorArray;
class Object; class Object;
class Array { class GD_CPP_CORE_API Array {
godot_array _godot_array; godot_array _godot_array;
public: public:
Array(); Array();

View File

@ -1,6 +1,16 @@
#ifndef BASIS_H #ifndef BASIS_H
#define BASIS_H #define BASIS_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "Defs.hpp" #include "Defs.hpp"
#include "Vector3.hpp" #include "Vector3.hpp"
@ -9,7 +19,7 @@ namespace godot {
class Quat; class Quat;
class Basis { class GD_CPP_CORE_API Basis {
public: public:
Vector3 elements[3]; Vector3 elements[3];

View File

@ -1,6 +1,16 @@
#ifndef COLOR_H #ifndef COLOR_H
#define COLOR_H #define COLOR_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include <godot/godot_color.h> #include <godot/godot_color.h>
#include <cmath> #include <cmath>
@ -10,7 +20,7 @@
namespace godot { namespace godot {
struct Color { struct GD_CPP_CORE_API Color {
private: private:

View File

@ -18,7 +18,7 @@
#include "RID.hpp" #include "RID.hpp"
#include "String.hpp" #include "String.hpp"
#include "Transform.hpp" #include "Transform.hpp"
#include "Transform2D.hp" #include "Transform2D.hpp"
#include "Variant.hpp" #include "Variant.hpp"
#include "Vector2.hpp" #include "Vector2.hpp"
#include "Vector3.hpp" #include "Vector3.hpp"

View File

@ -1,6 +1,16 @@
#ifndef DICTIONARY_H #ifndef DICTIONARY_H
#define DICTIONARY_H #define DICTIONARY_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "Variant.hpp" #include "Variant.hpp"
#include "Array.hpp" #include "Array.hpp"
@ -9,7 +19,7 @@
namespace godot { namespace godot {
class Dictionary { class GD_CPP_CORE_API Dictionary {
godot_dictionary _godot_dictionary; godot_dictionary _godot_dictionary;
public: public:
Dictionary(); Dictionary();

View File

@ -1,6 +1,16 @@
#ifndef IMAGE_H #ifndef IMAGE_H
#define IMAGE_H #define IMAGE_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "Defs.hpp" #include "Defs.hpp"
#include "Vector2.hpp" #include "Vector2.hpp"
@ -14,7 +24,7 @@ namespace godot {
class PoolByteArray; class PoolByteArray;
class Image { class GD_CPP_CORE_API Image {
godot_image _godot_image; godot_image _godot_image;
public: public:

View File

@ -4,7 +4,7 @@
#include <memory.h> #include <memory.h>
#include "Vector2.hpp" #include "Vector2.hpp"
#include "Transform2D.hp" #include "Transform2D.hpp"
#include <cmath> #include <cmath>

View File

@ -1,6 +1,16 @@
#ifndef INPUTEVENT_H #ifndef INPUTEVENT_H
#define INPUTEVENT_H #define INPUTEVENT_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include <cstdint> #include <cstdint>
#include <memory.h> #include <memory.h>
@ -119,7 +129,7 @@ enum {
* Input Modifier Status * Input Modifier Status
* for keyboard/mouse events. * for keyboard/mouse events.
*/ */
struct InputModifierState { struct GD_CPP_CORE_API InputModifierState {
bool shift; bool shift;
bool alt; bool alt;
@ -223,7 +233,7 @@ struct InputEventAction {
class Transform2D; class Transform2D;
struct InputEvent { struct GD_CPP_CORE_API InputEvent {
enum Type { enum Type {
NONE, NONE,

View File

@ -1,6 +1,16 @@
#ifndef NODEPATH_H #ifndef NODEPATH_H
#define NODEPATH_H #define NODEPATH_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "String.hpp" #include "String.hpp"
#include <godot/godot_node_path.h> #include <godot/godot_node_path.h>
@ -8,7 +18,7 @@
namespace godot { namespace godot {
class NodePath class GD_CPP_CORE_API NodePath
{ {
godot_node_path _node_path; godot_node_path _node_path;
public: public:

View File

@ -1,6 +1,16 @@
#ifndef PLANE_H #ifndef PLANE_H
#define PLANE_H #define PLANE_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "Vector3.hpp" #include "Vector3.hpp"
#include <cmath> #include <cmath>
@ -15,7 +25,7 @@ enum ClockDirection {
COUNTERCLOCKWISE COUNTERCLOCKWISE
}; };
class Plane { class GD_CPP_CORE_API Plane {
public: public:
Vector3 normal; Vector3 normal;
real_t d; real_t d;

View File

@ -1,6 +1,16 @@
#ifndef POOLARRAYS_H #ifndef POOLARRAYS_H
#define POOLARRAYS_H #define POOLARRAYS_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "Defs.hpp" #include "Defs.hpp"
#include "String.hpp" #include "String.hpp"
@ -14,7 +24,7 @@ namespace godot {
class Array; class Array;
class PoolByteArray { class GD_CPP_CORE_API PoolByteArray {
godot_pool_byte_array _godot_array; godot_pool_byte_array _godot_array;
public: public:
PoolByteArray(); PoolByteArray();
@ -45,7 +55,7 @@ public:
}; };
class PoolIntArray { class GD_CPP_CORE_API PoolIntArray {
godot_pool_int_array _godot_array; godot_pool_int_array _godot_array;
public: public:
PoolIntArray(); PoolIntArray();
@ -76,7 +86,7 @@ public:
}; };
class PoolRealArray { class GD_CPP_CORE_API PoolRealArray {
godot_pool_real_array _godot_array; godot_pool_real_array _godot_array;
public: public:
PoolRealArray(); PoolRealArray();
@ -107,7 +117,7 @@ public:
}; };
class PoolStringArray { class GD_CPP_CORE_API PoolStringArray {
godot_pool_string_array _godot_array; godot_pool_string_array _godot_array;
public: public:
PoolStringArray(); PoolStringArray();
@ -139,7 +149,7 @@ public:
class PoolVector2Array { class GD_CPP_CORE_API PoolVector2Array {
godot_pool_vector2_array _godot_array; godot_pool_vector2_array _godot_array;
public: public:
PoolVector2Array(); PoolVector2Array();
@ -170,7 +180,7 @@ public:
}; };
class PoolVector3Array { class GD_CPP_CORE_API PoolVector3Array {
godot_pool_vector3_array _godot_array; godot_pool_vector3_array _godot_array;
public: public:
PoolVector3Array(); PoolVector3Array();
@ -201,7 +211,7 @@ public:
}; };
class PoolColorArray { class GD_CPP_CORE_API PoolColorArray {
godot_pool_color_array _godot_array; godot_pool_color_array _godot_array;
public: public:
PoolColorArray(); PoolColorArray();

View File

@ -1,6 +1,16 @@
#ifndef QUAT_H #ifndef QUAT_H
#define QUAT_H #define QUAT_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include <cmath> #include <cmath>
#include "Vector3.hpp" #include "Vector3.hpp"
@ -9,7 +19,7 @@
namespace godot { namespace godot {
class Quat{ class GD_CPP_CORE_API Quat{
public: public:
real_t x,y,z,w; real_t x,y,z,w;

View File

@ -1,13 +1,23 @@
#ifndef RID_H #ifndef RID_H
#define RID_H #define RID_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include <godot/godot_rid.h> #include <godot/godot_rid.h>
namespace godot { namespace godot {
class Object; class Object;
class RID { class GD_CPP_CORE_API RID {
godot_rid _godot_rid; godot_rid _godot_rid;
public: public:

View File

@ -6,7 +6,7 @@
#include <cmath> #include <cmath>
#include "Transform2D.hp" #include "Transform2D.hpp"
namespace godot { namespace godot {

View File

@ -1,6 +1,16 @@
#ifndef RECT2_H #ifndef RECT2_H
#define RECT2_H #define RECT2_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "Vector2.hpp" #include "Vector2.hpp"
#include <cmath> #include <cmath>
@ -16,7 +26,7 @@ typedef Vector2 Point2;
class Transform2D; class Transform2D;
struct Rect2 { struct GD_CPP_CORE_API Rect2 {
Point2 pos; Point2 pos;
Size2 size; Size2 size;

View File

@ -1,6 +1,16 @@
#ifndef RECT3_H #ifndef RECT3_H
#define RECT3_H #define RECT3_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "Vector3.hpp" #include "Vector3.hpp"
#include "Plane.hpp" #include "Plane.hpp"
@ -9,7 +19,7 @@
namespace godot { namespace godot {
class Rect3 { class GD_CPP_CORE_API Rect3 {
public: public:
Vector3 pos; Vector3 pos;
Vector3 size; Vector3 size;

View File

@ -120,6 +120,11 @@ const wchar_t *String::c_string() const
} }
String operator +(const char *a, const String& b)
{
return String(a) + b;
}
} }

View File

@ -1,11 +1,21 @@
#ifndef STRING_H #ifndef STRING_H
#define STRING_H #define STRING_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include <godot/godot_string.h> #include <godot/godot_string.h>
namespace godot { namespace godot {
class String class GD_CPP_CORE_API String
{ {
godot_string _godot_string; godot_string _godot_string;
public: public:

View File

@ -1,6 +1,16 @@
#ifndef TRANSFORM_H #ifndef TRANSFORM_H
#define TRANSFORM_H #define TRANSFORM_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "Basis.hpp" #include "Basis.hpp"
#include "Plane.hpp" #include "Plane.hpp"
@ -8,7 +18,7 @@
namespace godot { namespace godot {
class Transform { class GD_CPP_CORE_API Transform {
public: public:
Basis basis; Basis basis;

View File

@ -1,4 +1,4 @@
#include "Transform2D.hp" #include "Transform2D.hpp"
#include "Vector2.hpp" #include "Vector2.hpp"

View File

@ -1,6 +1,16 @@
#ifndef TRANSFORM2D_H #ifndef TRANSFORM2D_H
#define TRANSFORM2D_H #define TRANSFORM2D_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "Vector2.hpp" #include "Vector2.hpp"
@ -10,7 +20,7 @@ typedef Vector2 Size2;
class Rect2; class Rect2;
struct Transform2D { struct GD_CPP_CORE_API Transform2D {
// Warning #1: basis of Transform2D is stored differently from Basis. In terms of elements array, the basis matrix looks like "on paper": // Warning #1: basis of Transform2D is stored differently from Basis. In terms of elements array, the basis matrix looks like "on paper":
// M = (elements[0][0] elements[1][0]) // M = (elements[0][0] elements[1][0])
// (elements[0][1] elements[1][1]) // (elements[0][1] elements[1][1])

View File

@ -1,6 +1,16 @@
#ifndef VARIANT_H #ifndef VARIANT_H
#define VARIANT_H #define VARIANT_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include <godot/godot_variant.h> #include <godot/godot_variant.h>
#include "Defs.hpp" #include "Defs.hpp"
@ -18,7 +28,7 @@
#include "RID.hpp" #include "RID.hpp"
#include "String.hpp" #include "String.hpp"
#include "Transform.hpp" #include "Transform.hpp"
#include "Transform2D.hp" #include "Transform2D.hpp"
#include "Vector2.hpp" #include "Vector2.hpp"
#include "Vector3.hpp" #include "Vector3.hpp"
@ -30,7 +40,7 @@ class Dictionary;
class Array; class Array;
class Variant { class GD_CPP_CORE_API Variant {
godot_variant _godot_variant; godot_variant _godot_variant;
public: public:
enum Type { enum Type {

View File

@ -2,6 +2,16 @@
#define VECTOR2_H #define VECTOR2_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include <godot/godot_vector2.h> #include <godot/godot_vector2.h>
#include "Defs.hpp" #include "Defs.hpp"
@ -10,7 +20,7 @@ namespace godot {
class String; class String;
struct Vector2 { struct GD_CPP_CORE_API Vector2 {
union { union {
real_t x; real_t x;

View File

@ -1,6 +1,16 @@
#ifndef VECTOR3_H #ifndef VECTOR3_H
#define VECTOR3_H #define VECTOR3_H
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "Defs.hpp" #include "Defs.hpp"
#include "String.hpp" #include "String.hpp"
@ -8,7 +18,7 @@
namespace godot { namespace godot {
struct Vector3 { struct GD_CPP_CORE_API Vector3 {
enum Axis { enum Axis {
AXIS_X, AXIS_X,

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
include/godot_cpp_core.dll Normal file

Binary file not shown.

BIN
include/godot_cpp_core.exp Normal file

Binary file not shown.

BIN
include/godot_cpp_core.lib Normal file

Binary file not shown.