1481c66dfa89cfb23a6785d109e6f0b7aa21dd9d
[vpp.git] / extras / emacs / plugin.el
1 ;;; Copyright (c) 2016 Cisco and/or its affiliates.
2 ;;; Licensed under the Apache License, Version 2.0 (the "License");
3 ;;; you may not use this file except in compliance with the License.
4 ;;; You may obtain a copy of the License at:
5 ;;;
6 ;;;     http://www.apache.org/licenses/LICENSE-2.0
7 ;;;
8 ;;; Unless required by applicable law or agreed to in writing, software
9 ;;; distributed under the License is distributed on an "AS IS" BASIS,
10 ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 ;;; See the License for the specific language governing permissions and
12 ;;; limitations under the License.
13
14 (defun make-plugin ()
15   "Create a plugin"
16   (interactive)
17   (save-excursion
18     (let (cd-args cmd-args start-dir)
19       (setq start-dir default-directory)
20       (makunbound 'plugin-name)
21       (makunbound 'PLUGIN-NAME)
22       (makunbound 'plugin-flavor)
23       (setq plugin-name (read-string "Plugin name: "))
24       (setq plugin-flavor 
25             (read-string "Dispatch type [dual or qs]: "))
26       (setq PLUGIN-NAME (upcase plugin-name))
27       (find-file (concat plugin-name ".am"))
28       (skel-plugin-makefile-am-fragment)
29       (setq cmd-args (concat "mkdir -p " plugin-name))
30       (shell-command cmd-args)
31       (setq cd-args (concat start-dir "/" plugin-name))
32       (setq default-directory cd-args)
33       (find-file (concat plugin-name ".api"))
34       (skel-plugin-api)
35       (find-file (concat plugin-name "_all_api_h.h"))
36       (skel-plugin-all-apih)
37       (find-file (concat plugin-name ".h"))
38       (skel-plugin-h)
39       (find-file (concat plugin-name ".c"))
40       (skel-plugin-main)
41       (find-file (concat plugin-name "_msg_enum.h"))
42       (skel-plugin-msg-enum)
43       (find-file "node.c")
44       (if (string= plugin-flavor "qs")
45           (skel-plugin-qsnode) (skel-plugin-node))
46       (find-file (concat plugin-name "_test.c"))
47       (skel-plugin-test)
48       (find-file (concat plugin-name "_periodic.c"))
49       (skel-plugin-periodic)
50       (find-file "setup.pg")
51       (skel-plugin-setup)
52       (cd start-dir))))
53