summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-05-15 19:09:00 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-05-15 19:09:00 -0400
commitcb4fea2e01e6923a016fdc57c48ee9d4045d8428 (patch)
tree004e54ea6ab7edf19d601c5084b8934c25478b08
parentf3d1d66387ea8eb9b0c2977315c771a5704604a6 (diff)
sd_messages: fix
-rw-r--r--sd_messages/Makefile2
-rwxr-xr-xsd_messages/messages.go.gen48
2 files changed, 36 insertions, 14 deletions
diff --git a/sd_messages/Makefile b/sd_messages/Makefile
index 512d27c..4cf4640 100644
--- a/sd_messages/Makefile
+++ b/sd_messages/Makefile
@@ -27,7 +27,7 @@ SD_MESSAGES_H ?= /usr/include/systemd/sd-messages.h
files.src.gen += messages.go
$(srcdir)/messages.go: $(srcdir)/messages.go.gen $(SD_MESSAGES_H)
- cd $(@D) && ./$(<F) $(SD_MESSAGES_H) | gofmt > $(@F)
+ cd $(@D) && ./$(<F) $(SD_MESSAGES_H) > $(@F)
# footer
ifneq ($(topsrcdir),)
diff --git a/sd_messages/messages.go.gen b/sd_messages/messages.go.gen
index 423829b..3314df3 100755
--- a/sd_messages/messages.go.gen
+++ b/sd_messages/messages.go.gen
@@ -1,17 +1,39 @@
-#!/usr/bin/sed -rnf
-1apackage foo
-1aconst (
-/^#define\s+SD_MESSAGE_/ {
+#!/usr/bin/env bash
+# Copyright (C) 2017 Luke Shumaker <lukeshu@sbcglobal.net>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
- s/^#define\s+SD_MESSAGE_(\S*)/\1 =/
+{
+ printf '//'
+ printf ' %q' "$0" "$@"
+ printf '\n// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n'
+ sed -rn '
+ 1apackage sd_messages
+ 1aimport "git.lukeshu.com/go/libsystemd/sd_id128"
+ 1avar (
+ /^#define\s+SD_MESSAGE_/ {
- s/SD_ID128_MAKE\(/ID128{0x/
- s/,/,0x/g
- s/\)/}/
+ s/^#define\s+SD_MESSAGE_(\S*)/\1 =/
- s/(^|_)([A-Z])([A-Z]*)/\U\2\L\3/g
+ s/SD_ID128_MAKE\(/sd_id128.ID128{0x/
+ s/,/,0x/g
+ s/\)/}/
- p
-}
-/^$/p
-$a)
+ s/(^|_)([A-Z])([A-Z]*)/\U\2\L\3/g
+
+ p
+ }
+ /^$/p
+ $a)
+ ' "$@"
+} | gofmt