소스 검색

Remove the need for makeset

Bryan Drewery 11 년 전
부모
커밋
fe56c3c1e7
5개의 변경된 파일29개의 추가작업 그리고 74개의 파일을 삭제
  1. 3 17
      Makefile.in
  2. 18 0
      build/makeset.sh
  3. 0 1
      src/.gitignore
  4. 8 6
      src/Makefile.in
  5. 0 50
      src/makeset.cc

+ 3 - 17
Makefile.in

@@ -26,7 +26,6 @@ VERSION 	:= $(shell git describe)
 DISTRIB = wraith-$(VERSION)
 
 HELPFILE = doc/help.txt
-SETTINGSFILE = doc/settings.txt
 RESPONSESFILE = doc/responses.txt
 
 # defaults
@@ -75,14 +74,14 @@ MAKE_UTILS_NR = $(MAKE) 'CXX=$(CXX)' 'STRIP=touch' 'INCLUDES=$(INCLUDES)' \
 
 MAKE_CONFIG = $(MAKE) 'MAKE=$(MAKE)'
 
-.PHONY: checkclean.static checkclean.dynamic checkclean.debug lib wraith dwraith lib.debug debug test general crypto utils sorthelp makehelp makeset makeres stringfix set res help sort indent tar distrib distclean clean cleanutils test all dynamic static tags
+.PHONY: checkclean.static checkclean.dynamic checkclean.debug lib wraith dwraith lib.debug debug test general crypto utils sorthelp makehelp makeres stringfix res help sort indent tar distrib distclean clean cleanutils test all dynamic static tags
 
 all: dynamic
 
 test:
 
 cleanutils:
-	@rm -f $(STRINGFIX) src/sorthelp@EXEEXT@ src/makehelp@EXEEXT@ src/makeres@EXEEXT@ src/makeset@EXEEXT@
+	@rm -f $(STRINGFIX) src/sorthelp@EXEEXT@ src/makehelp@EXEEXT@ src/makeres@EXEEXT@
 
 clean:  cleanutils
 	+@cd src && $(MAKE) clean
@@ -155,16 +154,6 @@ help: makehelp
 	cp -f src/help.h~ src/help.h; \
 	fi)
 
-set: makeset
-	@src/makeset@EXEEXT@ $(SETTINGSFILE) src/set_default.h~
-	@(if [ ! -f src/set_default.h ]; then \
-	touch src/set_default.h; \
-	fi)
-	@(if test "x`$(DIFF) -qurN src/set_default.h~ src/set_default.h`" != "x"; then \
-	cp -f src/set_default.h~ src/set_default.h; \
-	fi)
-
-
 res: makeres
 	@src/makeres@EXEEXT@ $(RESPONSESFILE) src/ 1
 	@(if [ ! -f src/response.h ]; then \
@@ -186,9 +175,6 @@ stringfix: src/stringfix.cc src/config.h
 makeres: src/makeres.cc
 	+@cd src && ${MAKE_UTILS} makeres
 
-makeset: src/makeset.cc
-	+@cd src && ${MAKE_UTILS} makeset
-
 makehelp: src/makehelp.cc
 	+@cd src && ${MAKE_UTILS} makehelp
 
@@ -200,7 +186,7 @@ utils: stringfix makehelp
 crypto:
 	+@cd src/crypto && ${MAKE_UTILS} crypto
 
-general: help res set stringfix
+general: help res stringfix
 
 .NOTPARALLEL: checkclean.static checkclean.dynamic checkclean.debug
 

+ 18 - 0
build/makeset.sh

@@ -0,0 +1,18 @@
+#! /bin/sh
+
+echo "/* Generated by $0 */"
+needcomma=0
+while read -r line; do
+	[ -z "${line%%#*}" ] && continue # skip comments
+	if [ -z "${line%%:*}" ]; then
+		[ ${needcomma} -eq 1 ] && printf "\"\n\n"
+		type="${line#:}"
+		[ "${type}" = "end" ] && break
+		printf "#define DEFAULT_%s \"%c\n" $(echo "${type}" | tr '[:lower:]' '[:upper:]') '\'
+		needcomma=0
+	else
+		[ ${needcomma} -eq 1 ] && printf ",%c\n" '\'
+		printf "%s" "${line}"
+		needcomma=1
+	fi
+done

+ 0 - 1
src/.gitignore

@@ -12,7 +12,6 @@
 /makehelp
 /sorthelp
 /makeres
-/makeset
 /set_default.h
 *.o
 *.So

+ 8 - 6
src/Makefile.in

@@ -11,6 +11,7 @@ CXXFLAGS = $(CXXFLAGS)
 CFLAGS = $(CFLGS)
 CPPFLAGS = @CPPFLAGS@ -I. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_srcdir)/pack @DEFS@ $(INCLUDES) '-DCOMMIT="$(COMMIT)"' '-DBRANCH="$(BRANCH)"' -DBUILDTS=$(BUILDTS) '-DVERSION="$(VERSION)"'
 LDFLAGS = @LDFLAGS@
