mirror of https://github.com/ArduPilot/ardupilot
AP_Scripting: auto-build the bindings
This commit is contained in:
parent
5c8e4a4d7b
commit
2c6fd13899
|
@ -0,0 +1,3 @@
|
|||
lua_generated_bindings.cpp
|
||||
lua_generated_bindings.h
|
||||
|
|
@ -68,8 +68,8 @@ FILE *description;
|
|||
FILE *header;
|
||||
FILE *source;
|
||||
|
||||
static struct generator_state state = {};
|
||||
static struct header * headers = NULL;
|
||||
static struct generator_state state;
|
||||
static struct header * headers;
|
||||
|
||||
enum trace_level {
|
||||
TRACE_TOKENS = (1 << 0),
|
||||
|
@ -321,8 +321,8 @@ struct userdata {
|
|||
int flags; // flags from the userdata_flags enum
|
||||
};
|
||||
|
||||
static struct userdata *parsed_userdata = NULL;
|
||||
static struct userdata *parsed_ap_objects = NULL;
|
||||
static struct userdata *parsed_userdata;
|
||||
static struct userdata *parsed_ap_objects;
|
||||
|
||||
|
||||
struct dependency {
|
||||
|
@ -332,7 +332,7 @@ struct dependency {
|
|||
char *error_msg; // message if the check fails
|
||||
};
|
||||
|
||||
static struct dependency *parsed_dependencies = NULL;
|
||||
static struct dependency *parsed_dependencies;
|
||||
|
||||
// lazy helper that allocates a storage buffer and does strcpy for us
|
||||
void string_copy(char **dest, const char * src) {
|
||||
|
@ -1928,7 +1928,7 @@ int main(int argc, char **argv) {
|
|||
sanity_check_userdata();
|
||||
|
||||
fprintf(source, "#include \"lua_generated_bindings.h\"\n");
|
||||
fprintf(source, "#include \"lua_boxed_numerics.h\"\n");
|
||||
fprintf(source, "#include <AP_Scripting/lua_boxed_numerics.h>\n");
|
||||
|
||||
trace(TRACE_GENERAL, "Starting emission");
|
||||
|
||||
|
@ -1980,7 +1980,7 @@ int main(int argc, char **argv) {
|
|||
fprintf(header, "#pragma once\n");
|
||||
fprintf(header, "// auto generated bindings, don't manually edit. See README.md for details.\n");
|
||||
emit_headers(header);
|
||||
fprintf(header, "#include \"lua/src/lua.hpp\"\n");
|
||||
fprintf(header, "#include <AP_Scripting/lua/src/lua.hpp>\n");
|
||||
fprintf(header, "#include <new>\n\n");
|
||||
emit_dependencies(header);
|
||||
fprintf(header, "\n\n");
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "lua_bindings.h"
|
||||
|
||||
#include "lua_boxed_numerics.h"
|
||||
#include "lua_generated_bindings.h"
|
||||
#include <AP_Scripting/lua_generated_bindings.h>
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
|
||||
#include "lua_scripts.h"
|
||||
#include "lua_generated_bindings.h"
|
||||
#include <AP_Scripting/lua_generated_bindings.h>
|
||||
|
||||
#include "lua/src/lua.h"
|
||||
#include "lua/src/lauxlib.h"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <GCS_MAVLink/GCS.h>
|
||||
#include "AP_Scripting.h"
|
||||
|
||||
#include "lua_generated_bindings.h"
|
||||
#include <AP_Scripting/lua_generated_bindings.h>
|
||||
|
||||
#ifndef SCRIPTING_DIRECTORY
|
||||
#if HAL_OS_FATFS_IO
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
'''
|
||||
build generated bindings from bindings.desc for AP_Scripting
|
||||
'''
|
||||
|
||||
from waflib.TaskGen import after_method, before_method, feature
|
||||
|
||||
CFLAGS="-std=c99 -Wno-error=missing-field-initializers -Wall -Werror -Wextra"
|
||||
CC="gcc"
|
||||
|
||||
def configure(cfg):
|
||||
cfg.env.AP_LIB_EXTRA_SOURCES['AP_Scripting'] = ['lua_generated_bindings.cpp']
|
||||
|
||||
def build(bld):
|
||||
main_c = bld.srcnode.make_node('libraries/AP_Scripting/generator/src/main.c')
|
||||
gen_bindings = bld.bldnode.find_or_declare('gen-bindings')
|
||||
|
||||
bld(
|
||||
# build gen-bindings compiler
|
||||
source=main_c,
|
||||
target=[gen_bindings],
|
||||
# we should have configure tests for finding the native compiler
|
||||
rule="%s %s -o %s %s" % (CC, CFLAGS, gen_bindings.abspath(), main_c.abspath()),
|
||||
group='dynamic_sources',
|
||||
)
|
||||
|
||||
bindings = bld.srcnode.make_node('libraries/AP_Scripting/generator/description/bindings.desc')
|
||||
gen_bindings = bld.bldnode.find_or_declare('gen-bindings')
|
||||
generated_cpp = bld.bldnode.find_or_declare('libraries/AP_Scripting/lua_generated_bindings.cpp')
|
||||
generated_h = bld.bldnode.find_or_declare('libraries/AP_Scripting/lua_generated_bindings.h')
|
||||
|
||||
bld(
|
||||
# build the bindings
|
||||
source=[bindings, gen_bindings],
|
||||
rule="./gen-bindings -o libraries/AP_Scripting/lua_generated_bindings -i %s" % (bindings.abspath()),
|
||||
target=[generated_cpp, generated_h],
|
||||
group='dynamic_sources',
|
||||
)
|
Loading…
Reference in New Issue