Bindings are generated by default; Replaced generate with regenerate flag; Updated readme
parent
38cfd627f3
commit
43f57c7f80
3
Makefile
3
Makefile
|
@ -1,10 +1,11 @@
|
||||||
|
|
||||||
GODOT_BIN_PATH = ../godot_fork/bin/godot.x11.tools.64.llvm
|
GODOT_BIN_PATH = ../godot_fork/bin/godot.x11.tools.64.llvm
|
||||||
|
REGENERATE_BINDINGS = no
|
||||||
HEADERS = ../godot_headers
|
HEADERS = ../godot_headers
|
||||||
TARGET = debug
|
TARGET = debug
|
||||||
NAME = godot-cpp
|
NAME = godot-cpp
|
||||||
|
|
||||||
BASE = scons n=$(NAME) generate_bindings=yes target=$(TARGET) headers=$(HEADERS) godotbinpath=$(GODOT_BIN_PATH) -j4
|
BASE = scons n=$(NAME) regenerate_bindings=$(REGENERATE_BINDINGS) target=$(TARGET) headers=$(HEADERS) godotbinpath=$(GODOT_BIN_PATH) -j4
|
||||||
LINUX = $(BASE) p=linux
|
LINUX = $(BASE) p=linux
|
||||||
WINDOWS = $(BASE) p=windows
|
WINDOWS = $(BASE) p=windows
|
||||||
OSX = $(BASE) p=osx
|
OSX = $(BASE) p=osx
|
||||||
|
|
49
README.md
49
README.md
|
@ -1,53 +1,44 @@
|
||||||
# cpp_bindings
|
# godot-cpp
|
||||||
C++ bindings for the Godot script API
|
C++ bindings for the Godot script API
|
||||||
|
|
||||||
# Creating a GDNative library (Linux)
|
# Creating a GDNative library (Linux)
|
||||||
Create a directory named `SimpleLibrary` with subdirectories `lib, src`
|
Create a directory named `SimpleLibrary` with subdirectories `lib, src`
|
||||||
|
|
||||||
Getting latest `cpp_bindings` and `godot_headers`
|
Getting latest `godot-cpp` and `godot_headers`
|
||||||
```
|
```
|
||||||
$ cd SimpleLibrary
|
$ git clone https://github.com/GodotNativeTools/godot-cpp
|
||||||
$ git clone https://github.com/GodotNativeTools/cpp_bindings
|
|
||||||
$ git clone https://github.com/GodotNativeTools/godot_headers
|
$ git clone https://github.com/GodotNativeTools/godot_headers
|
||||||
```
|
```
|
||||||
right now our directory structure should look like this
|
right now our directory structure should look like this:
|
||||||
```
|
```
|
||||||
[SimpleLibrary]
|
godot-cpp
|
||||||
├── cpp_bindings/
|
godot_headers
|
||||||
├── godot_headers/
|
SimpleLibrary
|
||||||
├── lib/
|
├── lib/
|
||||||
└── src/
|
└── src/
|
||||||
```
|
```
|
||||||
|
|
||||||
Now to generate cpp bindings
|
Now to generate cpp bindings
|
||||||
```
|
```
|
||||||
$ cd cpp_bindings
|
$ cd godot-cpp
|
||||||
```
|
$ scons godotbinpath="../godot_fork/bin/godot_binary" p=linux
|
||||||
|
$ cd ..
|
||||||
Edit `SConstruct` file and assign your godot executable path at line:7 `godot_bin_path = "../godot_fork/bin/"`,
|
|
||||||
|
|
||||||
Building cpp_bindings
|
|
||||||
```
|
|
||||||
$ scons godotbinpath="../godot_fork/bin/godot_binary" headers="../godot_headers/" p=linux generate_bindings=yes
|
|
||||||
```
|
```
|
||||||
resulting libraries will be placed under `bin/` and the generated headers will be placed under `include/*`
|
resulting libraries will be placed under `bin/` and the generated headers will be placed under `include/*`
|
||||||
|
|
||||||
**Note:**
|
**Note:**
|
||||||
> `generate_bindings=yes` is used to generate C++ bindings (`godot_api.json` - Godot API)
|
> `regenerate_bindings=yes` is used to force regenerating C++ bindings (`godot_api.json` - Godot API)
|
||||||
|
|
||||||
> Include `use_llvm=yes` for using clang++
|
> Include `use_llvm=yes` for using clang++
|
||||||
|
|
||||||
Copy binding libraries into the `SimpleLibrary/lib` folder
|
|
||||||
```
|
|
||||||
$ cd ..
|
|
||||||
$ cp cpp_bindings/bin/libgodot_cpp_bindings.a lib/
|
|
||||||
```
|
|
||||||
And our directory structure will be
|
And our directory structure will be
|
||||||
```
|
```
|
||||||
[SimpleLibrary]
|
godot-cpp
|
||||||
├── cpp_bindings/
|
└── bin/libgodot-cpp.a
|
||||||
├── godot_headers/
|
godot_headers
|
||||||
|
SimpleLibrary
|
||||||
├── lib/
|
├── lib/
|
||||||
│ └──libgodot_cpp_bindings.a
|
|
||||||
└── src/
|
└── src/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -115,9 +106,9 @@ extern "C" void GDN_EXPORT godot_nativescript_init(void *handle)
|
||||||
|
|
||||||
# Compiling
|
# Compiling
|
||||||
```
|
```
|
||||||
$ cd ..
|
$ cd SimpleLibrary
|
||||||
$ clang -fPIC -o src/init.os -c src/init.cpp -g -O3 -std=c++14 -Icpp_bindings/include -Igodot_headers
|
$ clang -fPIC -o src/init.os -c src/init.cpp -g -O3 -std=c++14 -I../godot-cpp/include -Igodot_headers
|
||||||
$ clang -o lib/libtest.so -shared src/init.os -Llib -lgodot_cpp_bindings
|
$ clang -o lib/libtest.so -shared src/init.os -L../godot-cpp/lib -lgodot-cpp
|
||||||
```
|
```
|
||||||
This creates the file `libtest.so` in your `SimpleLibrary/lib` directory. For windows you need to find out what compiler flags need to be used.
|
This creates the file `libtest.so` in your `SimpleLibrary/lib` directory. For windows you need to find out what compiler flags need to be used.
|
||||||
|
|
||||||
|
|
12
SConstruct
12
SConstruct
|
@ -3,9 +3,6 @@
|
||||||
import os, subprocess, platform
|
import os, subprocess, platform
|
||||||
|
|
||||||
|
|
||||||
def add_source(sources, name):
|
|
||||||
sources.append(name)
|
|
||||||
|
|
||||||
def add_sources(sources, dir, extension):
|
def add_sources(sources, dir, extension):
|
||||||
for f in os.listdir(dir):
|
for f in os.listdir(dir):
|
||||||
if f.endswith('.' + extension):
|
if f.endswith('.' + extension):
|
||||||
|
@ -21,7 +18,7 @@ target = ARGUMENTS.get('target', 'debug')
|
||||||
# Local dependency paths, adapt them to your setup
|
# Local dependency paths, adapt them to your setup
|
||||||
godot_headers = ARGUMENTS.get('headers', '../godot_headers')
|
godot_headers = ARGUMENTS.get('headers', '../godot_headers')
|
||||||
godot_bin_path = ARGUMENTS.get('godotbinpath', os.getenv('GODOT_BIN_PATH', '../godot_fork/bin/godot.x11.tools.64.llvm'))
|
godot_bin_path = ARGUMENTS.get('godotbinpath', os.getenv('GODOT_BIN_PATH', '../godot_fork/bin/godot.x11.tools.64.llvm'))
|
||||||
result_path = 'bin/'
|
result_path = 'bin'
|
||||||
result_name = ARGUMENTS.get('n', ARGUMENTS.get('name', os.path.relpath('.', '..')))
|
result_name = ARGUMENTS.get('n', ARGUMENTS.get('name', os.path.relpath('.', '..')))
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +50,7 @@ elif target_platform == 'windows':
|
||||||
result_name += '.windows.' + target_arch
|
result_name += '.windows.' + target_arch
|
||||||
|
|
||||||
if host_platform == 'Windows':
|
if host_platform == 'Windows':
|
||||||
result_name += '.dll'
|
result_name += '.lib'
|
||||||
|
|
||||||
env.Append(LINKFLAGS = [ '/WX' ])
|
env.Append(LINKFLAGS = [ '/WX' ])
|
||||||
if target == 'debug':
|
if target == 'debug':
|
||||||
|
@ -77,10 +74,9 @@ elif platform == 'osx':
|
||||||
env.Append(CPPPATH=['.', godot_headers, 'include', 'include/core'])
|
env.Append(CPPPATH=['.', godot_headers, 'include', 'include/core'])
|
||||||
|
|
||||||
|
|
||||||
if ARGUMENTS.get('generate_bindings', 'no') == 'yes':
|
# Generate bindings
|
||||||
# TODO Generating the API should be done only if the Godot build is more recent than the JSON file
|
|
||||||
json_api_file = os.path.join(os.getcwd(), 'godot_api.json')
|
json_api_file = os.path.join(os.getcwd(), 'godot_api.json')
|
||||||
|
if os.path.exists(json_api_file) == False or ARGUMENTS.get('regenerate_bindings', 'no') == 'yes':
|
||||||
subprocess.call([os.path.expanduser(godot_bin_path), '--gdnative-generate-json-api', json_api_file])
|
subprocess.call([os.path.expanduser(godot_bin_path), '--gdnative-generate-json-api', json_api_file])
|
||||||
|
|
||||||
# actually create the bindings here
|
# actually create the bindings here
|
||||||
|
|
Loading…
Reference in New Issue