nixpkgs/pkgs/by-name/na/nanopb/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

135 lines
3.7 KiB
Nix
Raw Normal View History

nanopb: 0.4.6 -> 0.4.8 This commit: - Bumps the nanopb version - Adds all runtime configuration options - Implements proper cross-compilation support which is the main use-case of the library. - Uses newer `finalAttrs` form of `mkDerivation` to allow for easier attribute overrides. The cross-compilation support is achieved by splitting the package into two sub-packages consisting of the build-time generator and the runtime library. Nanopb explicitely supports this by providing specialized `GENERATOR` and `RUNTIME` CMake configuration options. The top-level package uses `propagatedNativeBuildInputs` and `propagatedBuildInputs` to propagate the sub-packages and also adds convenient symlinks to make certain use cases easier. == GENERATOR == The generator is a mostly ready-to-be-packaged python module tree. We patch the library to also include the missing `__init__.py` and we also fix the `PYTHON_INSTDIR` variable to follow best practice and to prevent the library from attempting to install to a global directory. We package the python module using `buildPythonPackage` and internally override python in order to wrap the `nanopb_generator.py` executable. We do *not* wrap `nanob_generator.py` due to it also being imported directly from python when used through `protoc-gen-nanopb`. == RUNTIME == The runtime is a simple library that consists of the common functionality among generated headers/sources. It is configured through `preprocessor definitions` and consumer projects *must* be compiled with the same definitions. This is currently achieved by exposing all configuration options through the top-level overrides and patching the CMakeLists.txt so that the definitions are added to the to-be-installed CMake targets as PUBLIC properties.
2024-02-13 00:25:13 +00:00
{
stdenvNoCC,
callPackage,
fetchFromGitHub,
buildPackages,
lib,
enableMalloc ? false,
noPackedStructs ? false,
maxRequiredFields ? null,
field32bit ? false,
noErrmsg ? false,
bufferOnly ? false,
systemHeader ? null,
without64bit ? false,
encodeArraysUnpacked ? false,
convertDoubleFloat ? false,
validateUtf8 ? false,
littleEndian8bit ? false,
c99StaticAssert ? false,
noStaticAssert ? false,
}:
stdenvNoCC.mkDerivation (
self:
let
generator-out = buildPackages.callPackage ./generator-out.nix { inherit (self) src version; };
python-module = buildPackages.callPackage ./python-module.nix {
inherit (self) version;
inherit (self.passthru) generator-out;
};
python3 = buildPackages.python3.override {
self = python3;
nanopb: 0.4.6 -> 0.4.8 This commit: - Bumps the nanopb version - Adds all runtime configuration options - Implements proper cross-compilation support which is the main use-case of the library. - Uses newer `finalAttrs` form of `mkDerivation` to allow for easier attribute overrides. The cross-compilation support is achieved by splitting the package into two sub-packages consisting of the build-time generator and the runtime library. Nanopb explicitely supports this by providing specialized `GENERATOR` and `RUNTIME` CMake configuration options. The top-level package uses `propagatedNativeBuildInputs` and `propagatedBuildInputs` to propagate the sub-packages and also adds convenient symlinks to make certain use cases easier. == GENERATOR == The generator is a mostly ready-to-be-packaged python module tree. We patch the library to also include the missing `__init__.py` and we also fix the `PYTHON_INSTDIR` variable to follow best practice and to prevent the library from attempting to install to a global directory. We package the python module using `buildPythonPackage` and internally override python in order to wrap the `nanopb_generator.py` executable. We do *not* wrap `nanob_generator.py` due to it also being imported directly from python when used through `protoc-gen-nanopb`. == RUNTIME == The runtime is a simple library that consists of the common functionality among generated headers/sources. It is configured through `preprocessor definitions` and consumer projects *must* be compiled with the same definitions. This is currently achieved by exposing all configuration options through the top-level overrides and patching the CMakeLists.txt so that the definitions are added to the to-be-installed CMake targets as PUBLIC properties.
2024-02-13 00:25:13 +00:00
packageOverrides = _: _: {
nanopb-proto = self.passthru.python-module;
};
};
nanopb: 0.4.6 -> 0.4.8 This commit: - Bumps the nanopb version - Adds all runtime configuration options - Implements proper cross-compilation support which is the main use-case of the library. - Uses newer `finalAttrs` form of `mkDerivation` to allow for easier attribute overrides. The cross-compilation support is achieved by splitting the package into two sub-packages consisting of the build-time generator and the runtime library. Nanopb explicitely supports this by providing specialized `GENERATOR` and `RUNTIME` CMake configuration options. The top-level package uses `propagatedNativeBuildInputs` and `propagatedBuildInputs` to propagate the sub-packages and also adds convenient symlinks to make certain use cases easier. == GENERATOR == The generator is a mostly ready-to-be-packaged python module tree. We patch the library to also include the missing `__init__.py` and we also fix the `PYTHON_INSTDIR` variable to follow best practice and to prevent the library from attempting to install to a global directory. We package the python module using `buildPythonPackage` and internally override python in order to wrap the `nanopb_generator.py` executable. We do *not* wrap `nanob_generator.py` due to it also being imported directly from python when used through `protoc-gen-nanopb`. == RUNTIME == The runtime is a simple library that consists of the common functionality among generated headers/sources. It is configured through `preprocessor definitions` and consumer projects *must* be compiled with the same definitions. This is currently achieved by exposing all configuration options through the top-level overrides and patching the CMakeLists.txt so that the definitions are added to the to-be-installed CMake targets as PUBLIC properties.
2024-02-13 00:25:13 +00:00
generator = buildPackages.callPackage ./generator.nix {
inherit python3;
inherit (self) version;
inherit (self.passthru) generator-out;
};
runtime = callPackage ./runtime.nix {
inherit python3;
inherit (self) src version;
inherit
enableMalloc
noPackedStructs
maxRequiredFields
field32bit
noErrmsg
bufferOnly
systemHeader
without64bit
encodeArraysUnpacked
convertDoubleFloat
validateUtf8
littleEndian8bit
c99StaticAssert
noStaticAssert
;
};
in
{
pname = "nanopb";
2024-12-05 10:03:54 +00:00
version = "0.4.9.1";
nanopb: 0.4.6 -> 0.4.8 This commit: - Bumps the nanopb version - Adds all runtime configuration options - Implements proper cross-compilation support which is the main use-case of the library. - Uses newer `finalAttrs` form of `mkDerivation` to allow for easier attribute overrides. The cross-compilation support is achieved by splitting the package into two sub-packages consisting of the build-time generator and the runtime library. Nanopb explicitely supports this by providing specialized `GENERATOR` and `RUNTIME` CMake configuration options. The top-level package uses `propagatedNativeBuildInputs` and `propagatedBuildInputs` to propagate the sub-packages and also adds convenient symlinks to make certain use cases easier. == GENERATOR == The generator is a mostly ready-to-be-packaged python module tree. We patch the library to also include the missing `__init__.py` and we also fix the `PYTHON_INSTDIR` variable to follow best practice and to prevent the library from attempting to install to a global directory. We package the python module using `buildPythonPackage` and internally override python in order to wrap the `nanopb_generator.py` executable. We do *not* wrap `nanob_generator.py` due to it also being imported directly from python when used through `protoc-gen-nanopb`. == RUNTIME == The runtime is a simple library that consists of the common functionality among generated headers/sources. It is configured through `preprocessor definitions` and consumer projects *must* be compiled with the same definitions. This is currently achieved by exposing all configuration options through the top-level overrides and patching the CMakeLists.txt so that the definitions are added to the to-be-installed CMake targets as PUBLIC properties.
2024-02-13 00:25:13 +00:00
src = fetchFromGitHub {
owner = "nanopb";
repo = "nanopb";
rev = self.version;
2024-12-05 10:03:54 +00:00
hash = "sha256-bMSZZaF8egAegi3enCM+DRyxOrPoWKAKybvWsrKZEDc=";
nanopb: 0.4.6 -> 0.4.8 This commit: - Bumps the nanopb version - Adds all runtime configuration options - Implements proper cross-compilation support which is the main use-case of the library. - Uses newer `finalAttrs` form of `mkDerivation` to allow for easier attribute overrides. The cross-compilation support is achieved by splitting the package into two sub-packages consisting of the build-time generator and the runtime library. Nanopb explicitely supports this by providing specialized `GENERATOR` and `RUNTIME` CMake configuration options. The top-level package uses `propagatedNativeBuildInputs` and `propagatedBuildInputs` to propagate the sub-packages and also adds convenient symlinks to make certain use cases easier. == GENERATOR == The generator is a mostly ready-to-be-packaged python module tree. We patch the library to also include the missing `__init__.py` and we also fix the `PYTHON_INSTDIR` variable to follow best practice and to prevent the library from attempting to install to a global directory. We package the python module using `buildPythonPackage` and internally override python in order to wrap the `nanopb_generator.py` executable. We do *not* wrap `nanob_generator.py` due to it also being imported directly from python when used through `protoc-gen-nanopb`. == RUNTIME == The runtime is a simple library that consists of the common functionality among generated headers/sources. It is configured through `preprocessor definitions` and consumer projects *must* be compiled with the same definitions. This is currently achieved by exposing all configuration options through the top-level overrides and patching the CMakeLists.txt so that the definitions are added to the to-be-installed CMake targets as PUBLIC properties.
2024-02-13 00:25:13 +00:00
};
dontPatch = true;
dontUnpack = true;
propagatedNativeBuildInputs = [ generator ];
propagatedBuildInputs = [ runtime ];
postInstall = ''
mkdir $out
ln -s ${generator}/bin $out/bin
ln -s ${runtime}/include $out/include
ln -s ${runtime}/lib $out/lib
mkdir -p $out/share/nanopb/generator/proto
ln -s ${self.src}/generator/proto/nanopb.proto $out/share/nanopb/generator/proto/nanopb.proto
'';
passthru = {
inherit
runtime
generator-out
python-module
generator
;
tests = {
simple-proto2 = callPackage ./test-simple-proto2 { };
simple-proto3 = callPackage ./test-simple-proto3 { };
message-with-annotations = callPackage ./test-message-with-annotations { };
message-with-options = callPackage ./test-message-with-options { };
};
nanopb: 0.4.6 -> 0.4.8 This commit: - Bumps the nanopb version - Adds all runtime configuration options - Implements proper cross-compilation support which is the main use-case of the library. - Uses newer `finalAttrs` form of `mkDerivation` to allow for easier attribute overrides. The cross-compilation support is achieved by splitting the package into two sub-packages consisting of the build-time generator and the runtime library. Nanopb explicitely supports this by providing specialized `GENERATOR` and `RUNTIME` CMake configuration options. The top-level package uses `propagatedNativeBuildInputs` and `propagatedBuildInputs` to propagate the sub-packages and also adds convenient symlinks to make certain use cases easier. == GENERATOR == The generator is a mostly ready-to-be-packaged python module tree. We patch the library to also include the missing `__init__.py` and we also fix the `PYTHON_INSTDIR` variable to follow best practice and to prevent the library from attempting to install to a global directory. We package the python module using `buildPythonPackage` and internally override python in order to wrap the `nanopb_generator.py` executable. We do *not* wrap `nanob_generator.py` due to it also being imported directly from python when used through `protoc-gen-nanopb`. == RUNTIME == The runtime is a simple library that consists of the common functionality among generated headers/sources. It is configured through `preprocessor definitions` and consumer projects *must* be compiled with the same definitions. This is currently achieved by exposing all configuration options through the top-level overrides and patching the CMakeLists.txt so that the definitions are added to the to-be-installed CMake targets as PUBLIC properties.
2024-02-13 00:25:13 +00:00
};
meta = with lib; {
platforms = platforms.all;
description = "Protocol Buffers with small code size";
homepage = "https://jpa.kapsi.fi/nanopb/";
license = licenses.zlib;
maintainers = with maintainers; [
kalbasit
liarokapisv
];
longDescription = ''
Nanopb is a small code-size Protocol Buffers implementation in ansi C. It
is especially suitable for use in microcontrollers, but fits any memory
restricted system.
- Homepage: jpa.kapsi.fi/nanopb
- Documentation: jpa.kapsi.fi/nanopb/docs
- Downloads: jpa.kapsi.fi/nanopb/download
- Forum: groups.google.com/forum/#!forum/nanopb
In order to use the nanopb options in your proto files, you'll need to
tell protoc where to find the nanopb.proto file.
You can do so with the --proto_path (-I) option to add the directory
''${nanopb}/share/nanopb/generator/proto like so:
protoc --proto_path=. --proto_path=''${nanopb}/share/nanopb/generator/proto --plugin=protoc-gen-nanopb=''${nanopb}/bin/protoc-gen-nanopb --nanopb_out=out file.proto
'';
};
}
)