Skip to content
Snippets Groups Projects
Commit b0691ad8 authored by Millian Poquet's avatar Millian Poquet
Browse files

protobuf + nix setup

parent c1b5402e
Branches
No related tags found
No related merge requests found
result
.vscode
{ pkgs ? import (fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/22.05.tar.gz";
sha256 = "0d643wp3l77hv2pmg2fi7vyxn4rwy0iyr8djcw1h5x72315ck9ik";
}) {}
}:
let self = rec {
pythonPackages = pkgs.python3Packages;
simgrid = pkgs.simgrid;
protocol-cpp = pkgs.stdenv.mkDerivation {
pname = "protocol-cpp";
version = "local";
src = pkgs.lib.sourceByRegex ./protocol [
"hello\.proto"
"meson\.build"
];
propagatedBuildInputs = with pkgs; [
protobuf
];
buildInputs = with pkgs; [
meson
pkg-config
ninja
];
};
};
in
self
syntax = "proto2";
package hello;
message Hello {
optional string name = 1;
}
message Bye {
}
project('protocol-cpp', 'cpp', version: '0.1.0', default_options: ['cpp_std=c++17'])
protoc = find_program('protoc', required: true)
protobuf_dep = dependency('protobuf', required: true)
gen = generator(protoc, \
output : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
arguments : ['--proto_path=@CURRENT_SOURCE_DIR@', '--cpp_out=@BUILD_DIR@', '@INPUT@'])
proto_generated_cpp = custom_target('protobuf-generated-sources',
input: ['hello.proto'],
output: ['hello.pb.h', 'hello.pb.cc'],
command: [protoc, '--proto_path=@CURRENT_SOURCE_DIR@', '--cpp_out=@OUTDIR@', '@INPUT@'],
install: true,
install_dir: [get_option('includedir'), false],
)
lib = shared_library('protocol', proto_generated_cpp, dependencies: protobuf_dep, install: true)
pkg = import('pkgconfig')
pkg.generate(lib)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment