Commit Graph
54 Commits
Author SHA1 Message Date
Thiago Macieira c52d731e5e cbor.h: let tinycbor-export.h define CBOR_API
And make CBOR_PRIVATE_API fall back to it.

We also need to provide the file for the old Makefile build too.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-12 16:49:17 -07:00
Thiago Macieira db9f29d499 CI/Makefile: do allow Qt 6
I don't think we need to worry about Qt 4 any more.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-01 18:29:45 -07:00
Thiago Macieira 0d5538277d Makefile: Fix build with Clang
It doesn't know -Wdiscarded-qualifiers. Reported by @pjonsson on #247.

I really need to switch to CMake - #242

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2023-11-26 17:27:09 -07:00
Thiago Macieira 02a7efcf6f Makefile: add -Werror=discarded-qualifiers to the C flags
Because C allows this:

  void f(int *x);
  void g(const int *x)
  { f(x); }

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 08:07:09 -08:00
Fabrice Fontaine 5f26eaf8d7 Makefile: add DISABLE_WERROR
Allow the user to disable -Werror to avoid the following build failure
with gcc 4.8 raised since version 0.6.0 and
https://github.com/intel/tinycbor/commit/e2a4ed135c4d9101c4df83f2dd033cd249b6ef07:

/home/buildroot/autobuild/instance-1/output-1/host/bin/arm-none-linux-gnueabi-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I./src -std=gnu99 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os -g0 -D_FORTIFY_SOURCE=1 -Werror=incompatible-pointer-types -Werror=implicit-function-declaration -Werror=int-conversion -fPIC  -c -o src/cborerrorstrings.pic.o src/cborerrorstrings.c
cc1: error: -Werror=incompatible-pointer-types: no option -Wincompatible-pointer-types
cc1: error: -Werror=int-conversion: no option -Wint-conversion

Fixes:
 - http://autobuild.buildroot.org/results/a9f/a9fe64c42bb96f9e7b4af3050464f6570c1c00fa

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2022-01-12 08:13:56 -08:00
Alfie Fresta 6176e0a28d Makefile: Use file name instead of file descriptor for .config target 2021-10-04 11:59:18 -07:00
Thiago Macieira e2a4ed135c Build system: Add a few -Werror for sane C development 2021-09-03 12:54:10 -07:00
Thiago Macieira 7dce551629 Merge branch 'master' into dev 2021-01-13 09:05:42 -08:00
Dan Church fc42a04985 Fix links to shared library upon "make install" 2020-10-24 01:13:13 -03:00
Thiago Macieira 6643c174e4 Merge branch 'master' into dev 2019-03-15 10:12:23 -07:00
phirsov f1db0abccd enhancement #149 implemented: access half-precision floating point data as single float
Motivation: half-precision floating point format is used to minimize storage
and traffic mostly.  Application level manipulates with single and double
precision usually. So, two routines added to public API to encode/decode given
single precision value in the half precision format

Signed-off-by: S.Phirsov
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2019-03-15 10:11:00 -07:00
phirsov e9c6ebe9d6 eliminating misleading messages in case .config file not yet created
Signed-off-by: phirsov <41143811+phirsov@users.noreply.github.com>
2018-12-04 15:15:32 -08:00
Thiago Macieira d94ca09aa9 Install the tinycbor-version.h header.
Fixes #136.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-09-08 22:33:57 -07:00
Thiago Macieira 88943666c4 Properly link the shared libtinycbor.so to -lm
The hosted version makes use of math functions (usually, we don't test
that CBOR_NO_FLOATING_POINT is defined).

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-08-13 21:03:31 -07:00
Thiago Macieira 4d15639645 Don't compile bin/cbordump in freestanding builds
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-08-13 21:03:31 -07:00
Konstantin Yegupov 8606611e53 Update gcc flags to build json2cbor with gcc 4.4.7 (used in CentOS 6)
Signed-off-by: Konstantin Yegupov <kyegupov4@gmail.com>
2018-03-31 09:39:10 -07:00
Thiago Macieira 3cdb9c890b Add a script to make docs in Travis
This also stores the current library sizes (in -Os / -Oz build modes)
for each branch,

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-30 14:21:35 -08:00
Thiago Macieira 301e263afb Update the ELF soname not to say "libtinycbor.so.0"
Since we're not (yet) guaranteeing binary compatibility, let's use 0.5
as the "soversion".

This changes the version number stored in the VERSION file so that the
actual library file is "libtinycbor.so.0.5.0". As an indirect
consequence, the release will be tagged "v0.5.0", which sorts after
"v0.5-beta1".

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-30 14:01:23 -08:00
Thiago Macieira f2b75b8721 Make it easier to build only the freestanding code
Freestanding C, as opposed to hosted C (see the macro), is restricted to
a few C headers and usually lacks a libc. In our case, that means we
cannot assume <stdio.h> and FILE* is present, but we do require
<string.h> (memcpy, memcmp).

