Stop using gperf

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-09-02 19:24:39 +02:00
parent 1f9547b4e0
commit 6bb646861c
6 changed files with 2 additions and 158 deletions

View File

@ -89,8 +89,7 @@ set(AWE_MAN_SRCS
set(AWE_MAN_LANGS es fr de) set(AWE_MAN_LANGS es fr de)
add_executable(${PROJECT_AWE_NAME} add_executable(${PROJECT_AWE_NAME}
${AWE_SRCS} ${AWE_SRCS})
${BUILD_DIR}/common/tokenize.c)
set_target_properties(${PROJECT_AWE_NAME} set_target_properties(${PROJECT_AWE_NAME}
PROPERTIES PROPERTIES
@ -121,30 +120,9 @@ add_custom_command(
COMMENT "Generating atoms-intern.h" COMMENT "Generating atoms-intern.h"
VERBATIM) VERBATIM)
# gperf
add_custom_command(
COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
ARGS ${SOURCE_DIR}/common/tokenize.gperf
${BUILD_DIR}/common/tokenize.h
OUTPUT ${BUILD_DIR}/common/tokenize.h
DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
${SOURCE_DIR}/build-utils/gperf.sh
COMMENT "Generating common/tokenize.h")
add_custom_command(
COMMAND ${SOURCE_DIR}/build-utils/gperf.sh
ARGS ${SOURCE_DIR}/common/tokenize.gperf
${BUILD_DIR}/common/tokenize.c
OUTPUT ${BUILD_DIR}/common/tokenize.c
DEPENDS ${SOURCE_DIR}/common/tokenize.gperf
${SOURCE_DIR}/build-utils/gperf.sh
COMMENT "Generating common/tokenize.c")
add_custom_target(generated_sources add_custom_target(generated_sources
DEPENDS ${BUILD_DIR}/common/atoms-intern.h DEPENDS ${BUILD_DIR}/common/atoms-intern.h
${BUILD_DIR}/common/atoms-extern.h ${BUILD_DIR}/common/atoms-extern.h)
${BUILD_DIR}/common/tokenize.c
${BUILD_DIR}/common/tokenize.h)
# Default theme directory # Default theme directory
file(MAKE_DIRECTORY ${BUILD_DIR}/themes/default) file(MAKE_DIRECTORY ${BUILD_DIR}/themes/default)

View File

@ -50,7 +50,6 @@ a_find_program(LN_EXECUTABLE ln TRUE)
a_find_program(GREP_EXECUTABLE grep TRUE) a_find_program(GREP_EXECUTABLE grep TRUE)
a_find_program(GIT_EXECUTABLE git FALSE) a_find_program(GIT_EXECUTABLE git FALSE)
a_find_program(HOSTNAME_EXECUTABLE hostname FALSE) a_find_program(HOSTNAME_EXECUTABLE hostname FALSE)
a_find_program(GPERF_EXECUTABLE gperf TRUE)
# programs needed for man pages # programs needed for man pages
a_find_program(ASCIIDOC_EXECUTABLE asciidoc FALSE) a_find_program(ASCIIDOC_EXECUTABLE asciidoc FALSE)
a_find_program(XMLTO_EXECUTABLE xmlto FALSE) a_find_program(XMLTO_EXECUTABLE xmlto FALSE)

View File

@ -1,130 +0,0 @@
#!/bin/sh
#
# Copyright © 2008 Pierre Habouzit <madcoder@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
die() {
echo "$@" 1>&2
exit 2
}
do_hdr() {
cat <<EOF
/* This file is autogenerated by $(basename $0) */
EOF
}
out=
type_t=
while true; do
test $# -gt 2 || break
case "$1" in
-o) shift; out="$1"; shift;;
-t) shift; type_t="$1"; shift;;
*) break;;
esac
done
do_h() {
cat <<EOF
`do_hdr`
#ifndef AWESOME_TOKENIZE_H
#define AWESOME_TOKENIZE_H
typedef enum awesome_token_t {
A_TK_UNKNOWN,
`LC_ALL=C tr a-z A-Z | sed -e "s/^[^/].*/ A_TK_&,/"`
} awesome_token_t;
__attribute__((pure)) enum awesome_token_t a_tokenize(const char *s, int len);
#endif
EOF
}
do_tokens() {
while read tok; do
case "$tok" in
"") continue;;
*)
echo "$tok, A_TK_`echo $tok | LC_ALL=C tr a-z A-Z`"
;;
esac
done
}
do_c() {
which gperf > /dev/null
if test $? = 1 ; then
echo "gperf not found. You need to install gperf." > /dev/stderr;
exit 1;
fi;
gperf -l -t -C -F",0" \
--language=ANSI-C -Na_tokenize_aux <<EOF \
| sed -e '/__gnu_inline__/d;s/\<\(__\|\)inline\>//g'
%{
`do_hdr`
#include <string.h>
#include "common/tokenize.h"
static const struct tok *a_tokenize_aux(const char *str, unsigned int len);
%}
struct tok { const char *name; int val; };
%%
`do_tokens`
%%
awesome_token_t a_tokenize(const char *s, int len)
{
if (len < 0)
len = (int)strlen(s);
if (len) {
const struct tok *res = a_tokenize_aux(s, len);
return res ? res->val : A_TK_UNKNOWN;
} else {
return A_TK_UNKNOWN;
}
}
EOF
}
extract_tokens() {
grep '^### ' "$1" | cut -d ' ' -f 2
}
TOKENS_FILE="$1"
TARGET="$2"
trap "rm -f ${TARGET}" 0
rm -f "${TARGET}"
case "${TARGET}" in
*.h) do_h > "${TARGET}" < "${TOKENS_FILE}" ;;
*.c) do_c > "${TARGET}" < "${TOKENS_FILE}" ;;
*) die "you must ask for the 'h' or 'c' generation";;
esac
chmod -w "${TARGET}"
trap - 0
exit 0

View File

@ -23,7 +23,6 @@
#define AWESOME_COMMON_LUACLASS #define AWESOME_COMMON_LUACLASS
#include "common/signal.h" #include "common/signal.h"
#include "common/tokenize.h"
typedef struct lua_class_property lua_class_property_t; typedef struct lua_class_property lua_class_property_t;

View File

@ -24,7 +24,6 @@
#include "button.h" #include "button.h"
#include "draw.h" #include "draw.h"
#include "common/tokenize.h"
typedef widget_t *(widget_constructor_t)(widget_t *); typedef widget_t *(widget_constructor_t)(widget_t *);
typedef void (widget_destructor_t)(widget_t *); typedef void (widget_destructor_t)(widget_t *);

View File

@ -21,7 +21,6 @@
#include "objects/widget.h" #include "objects/widget.h"
#include "luaa.h" #include "luaa.h"
#include "common/tokenize.h"
/** Padding type */ /** Padding type */
typedef struct typedef struct