aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2021-10-01 23:46:00 +0000
committerEd Maste <emaste@FreeBSD.org>2021-10-01 23:46:00 +0000
commit5b2defbd2a1aa991bd0a2855eef8e15107572747 (patch)
tree0e8b33a28f1fb7396bf8b6fcef974fa82de59e9d /misc
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/bytes.rb3
-rwxr-xr-xmisc/file_to_bytes.rb5
-rwxr-xr-xmisc/hooks/pre-commit18
-rwxr-xr-xmisc/repeat.rb3
-rwxr-xr-xmisc/seq.rb3
-rwxr-xr-xmisc/update_version.py38
6 files changed, 70 insertions, 0 deletions
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}'""")