This commit simply makes it easier for me to test that TinyCBOR still
compiles in freestanding mode. Eventually I need to test with an actual
Zephyr build (issue #40).

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-30 13:43:49 -08:00
Thiago Macieira f39dcb8b56 Pretty: move the two functions taking FILE* to a separate file
This now allows the cborpretty.c source to be compiled even in C
freestanding environments.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-02 17:05:44 -06:00
Thiago Macieira ed68cdae5f Merge remote-tracking branch 'origin/dev' into HEAD 2017-12-17 23:48:22 -08:00
Thiago Macieira 78905c85da Add the -f flag to ln, to force symlink creation
Otherwise, remaking ends with:

 ln: failed to create symbolic link 'libtinycbor.so': File exists
 ln: failed to create symbolic link 'libtinycbor.so.0': File exists

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-12-17 23:46:54 -08:00
Fabrice Fontaine 19b26bd416 Add BUILD_STATIC option
- Enable BUILD_STATIC by default
 - If BUILD_STATIC and BUILD_SHARED are both different from 1, return an
error
 - If BUILD_STATIC is disabled, use shared library for binaries
 - If both are enabled, use the static library

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2017-12-07 13:20:48 -08:00
Thiago Macieira df440a0891 Make sure that -fPIC objects are removed in make clean
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-11-13 22:28:07 -08:00
Thiago Macieira aa692b7863 Fix build on non-ELF systems (macOS): don't build the shared library
Detect if this is an ELF system by checking if /bin/sh is ELF. This can
be configured manually with:
   make BUILD_SHARED=0
or
   make BUILD_SHARED=1

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-11-13 20:54:30 -08:00
Thiago Macieira 15dfacff6c Fix the build outside of Linux: disable shared libraries
Technically, they should be allowed on the BSDs, but it's far easier to
whitelist than blacklist.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-10-07 16:17:01 -04:00
Bertrand Roussel 47914e0fa1 Provide shared library
Some people may want to use tinycbor as a shared library instead of
as a static library, so providing a set of .so accordingly.

Even with the static library, I'm having trouble incorporating it
into another shared library, so providing -fPIC option as well.

Signed-off-by: Bertrand Roussel <broussel@sierrawireless.com>
2017-10-07 13:16:46 -07:00
Thiago Macieira effaf7d5c3 Merge branch 'master' into dev
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-10-07 15:38:31 -04:00
Thiago Macieira addf8043e4 Add the API to do more in-depth validation
This implements barely the canonical validation. Implemented features:
 - CborValidateShortestFloatingPoint
 - CborValidateNoIndeterminateLength
 - CborValidateNoUndefined
 - CborValidateNoTags
 - CborValidateCompleteData
 - CborValidateNoUnknownSimpleTypesSA
 - CborValidateNoUnknownSimpleTypes

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-05-08 20:59:16 -07:00
Fabrice Fontaine ae608ea273 Fix static compilation of json2cbor
json2cbor depends on cjson so tools/json2cbor/json2cbor.o must be
before -lcjson

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2017-03-06 20:40:35 +01:00
Thiago Macieira 588948d627 Start development of TinyCBOR 0.5
This commit creates the tinycbor-version.h file with the version number
in available to source code.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-03-05 19:35:03 +01:00
Fabrice Fontaine 8ba8e2030e Update cjson include path
Since cjson-v1.0.0 (https://github.com/DaveGamble/cJSON/releases),
cJSON.h is installed into cjson/cJSON.h and library has been renamed
from cJSON to cjson

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2017-01-18 15:47:32 -08:00
Thiago Macieira c2242c5b36 Stop setting TINYCBOR_VERSION in the build
For TinyCBOR 0.5, I'd like to make it numeric. Anyway, nothing was using
this.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-30 12:56:20 -08:00
Thiago Macieira 80d76e79b8 Fix build in shadow builds: need to mkdir bin and lib
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-30 12:53:45 -08:00
Thiago Macieira 2921240965 Create a Perl script that properly creates tags
The previous part of the Makefile didn't work properly. Instead of using
the contents of the VERSION file, it updated the file right before the
tagging and always for the next minor release.

Instead, move everything to a Perl script that updates the VERSION file
only after the tagging and sets up for a patch release (which are more
frequent). Updating of the dev branch is left as an exercise for the
reader.

As a bonus, this will work on Windows too without Unix shell tools.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-11 10:07:18 +08:00
Thiago Macieira a088996aa5 Update "make release" target
This commit allos the use of the VERSION variable to set the version to
be tagged, instead of just incrementing the last digit in the VERSION
file.

It stops creating the .zip and .tar.gz files since those are kept in
GitHub anyway.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-11-02 22:00:07 -07:00
Fabrice Fontaine 04ada5890c Properly manage open_memstream availability
- Update Makefile.configure to test the availability of fopencookie
- If open_memstream is not available on the system AND funopen or fopencookie are available, compile our own version of open_memstream
- If open_memstream can not be compiled, return a new error (CborErrorJsonNotImplemented)

fixes #42

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-08-31 10:39:48 -07:00
Thomas Petazzoni 31c7f81d45 Makefile: use installation logic compatible with old make version
The installation logic used by the Makefile causes a problem with old
make versions, such as make 3.81. Indeed, the rule "$(DESTDIR)%/" gets
matched even for targets like "$(DESTDIR)$(libdir)/libtinycbor.a". Due
to this, with those old make versions, tinycbor.a is installed as a
directory, and the library is never copied:

make[1]: Entering directory `/home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/build/tinycbor-v0.3.1'
install -d /home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/target/usr/bin/cbordump
install -d /home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/target/usr/lib/libtinycbor.a
install -d /home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/target/usr/lib/pkgconfig/tinycbor.pc
install -d /home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/target/usr/include/tinycbor/cbor.h
install -d /home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/target/usr/include/tinycbor/cborjson.h
make[1]: Leaving directory `/home/test/outputs/b1305500555cbb5b959e5be11dee5cf75907f0ce/output/build/tinycbor-v0.3.1'

To address this, we create the destination directory directly within
the per-file make targets.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-30 23:07:32 -07:00
Thiago Macieira 1735f9cb7c Fix "make distcheck" when TMPDIR isn't set
Otherwise, we get this:
 GIT_DIR=./.git git archive --prefix=tinycbor-distcheck/ --format=tar HEAD | tar -xf - -C $TMPDIR
 tar: option requires an argument -- 'C'

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-30 23:07:32 -07:00
Fabrice Fontaine c88913e53c Fix compilation error due to file descriptor
In Makefile, the file descriptor 10 is used to redirect input to .config:
$(MAKE) -f $(SRCDIR)Makefile.configure OUT='>&10' configure 10> $@

This patch replaces this file descriptor from to 10 to 9 as
"Redirections using file descriptors greater than 9 should be used with
care, as they may conflict with file descriptors the shell uses
internally."
(cf. https://www.gnu.org/software/bash/manual/html_node/Redirections.html)

Signed-off-by: Fabrice Fontaine <fabrice.fontaine@orange.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-21 08:35:18 -07:00
Thiago Macieira b590a2be69 Merge branch 'master' into HEAD
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-08 10:05:48 -07:00
Otavio Pontes 4ce56694ed Remove from cborparser.c file the dependency on stdlib header
Function _cbor_value_dup_string from cborparser.c is using malloc/free
functions, from sdtlib header, so it is not possible to compile the
cborparser in systems without stdlib support. Move this function to a
different c file in order to remove the dependency on stdlib header from
cborparser.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-08 09:55:15 -07:00
Thiago Macieira 46a818e31f Finish TinyCBOR documentation
This commit adds the Doxyfile and the necessary Makefile commands

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2016-07-07 20:40:13 -07:00
Thiago Macieira 43e3ac9490 Add .travis.yml file 2015-10-17 21:36:43 -07:00
Thiago Macieira db9904fcf9 Update the "make release" target to work
I used it for the v0.2 release.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2015-09-30 11:48:19 -07:00
Thiago Macieira 57bcf4fec4 Add support for IEEE 754 half-precision floating point
The CBOR spec has support for them, but we didn't take them into account
in the CBOR and JSON dumpers nor the JSON parser.

See: https://en.wikipedia.org/wiki/Half-precision_floating-point_format

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2015-09-29 18:50:27 -07:00
Thiago Macieira d4c9ecb91f json2cbor: Add the tool to convert from JSON to CBOR
Conversion works without metadata interpretation yet. That's coming
next.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2015-09-29 18:50:27 -07:00
Thiago Macieira 2a5fb79dae Fix build on OS X
OS X has no open_memstream and its linker has no --gc-sections.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2015-09-29 14:15:48 -07:00
Thiago Macieira 2b1800c399 Add initial CBOR-to-JSON conversion code
Tags are not handled yet.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2015-09-29 14:14:24 -07:00
Thiago Macieira 4e9626cd16 Implement checking of array and map sizes
This fixes issue #4. The code is placed in a new file and function so
that only people who need it will pay the cost of this function. The
impact to existing code is minimal.

Before:
   text    data     bss     dec     hex filename
    945       0       0     945     3b1 cborencoder.o
   2743       0       0    2743     ab7 cborparser.o
After:
   1026       0       0    1026     424 cborencoder.o
   2756       0       0    2756     ac4 cborparser.o

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2015-09-21 16:47:21 -07:00