Skip to content

Commit b95b0ff

Browse files
committed
THRIFT-1500: d programming language support
Client: D Patch: David Nadlinger D program language library and additions git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1304085 13f79535-47bb-0310-9956-ffa450edef68
1 parent f485e2b commit b95b0ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+23339
-1
lines changed

aclocal/ax_check_openssl.m4

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# ===========================================================================
2+
# http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]])
8+
#
9+
# DESCRIPTION
10+
#
11+
# Look for OpenSSL in a number of default spots, or in a user-selected
12+
# spot (via --with-openssl). Sets
13+
#
14+
# OPENSSL_INCLUDES to the include directives required
15+
# OPENSSL_LIBS to the -l directives required
16+
# OPENSSL_LDFLAGS to the -L or -R flags required
17+
#
18+
# and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately
19+
#
20+
# This macro sets OPENSSL_INCLUDES such that source files should use the
21+
# openssl/ directory in include directives:
22+
#
23+
# #include <openssl/hmac.h>
24+
#
25+
# LICENSE
26+
#
27+
# Copyright (c) 2009,2010 Zmanda Inc. <http://www.zmanda.com/>
28+
# Copyright (c) 2009,2010 Dustin J. Mitchell <[email protected]>
29+
#
30+
# Copying and distribution of this file, with or without modification, are
31+
# permitted in any medium without royalty provided the copyright notice
32+
# and this notice are preserved. This file is offered as-is, without any
33+
# warranty.
34+
35+
#serial 8
36+
37+
AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL])
38+
AC_DEFUN([AX_CHECK_OPENSSL], [
39+
found=false
40+
AC_ARG_WITH([openssl],
41+
[AS_HELP_STRING([--with-openssl=DIR],
42+
[root of the OpenSSL directory])],
43+
[
44+
case "$withval" in
45+
"" | y | ye | yes | n | no)
46+
AC_MSG_ERROR([Invalid --with-openssl value])
47+
;;
48+
*) ssldirs="$withval"
49+
;;
50+
esac
51+
], [
52+
# if pkg-config is installed and openssl has installed a .pc file,
53+
# then use that information and don't search ssldirs
54+
AC_PATH_PROG([PKG_CONFIG], [pkg-config])
55+
if test x"$PKG_CONFIG" != x""; then
56+
OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
57+
if test $? = 0; then
58+
OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null`
59+
OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null`
60+
found=true
61+
fi
62+
fi
63+
64+
# no such luck; use some default ssldirs
65+
if ! $found; then
66+
ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
67+
fi
68+
]
69+
)
70+
71+
72+
# note that we #include <openssl/foo.h>, so the OpenSSL headers have to be in
73+
# an 'openssl' subdirectory
74+
75+
if ! $found; then
76+
OPENSSL_INCLUDES=
77+
for ssldir in $ssldirs; do
78+
AC_MSG_CHECKING([for openssl/ssl.h in $ssldir])
79+
if test -f "$ssldir/include/openssl/ssl.h"; then
80+
OPENSSL_INCLUDES="-I$ssldir/include"
81+
OPENSSL_LDFLAGS="-L$ssldir/lib"
82+
OPENSSL_LIBS="-lssl -lcrypto"
83+
found=true
84+
AC_MSG_RESULT([yes])
85+
break
86+
else
87+
AC_MSG_RESULT([no])
88+
fi
89+
done
90+
91+
# if the file wasn't found, well, go ahead and try the link anyway -- maybe
92+
# it will just work!
93+
fi
94+
95+
# try the preprocessor and linker with our new flags,
96+
# being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
97+
98+
AC_MSG_CHECKING([whether compiling and linking against OpenSSL works])
99+
echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \
100+
"OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD
101+
102+
save_LIBS="$LIBS"
103+
save_LDFLAGS="$LDFLAGS"
104+
save_CPPFLAGS="$CPPFLAGS"
105+
LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
106+
LIBS="$OPENSSL_LIBS $LIBS"
107+
CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
108+
AC_LINK_IFELSE(
109+
[AC_LANG_PROGRAM([#include <openssl/ssl.h>], [SSL_new(NULL)])],
110+
[
111+
AC_MSG_RESULT([yes])
112+
$1
113+
], [
114+
AC_MSG_RESULT([no])
115+
$2
116+
])
117+
CPPFLAGS="$save_CPPFLAGS"
118+
LDFLAGS="$save_LDFLAGS"
119+
LIBS="$save_LIBS"
120+
121+
AC_SUBST([OPENSSL_INCLUDES])
122+
AC_SUBST([OPENSSL_LIBS])
123+
AC_SUBST([OPENSSL_LDFLAGS])
124+
])

aclocal/ax_dmd.m4

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
dnl @synopsis AX_DMD
2+
dnl
3+
dnl Test for the presence of a DMD-compatible D2 compiler, and (optionally)
4+
dnl specified modules on the import path.
5+
dnl
6+
dnl If "DMD" is defined in the environment, that will be the only
7+
dnl dmd command tested. Otherwise, a hard-coded list will be used.
8+
dnl
9+
dnl After AX_DMD runs, the shell variables "success" and "ax_dmd" are set to
10+
dnl "yes" or "no", and "DMD" is set to the appropriate command. Furthermore,
11+
dnl "dmd_optlink" will be set to "yes" or "no" depending on whether OPTLINK is
12+
dnl used as the linker (DMD/Windows), and "dmd_of_dirsep" will be set to the
13+
dnl directory separator to use when passing -of to DMD (OPTLINK requires a
14+
dnl backslash).
15+
dnl
16+
dnl AX_CHECK_D_MODULE must be run after AX_DMD. It tests for the presence of a
17+
dnl module in the import path of the chosen compiler, and sets the shell
18+
dnl variable "success" to "yes" or "no".
19+
dnl
20+
dnl @category D
21+
dnl @version 2011-05-31
22+
dnl @license AllPermissive
23+
dnl
24+
dnl Copyright (C) 2009 David Reiss
25+
dnl Copyright (C) 2011 David Nadlinger
26+
dnl Copying and distribution of this file, with or without modification,
27+
dnl are permitted in any medium without royalty provided the copyright
28+
dnl notice and this notice are preserved.
29+
30+
31+
AC_DEFUN([AX_DMD],
32+
[
33+
dnl Hard-coded default commands to test.
34+
DMD_PROGS="dmd,gdmd,ldmd"
35+
36+
dnl Allow the user to specify an alternative.
37+
if test -n "$DMD" ; then
38+
DMD_PROGS="$DMD"
39+
fi
40+
41+
AC_MSG_CHECKING(for DMD)
42+
43+
# std.algorithm as a quick way to check for D2/Phobos.
44+
echo "import std.algorithm; void main() {}" > configtest_ax_dmd.d
45+
success=no
46+
oIFS="$IFS"
47+
48+
IFS=","
49+
for DMD in $DMD_PROGS ; do
50+
IFS="$oIFS"
51+
52+
echo "Running \"$DMD configtest_ax_dmd.d\"" >&AS_MESSAGE_LOG_FD
53+
if $DMD configtest_ax_dmd.d >&AS_MESSAGE_LOG_FD 2>&1 ; then
54+
success=yes
55+
break
56+
fi
57+
done
58+
59+
if test "$success" != "yes" ; then
60+
AC_MSG_RESULT(no)
61+
DMD=""
62+
else
63+
AC_MSG_RESULT(yes)
64+
fi
65+
66+
ax_dmd="$success"
67+
68+
# Test whether OPTLINK is used by trying if DMD accepts -L/? without
69+
# erroring out.
70+
if test "$success" == "yes" ; then
71+
AC_MSG_CHECKING(whether DMD uses OPTLINK)
72+
echo "Running \”$DMD -L/? configtest_ax_dmd.d\"" >&AS_MESSAGE_LOG_FD
73+
if $DMD -L/? configtest_ax_dmd.d >&AS_MESSAGE_LOG_FD 2>&1 ; then
74+
AC_MSG_RESULT(yes)
75+
dmd_optlink="yes"
76+
77+
# This actually produces double slashes in the final configure
78+
# output, but at least it works.
79+
dmd_of_dirsep="\\\\"
80+
else
81+
AC_MSG_RESULT(no)
82+
dmd_optlink="no"
83+
dmd_of_dirsep="/"
84+
fi
85+
fi
86+
87+
rm -f configtest_ax_dmd*
88+
])
89+
90+
91+
AC_DEFUN([AX_CHECK_D_MODULE],
92+
[
93+
AC_MSG_CHECKING(for D module [$1])
94+
95+
echo "import $1; void main() {}" > configtest_ax_dmd.d
96+
97+
echo "Running \"$DMD configtest_ax_dmd.d\"" >&AS_MESSAGE_LOG_FD
98+
if $DMD -c configtest_ax_dmd.d >&AS_MESSAGE_LOG_FD 2>&1 ; then
99+
AC_MSG_RESULT(yes)
100+
success=yes
101+
else
102+
AC_MSG_RESULT(no)
103+
success=no
104+
fi
105+
106+
rm -f configtest_ax_dmd*
107+
])

compiler/cpp/Makefile.am

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ thrift_SOURCES += src/generate/t_c_glib_generator.cc \
8383
src/generate/t_js_generator.cc \
8484
src/generate/t_javame_generator.cc \
8585
src/generate/t_delphi_generator.cc \
86-
src/generate/t_go_generator.cc
86+
src/generate/t_go_generator.cc \
87+
src/generate/t_d_generator.cc
8788

8889
thrift_CPPFLAGS = -I$(srcdir)/src
8990
thrift_CXXFLAGS = -Wall

0 commit comments

Comments
 (0)