Browse Source

Merge pull request #1619 from BastiaanOlij/add_gdnative_branch_info

Added some info about the branches in the GDNative repositories
Nathan Lovato 6 years ago
parent
commit
ead283f681

+ 1 - 1
tutorials/plugins/gdnative/files/cpp_example/SConstruct

@@ -37,7 +37,7 @@ elif platform == "windows":
 
 
     final_lib_path = final_lib_path + 'win' + str(bits) + '/'
     final_lib_path = final_lib_path + 'win' + str(bits) + '/'
 
 
-env.Append(CPPPATH=['.', 'src/', "godot_headers/", 'godot-cpp/include/', 'godot-cpp/include/core/'])
+env.Append(CPPPATH=['.', 'src/', "godot-cpp/godot_headers/", 'godot-cpp/include/', 'godot-cpp/include/core/', 'godot-cpp/include/gen/'])
 env.Append(LIBPATH="godot-cpp/bin")
 env.Append(LIBPATH="godot-cpp/bin")
 env.Append(LIBS=["godot-cpp" + "." + platform + "." + str(bits)])
 env.Append(LIBS=["godot-cpp" + "." + platform + "." + str(bits)])
 
 

+ 13 - 3
tutorials/plugins/gdnative/gdnative-c-example.rst

@@ -44,9 +44,19 @@ For number 3, we suggest that you create a folder somewhere that you use to stor
 
 
     git clone https://github.com/GodotNativeTools/godot_headers
     git clone https://github.com/GodotNativeTools/godot_headers
 
 
-This will download the required files into that folder. 
+This will download the required files into that folder.
 
 
-If you are building Godot from source, you may need a newer version of these files. You can find this at ``<godotsource>/modules/gdnative/include``
+.. note:: On this repository you will now find different branches. As Godot evolves, so does GDNative. With the exception of one breaking change in ARVR between 3.0 and 3.1, GDNative modules build for older versions of Godot will work with newer versions of Godot but not the other way around.
+
+The master branch of the ``godot_headers`` repository is kept in line with the master branch of Godot and thus contains the GDNative class and structure definitions that will work with the latest Godot master.
+
+The 3.0 branch of the ``godot_headers`` repository contains the GDNative class and structure definitions that will work with Godot 3.0. You can clone this branch by executing:
+
+.. code-block:: none
+
+    git clone https://github.com/GodotNativeTools/godot_headers -b 3.0
+
+If you are building Godot from source with your own changes that impact GDNative, you can find the updated class and structure definition in ``<godotsource>/modules/gdnative/include``
 
 
 Our C source
 Our C source
 ------------
 ------------
@@ -244,7 +254,7 @@ On Windows:
     cl /Fosimple.obj /c simple.c /nologo -EHsc -DNDEBUG /MD /I. /IC:\PATH\TO\GODOT\HEADERS
     cl /Fosimple.obj /c simple.c /nologo -EHsc -DNDEBUG /MD /I. /IC:\PATH\TO\GODOT\HEADERS
     link /nologo /dll /out:..\bin\libsimple.dll /implib:..\bin\libsimple.lib simple.obj
     link /nologo /dll /out:..\bin\libsimple.dll /implib:..\bin\libsimple.lib simple.obj
 
 
-Note that on the Windows build you also end up with a libsimple.lib library. This is a library that you can compile into a project to provide access to the DLL. We get it as a bonus and we do not need it :) When exporting your game for release this file will be ignored.
+.. note:: on the Windows build you also end up with a libsimple.lib library. This is a library that you can compile into a project to provide access to the DLL. We get it as a bonus and we do not need it :) When exporting your game for release this file will be ignored.
 
 
 Creating our GDNLIB file
 Creating our GDNLIB file
 ------------------------
 ------------------------

+ 26 - 8
tutorials/plugins/gdnative/gdnative-cpp-example.rst

@@ -38,7 +38,10 @@ See also :ref:`Compiling <toc-devel-compiling>` as the build tools are identical
 to the ones you need to compile Godot from source.
 to the ones you need to compile Godot from source.
 
 
 You can download these repositories from GitHub or let Git
 You can download these repositories from GitHub or let Git
-do the work for you. If you are versioning your project using Git,
+do the work for you. 
+Note that these repositories now have different branches for different versions of Godot. GDNative modules written for an earlier version of Godot will work in newer versions (with the exception of one breaking change in ARVR interfaces between 3.0 and 3.1) but not vise versa so make sure you download the correct branch.
+
+If you are versioning your project using Git,
 it is a good idea to add them as Git submodules:
 it is a good idea to add them as Git submodules:
 
 
 .. code-block:: none
 .. code-block:: none
