Import of the watch repository from Pebble

This commit is contained in:
Matthieu Jeanson 2024-12-12 16:43:03 -08:00 committed by Katharine Berry
commit 3b92768480
10334 changed files with 2564465 additions and 0 deletions

View file

@ -0,0 +1,11 @@
set(PACKAGE_VERSION "@nanopb_VERSION@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

View file

@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/nanopb-targets.cmake)

40
third_party/nanopb/extra/nanopb.mk vendored Normal file
View file

@ -0,0 +1,40 @@
# This is an include file for Makefiles. It provides rules for building
# .pb.c and .pb.h files out of .proto, as well the path to nanopb core.
# Path to the nanopb root directory
NANOPB_DIR := $(patsubst %/,%,$(dir $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))))
# Files for the nanopb core
NANOPB_CORE = $(NANOPB_DIR)/pb_encode.c $(NANOPB_DIR)/pb_decode.c $(NANOPB_DIR)/pb_common.c
# Check if we are running on Windows
ifdef windir
WINDOWS = 1
endif
ifdef WINDIR
WINDOWS = 1
endif
# Check whether to use binary version of nanopb_generator or the
# system-supplied python interpreter.
ifneq "$(wildcard $(NANOPB_DIR)/generator-bin)" ""
# Binary package
PROTOC = $(NANOPB_DIR)/generator-bin/protoc
PROTOC_OPTS =
else
# Source only or git checkout
PROTOC_OPTS =
ifdef WINDOWS
PROTOC = python $(NANOPB_DIR)/generator/protoc
else
PROTOC = $(NANOPB_DIR)/generator/protoc
endif
endif
# Rule for building .pb.c and .pb.h
%.pb.c %.pb.h: %.proto %.options
$(PROTOC) $(PROTOC_OPTS) --nanopb_out=. $<
%.pb.c %.pb.h: %.proto
$(PROTOC) $(PROTOC_OPTS) --nanopb_out=. $<

120
third_party/nanopb/extra/pb_syshdr.h vendored Normal file
View file

@ -0,0 +1,120 @@
/* This is an example of a header file for platforms/compilers that do
* not come with stdint.h/stddef.h/stdbool.h/string.h. To use it, define
* PB_SYSTEM_HEADER as "pb_syshdr.h", including the quotes, and add the
* extra folder to your include path.
*
* It is very likely that you will need to customize this file to suit
* your platform. For any compiler that supports C99, this file should
* not be necessary.
*/
#ifndef _PB_SYSHDR_H_
#define _PB_SYSHDR_H_
/* stdint.h subset */
#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
/* You will need to modify these to match the word size of your platform. */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
/* These are ok for most platforms, unless uint8_t is actually not available,
* in which case you should give the smallest available type. */
typedef int8_t int_least8_t;
typedef uint8_t uint_least8_t;
typedef uint8_t uint_fast8_t;
typedef int16_t int_least16_t;
typedef uint16_t uint_least16_t;
#endif
/* stddef.h subset */
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#else
typedef uint32_t size_t;
#define offsetof(st, m) ((size_t)(&((st *)0)->m))
#ifndef NULL
#define NULL 0
#endif
#endif
/* stdbool.h subset */
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#else
#ifndef __cplusplus
typedef int bool;
#define false 0
#define true 1
#endif
#endif
/* stdlib.h subset */
#ifdef PB_ENABLE_MALLOC
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#else
void *realloc(void *ptr, size_t size);
void free(void *ptr);
#endif
#endif
/* string.h subset */
#ifdef HAVE_STRING_H
#include <string.h>
#else
/* Implementations are from the Public Domain C Library (PDCLib). */
static size_t strlen( const char * s )
{
size_t rc = 0;
while ( s[rc] )
{
++rc;
}
return rc;
}
static void * memcpy( void *s1, const void *s2, size_t n )
{
char * dest = (char *) s1;
const char * src = (const char *) s2;
while ( n-- )
{
*dest++ = *src++;
}
return s1;
}
static void * memset( void * s, int c, size_t n )
{
unsigned char * p = (unsigned char *) s;
while ( n-- )
{
*p++ = (unsigned char) c;
}
return s;
}
#endif
/* limits.h subset */
#ifdef HAVE_LIMITS_H
#include <limits.h>
#else
#define CHAR_BIT 8
#endif
#endif

View file

@ -0,0 +1,20 @@
#!/bin/bash
set -ex
rm -rf build
mkdir build
mkdir -p dist
(cd "$(git rev-parse --show-toplevel)"; git archive HEAD) > build/tmp.tar
cd build
ln -s ../dist .
mkdir nanopb
tar xf tmp.tar README.md generator
mv generator nanopb/
touch nanopb/__init__.py nanopb/generator/__init__.py
make -C nanopb/generator/proto
cp ../pyproject.toml .
sed -i -e 's/\(version =.*\)-dev.*/\1-dev'$(git rev-list HEAD --count)'"/' pyproject.toml
poetry build

View file

@ -0,0 +1,31 @@
[tool.poetry]
name = "nanopb"
version = "0.4.6"
description = "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."
authors = ["Petteri Aimonen <jpa@npb.mail.kapsi.fi>"]
license = "Zlib"
repository = "https://github.com/nanopb/nanopb/"
readme = "README.md"
homepage = "https://jpa.kapsi.fi/nanopb/"
documentation = "https://jpa.kapsi.fi/nanopb/docs/index.html"
keywords = ["protobuf", "protoc"]
classifiers = ["Topic :: Software Development :: Build Tools"]
include = ["nanopb/**/*", "nanopb/__init__.py"]
[tool.poetry.scripts]
nanopb_generator = "nanopb.generator.nanopb_generator:main_cli"
protoc-gen-nanopb = "nanopb.generator.nanopb_generator:main_plugin"
[tool.poetry.dependencies]
python = ">=2.7"
protobuf = ">=3.19"
grpcio-tools = ">=1.46.0"
[tool.poetry.dev-dependencies]
[tool.poetry.extras]
grpcio-tools = ["grpcio-tools"]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"