More wip - TCP, repeated fps, meson / cmake, subproject wrap
parent
5680fff171
commit
bc523e7191
File diff suppressed because one or more lines are too long
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from subprocess import call
|
||||
from os.path import dirname
|
||||
from os import makedirs
|
||||
|
||||
protoc_path = sys.argv[1]
|
||||
gen_path = sys.argv[2]
|
||||
proto_file = sys.argv[3]
|
||||
options_file = sys.argv[4]
|
||||
build_dir = sys.argv[5]
|
||||
|
||||
source_dir = dirname(proto_file)
|
||||
|
||||
makedirs(build_dir, exist_ok=True)
|
||||
|
||||
cmdline = [protoc_path, '--plugin=protoc-gen-nanopb=' + gen_path,
|
||||
'-I' + source_dir,
|
||||
'--nanopb_out=' + '-f ' + options_file + ':' + build_dir,
|
||||
proto_file]
|
||||
|
||||
sys.stderr.write(" ".join(cmdline) + "\n")
|
||||
exit(call(cmdline))
|
@ -0,0 +1,58 @@
|
||||
cmake = import('cmake')
|
||||
|
||||
nanopb = dependency('nanopb', version : '>=0.4.2', method : 'cmake', modules : ['nanopb::protobuf-nanopb-static'], required : false)
|
||||
must_regenerate_pb = nanopb.found()
|
||||
if not nanopb.found()
|
||||
opt_var = cmake.subproject_options()
|
||||
opt_var.add_cmake_defines({
|
||||
#'-DCMAKE_C_COMPILER=' + ,
|
||||
'nanopb_BUILD_GENERATOR': true,
|
||||
'BUILD_SHARED_LIBS': false,
|
||||
'CMAKE_C_FLAGS': '-DPB_ENABLE_MALLOC',
|
||||
'CMAKE_POSITION_INDEPENDENT_CODE': true,
|
||||
})
|
||||
nanopb_proj = cmake.subproject('nanopb', options: opt_var)
|
||||
nanopb = nanopb_proj.dependency('protobuf-nanopb-static')
|
||||
endif
|
||||
|
||||
rpc_common_sources = files('common.c')
|
||||
|
||||
if must_regenerate_pb
|
||||
protoc = find_program('protoc')
|
||||
protoc_gen_nanopb = find_program('protoc-gen-nanopb')
|
||||
|
||||
gen_pb_py = meson.current_source_dir() + '/gen-pb.py'
|
||||
|
||||
mangohud_pb = custom_target('gen-pb',
|
||||
input : ['mangohud.proto', 'mangohud.options'],
|
||||
output : ['mangohud.pb.c', 'mangohud.pb.h'],
|
||||
command : [gen_pb_py, protoc.path(), protoc_gen_nanopb.path(), '@INPUT0@', '@INPUT1@', meson.current_build_dir()])
|
||||
|
||||
rpc_common_sources += mangohud_pb
|
||||
else
|
||||
rpc_common_sources += 'mangohud.pb.c'
|
||||
endif
|
||||
|
||||
|
||||
#mangohud_pb = nanopb('mangohud.proto')
|
||||
|
||||
rpc_common = static_library(
|
||||
'common',
|
||||
rpc_common_sources,
|
||||
c_args : [
|
||||
pre_args,
|
||||
],
|
||||
cpp_args : [
|
||||
pre_args,
|
||||
],
|
||||
dependencies : [
|
||||
nanopb,
|
||||
],
|
||||
#link_args : ['-lprotobuf-nanopb'],
|
||||
)
|
||||
|
||||
#executable('server', ['server.cpp'], link_with : rpc_common, dependencies : nanopb, install : true)
|
||||
executable('server', ['server.cpp'], link_with : rpc_common, install : true)
|
||||
#executable('server', ['server.cpp'], dependencies : [rpc_common, nanopb], install : true)
|
||||
|
||||
#executable('client-demo', ['client_demo.cpp'], link_with : rpc_common, dependencies : nanopb)
|
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This file is used to invoke nanopb_generator.py as a plugin
|
||||
# to protoc on Linux and other *nix-style systems.
|
||||
# Use it like this:
|
||||
# protoc --plugin=nanopb=..../protoc-gen-nanopb --nanopb_out=dir foo.proto
|
||||
#
|
||||
# Note that if you use the binary package of nanopb, the protoc
|
||||
# path is already set up properly and there is no need to give
|
||||
# --plugin= on the command line.
|
||||
|
||||
NANOPB_PATH="../../subprojects/nanopb/generator"
|
||||
if [ -x "${NANOPB_PATH}/nanopb_generator.py" ]; then
|
||||
exec python3 "${NANOPB_PATH}/nanopb_generator.py" --protoc-plugin
|
||||
else
|
||||
# Try in default PATH.
|
||||
exec "nanopb_generator.py" --protoc-plugin
|
||||
fi
|
@ -0,0 +1,4 @@
|
||||
[wrap-git]
|
||||
directory = nanopb
|
||||
url = https://github.com/nanopb/nanopb
|
||||
revision = 0.4.4
|
Loading…
Reference in New Issue