@@ -46,14 +49,29 @@ it is a good idea to add them as Git submodules:
     mkdir gdnative_cpp_example
     mkdir gdnative_cpp_example
     cd gdnative_cpp_example
     cd gdnative_cpp_example
     git init
     git init
-    git submodule add https://github.com/GodotNativeTools/godot_headers
-    git submodule add https://github.com/GodotNativeTools/godot-cpp
+    git submodule add -b 3.0 https://github.com/GodotNativeTools/godot-cpp
+    cd godot-cpp
+    git submodule init
+    git submodule update
+    cd ..
 
 
 If you decide to just download the repositories or clone them
 If you decide to just download the repositories or clone them
 into your project folder, make sure to keep the folder layout identical
 into your project folder, make sure to keep the folder layout identical
 to the one described here, as much of the code we'll be showcasing here
 to the one described here, as much of the code we'll be showcasing here
 assumes the project follows this layout.
 assumes the project follows this layout.
 
 
+Do make sure you clone recursive to pull in both repositories:
+.. code-block:: none
+
+    mkdir gdnative_cpp_example
+    cd gdnative_cpp_example
+    git clone --recursive -b 3.0 https://github.com/GodotNativeTools/godot-cpp
+
+.. note:: The ``-b 3.0`` I've added as an example to show how to select a specific branch for a specific version of Godot.
+          Also ``godot-cpp`` now includes ``godot_headers`` as a nested submodule, if you've manually downloaded them please make sure to place ``godot_headers`` inside of the ``godot-cpp`` folder.
+          
+          You don't have to do it this way but I've found it easiest to manage. If you decide to just download the repositories or just clone them into your folder, makes sure to keep the folder layout the same as I've setup here as much of the code we'll be showcasing here assumes the project has this layout.
+
 If you cloned the example from the link specified in
 If you cloned the example from the link specified in
 the introduction, the submodules are not automatically initialized.
 the introduction, the submodules are not automatically initialized.
 You will need to execute the following commands:
 You will need to execute the following commands:
@@ -61,7 +79,7 @@ You will need to execute the following commands:
 .. code-block:: none
 .. code-block:: none
 
 
     cd gdnative_cpp_example
     cd gdnative_cpp_example
-    git submodule --init update
+    git submodule --init update --recursive
 
 
 This will clone these two repositories into your project folder.
 This will clone these two repositories into your project folder.
 
 
@@ -77,9 +95,9 @@ simply call the Godot executable:
 
 
 .. code-block:: none
 .. code-block:: none
 
 
-    godot --gdnative-generate-json-api godot_api.json
+    godot --gdnative-generate-json-api api.json
 
 
-Place the resulting ``godot_api.json`` file in the ``godot-cpp/`` folder.
+Place the resulting ``api.json`` file in the project folder and add ``use_custom_api_file=yes custom_api_file=../api.json`` to the scons command below.
 
 
 To generate and compile the bindings, use this command (replacing
 To generate and compile the bindings, use this command (replacing
 ``<platform>`` with ``windows``, ``x11`` or ``osx`` depending on your OS):
 ``<platform>`` with ``windows``, ``x11`` or ``osx`` depending on your OS):
@@ -87,7 +105,7 @@ To generate and compile the bindings, use this command (replacing
 .. code-block:: none
 .. code-block:: none
 
 
     cd godot-cpp
     cd godot-cpp
-    scons platform=<platform> headers_dir=../godot_headers generate_bindings=yes
+    scons platform=<platform> generate_bindings=yes
     cd ..
     cd ..
 
 
 This step will take a while. When it is completed, you should have static
 This step will take a while. When it is completed, you should have static
@@ -272,7 +290,7 @@ and ``demo``, then run:
 
 
 You should now be able to find the module in ``demo/bin/<platform>``.
 You should now be able to find the module in ``demo/bin/<platform>``.
 
 
-**Note:** Here, we've compiled both godot-cpp and our gdexample library
+.. note:: Here, we've compiled both godot-cpp and our gdexample library
 as debug builds. For optimized builds, you should compile them using
 as debug builds. For optimized builds, you should compile them using
 the ``target=release`` switch.
 the ``target=release`` switch.