+SETTINGSFILE = $(top_srcdir)/doc/settings.txt
 
 include $(top_srcdir)/build/build.mk
 
@@ -76,16 +77,17 @@ blah:
 	@echo "Use the build script."
 	@echo ""
 
+set.cc: set_default.h
+
+set_default.h: $(SETTINGSFILE) $(top_srcdir)/build/makeset.sh
+	@echo -e "[H]	\033[1m$*\033[0m"
+	@$(top_srcdir)/build/makeset.sh < $(SETTINGSFILE) > $@
+
 makeres: makeres.cc ../lib/bdlib/src/libbdlib.a
 	@echo -e "Compiling: \033[1mmakeres\033[0m"
 	@$(CXX) $(CPPFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/pack $(CXXFLAGS) $< ../lib/bdlib/src/libbdlib.a $(LDFLAGS) -o $@
 	@$(STRIP) $@@EXEEXT@
 
-makeset: makeset.cc ../lib/bdlib/src/libbdlib.a
-	@echo -e "Compiling: \033[1mmakeset\033[0m"
-	@$(CXX) $(CPPFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/pack $(CXXFLAGS) $< ../lib/bdlib/src/libbdlib.a $(LDFLAGS) -o $@
-	@$(STRIP) $@@EXEEXT@
-
 makehelp: makehelp.cc ../lib/bdlib/src/libbdlib.a
 	@echo -e "Compiling: \033[1mmakehelp\033[0m"
 	@$(CXX) $(CPPFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/pack $(CXXFLAGS) $< ../lib/bdlib/src/libbdlib.a $(LDFLAGS) -o $@
@@ -116,7 +118,7 @@ stringfix: stringfix.cc common.h config.h eggdrop.h
 $(EGGEXEC): stringfix ../$(EGGEXEC)
 
 clean:
-	@rm -f .depend *.o *.So *~ _*.c _*.cc *.ii *.i
+	@rm -f .depend *.o *.So *~ _*.c _*.cc *.ii *.i set_default.h
 
 build_msg:
 	@echo "[*] Compiling core components"

+ 0 - 50
src/makeset.cc

@@ -1,50 +0,0 @@
-#include <bdlib/src/Stream.h>
-#include <bdlib/src/String.h>
-#include <cctype>
-#include <algorithm>
-#include <cstring>
-using namespace std;
-
-int main(int argc, char *argv[]) {
-  if (argc == 2)
-    return 1;
-
-  bd::Stream file, out;
-  file.loadFile(argv[1]);
-
-  bd::String type, line;
-  char c;
-
-  while (file.tell() < file.length()) {
-    line = file.getline().chomp();
-    if (line[0] == '#') continue;
-    if (line[0] == ':') {
-      type = line(1);
-      if (type == "end")
-        break;
-
-      transform(type.begin(), type.end(), type.mdata(), (int(*)(int)) toupper);
-
-      type = "DEFAULT_" + type;
-      out << "#define " << type << " \"\\" << "\n";
-    } else {
-      if (!type.length()) 
-        continue;
-
-      out << line;
-      c = file.peek()[0];
-      if (strchr("\n:", c)) {
-        out << "\"\n\n";
-        type = "";
-      } else
-        out << ",\\\n";
-    }
-  }
-
-  if (out.writeFile(argv[2])) {
-    fprintf(stderr, "Failure writing %s\n", argv[2]);
-    return 1;
-  }
-  return 0;
-}
-/* vim: set sts=2 sw=2 ts=8 et: */