diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..02f17690dd86b24cdb1e7f593f3cec055755a5d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +result +.vscode diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000000000000000000000000000000000..0119eec5c75196ed184df7795db32548422986e1 --- /dev/null +++ b/default.nix @@ -0,0 +1,29 @@ +{ 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 diff --git a/protocol/hello.proto b/protocol/hello.proto new file mode 100644 index 0000000000000000000000000000000000000000..20227667496af4b0cca13a0b0edfa565c904aec4 --- /dev/null +++ b/protocol/hello.proto @@ -0,0 +1,10 @@ +syntax = "proto2"; + +package hello; + +message Hello { + optional string name = 1; +} + +message Bye { +} diff --git a/protocol/meson.build b/protocol/meson.build new file mode 100644 index 0000000000000000000000000000000000000000..747eac16597f8328e34d49da6b502426adb64a8a --- /dev/null +++ b/protocol/meson.build @@ -0,0 +1,21 @@ +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)