From 5b2defbd2a1aa991bd0a2855eef8e15107572747 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 1 Oct 2021 19:46:00 -0400 Subject: Vendor import of libcbor 0.8.0 --- misc/bytes.rb | 3 +++ misc/file_to_bytes.rb | 5 +++++ misc/hooks/pre-commit | 18 ++++++++++++++++++ misc/repeat.rb | 3 +++ misc/seq.rb | 3 +++ misc/update_version.py | 38 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 70 insertions(+) create mode 100755 misc/bytes.rb create mode 100755 misc/file_to_bytes.rb create mode 100755 misc/hooks/pre-commit create mode 100755 misc/repeat.rb create mode 100755 misc/seq.rb create mode 100755 misc/update_version.py (limited to 'misc') diff --git a/misc/bytes.rb b/misc/bytes.rb new file mode 100755 index 000000000000..ed453a4fcd81 --- /dev/null +++ b/misc/bytes.rb @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby + +puts $*[0][2..-1].split('').each_slice(2).map {|_| '0x%02X' % _.join.to_i(16) }.join(', ') diff --git a/misc/file_to_bytes.rb b/misc/file_to_bytes.rb new file mode 100755 index 000000000000..047c91054f5e --- /dev/null +++ b/misc/file_to_bytes.rb @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby + +lst = (ARGV.empty? ? STDIN.read : IO.binread(ARGV[0])).bytes.map {|_| '0x%02X' % _ } +puts lst.size +puts lst.join(', ') diff --git a/misc/hooks/pre-commit b/misc/hooks/pre-commit new file mode 100755 index 000000000000..f3ac9f483799 --- /dev/null +++ b/misc/hooks/pre-commit @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +# Run clang-format and add modified files +MODIFIED_UNSTAGED=$(git -C . diff --name-only) +MODIFIED_STAGED=$(git -C . diff --name-only --cached --diff-filter=d) + +./clang-format.sh + +git add ${MODIFIED_STAGED} + +if [[ ${MODIFIED_UNSTAGED} != $(git -C . diff --name-only) ]]; then + echo "WARNING: Non-staged files were reformatted. Please review and/or add" \ + "them" +fi + + diff --git a/misc/repeat.rb b/misc/repeat.rb new file mode 100755 index 000000000000..fa3da5dbdffb --- /dev/null +++ b/misc/repeat.rb @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby + +(Integer($*[0])..Integer($*[1])).each {|i| puts "case 0x%02X:" % i} diff --git a/misc/seq.rb b/misc/seq.rb new file mode 100755 index 000000000000..0902eb0d96f5 --- /dev/null +++ b/misc/seq.rb @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby + +Integer($*[0]).times {|i| print "0x%02X, " % ((Integer($*[1]) + i) % 0xFF) } diff --git a/misc/update_version.py b/misc/update_version.py new file mode 100755 index 000000000000..eb330215d375 --- /dev/null +++ b/misc/update_version.py @@ -0,0 +1,38 @@ +import sys, re +from datetime import date + +version = sys.argv[1] +release_date = date.today().strftime('%Y-%m-%d') +major, minor, patch = version.split('.') + + +def replace(file_path, pattern, replacement): + updated = re.sub(pattern, replacement, open(file_path).read()) + with open(file_path, 'w') as f: + f.write(updated) + +# Update changelog +SEP = '---------------------' +NEXT = f'Next\n{SEP}' +changelog_header = f'{NEXT}\n\n{version} ({release_date})\n{SEP}' +replace('CHANGELOG.md', NEXT, changelog_header) + +# Update Doxyfile +DOXY_VERSION = 'PROJECT_NUMBER = ' +replace('Doxyfile', DOXY_VERSION + '.*', DOXY_VERSION + version) + +# Update CMakeLists.txt +replace('CMakeLists.txt', + '''SET\\(CBOR_VERSION_MAJOR "0"\\) +SET\\(CBOR_VERSION_MINOR "7"\\) +SET\\(CBOR_VERSION_PATCH "0"\\)''', + f'''SET(CBOR_VERSION_MAJOR "{major}") +SET(CBOR_VERSION_MINOR "{minor}") +SET(CBOR_VERSION_PATCH "{patch}")''') + +# Update Sphinx +replace('doc/source/conf.py', + """version = '.*' +release = '.*'""", + f"""version = '{major}.{minor}' +release = '{major}.{minor}.{patch}'""") -- cgit v1.3