Rebar good autoconf bad
This commit is contained in:
11
.gitignore
vendored
11
.gitignore
vendored
@@ -1,13 +1,8 @@
|
|||||||
doc
|
doc
|
||||||
config.log
|
|
||||||
config.status
|
|
||||||
autom4te.cache
|
|
||||||
Makefile
|
|
||||||
priv/Makefile
|
|
||||||
sqlite3.plt
|
sqlite3.plt
|
||||||
.svn
|
|
||||||
*/.svn
|
|
||||||
*.db
|
*.db
|
||||||
*.swp
|
*.swp
|
||||||
*~
|
*~
|
||||||
|
ebin
|
||||||
|
priv
|
||||||
|
erl_crash.dump
|
||||||
|
|||||||
14
Makefile
Normal file
14
Makefile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
REBAR:=./rebar
|
||||||
|
|
||||||
|
all: erl
|
||||||
|
|
||||||
|
erl:
|
||||||
|
$(REBAR) get-deps compile
|
||||||
|
|
||||||
|
test: all
|
||||||
|
$(REBAR) skip_deps=true eunit
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(REBAR) clean
|
||||||
|
-rm -rvf deps ebin
|
||||||
|
|
||||||
35
Makefile.in
35
Makefile.in
@@ -1,35 +0,0 @@
|
|||||||
ERL=@ERL@
|
|
||||||
ERLC=@ERLC@
|
|
||||||
ERL_ERTS=@ERLANG_LIB_DIR_erts@
|
|
||||||
ERL_KERNEL=@ERLANG_LIB_DIR_kernel@
|
|
||||||
ERL_STDLIB=@ERLANG_LIB_DIR_stdlib@
|
|
||||||
ERL_CRYPTO=@ERLANG_LIB_DIR_crypto@
|
|
||||||
ERL_COMPILER=@ERLANG_LIB_DIR_compiler@
|
|
||||||
ERL_HIPE=@ERLANG_LIB_DIR_hipe@
|
|
||||||
ERL_SYNTAX_TOOLS=@ERLANG_LIB_DIR_syntax_tools@
|
|
||||||
OTP_TOP=/usr/lib/erlang/lib
|
|
||||||
PLT_SRC=$(ERL_ERTS)/ebin $(ERL_KERNEL)/ebin $(ERL_STDLIB)/ebin $(ERL_CRYPTO)/ebin $(ERL_COMPILER)/ebin $(ERL_HIPE)/ebin $(ERL_SYNTAX_TOOLS)/ebin
|
|
||||||
|
|
||||||
all: compile docs
|
|
||||||
|
|
||||||
compile:
|
|
||||||
test -d ebin || mkdir ebin
|
|
||||||
$(ERL) -make
|
|
||||||
cd priv && make
|
|
||||||
|
|
||||||
ifeq ($(wildcard sqlite3.plt),)
|
|
||||||
static:
|
|
||||||
dialyzer --build_plt --output_plt sqlite3.plt -r $(PLT_SRC) ebin
|
|
||||||
else
|
|
||||||
static:
|
|
||||||
dialyzer --add_to_plt --plt sqlite3.plt -r ebin
|
|
||||||
endif
|
|
||||||
|
|
||||||
clean:
|
|
||||||
- rm -rf ebin/*.beam doc/* sqlite3.plt src/test/*.beam
|
|
||||||
- rm -rf ct_run* all_runs.html variables* index.html
|
|
||||||
- find . -name "*~" | xargs rm
|
|
||||||
cd priv && make clean
|
|
||||||
|
|
||||||
docs:
|
|
||||||
$(ERL) -noshell -run edoc_run application "'sqlite3'" '"."' '[{title,"Welcome to sqlite3"},{hidden,false},{private,false}]' -s erlang halt
|
|
||||||
BIN
c_src/erl_comm.o
Normal file
BIN
c_src/erl_comm.o
Normal file
Binary file not shown.
BIN
c_src/sqlite3_drv.o
Normal file
BIN
c_src/sqlite3_drv.o
Normal file
Binary file not shown.
BIN
c_src/sqlite_port.o
Normal file
BIN
c_src/sqlite_port.o
Normal file
Binary file not shown.
55
configure.ac
55
configure.ac
@@ -1,55 +0,0 @@
|
|||||||
# -*- Autoconf -*-
|
|
||||||
# Process this file with autoconf to produce a configure script.
|
|
||||||
|
|
||||||
AC_PREREQ([2.63])
|
|
||||||
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
|
|
||||||
AC_CONFIG_SRCDIR([priv/erl_comm.c])
|
|
||||||
#AC_CONFIG_HEADERS([config.h])
|
|
||||||
#AC_CANONICAL_TARGET
|
|
||||||
|
|
||||||
# Checks for programs.
|
|
||||||
AC_PROG_CC
|
|
||||||
AC_PROG_MAKE_SET
|
|
||||||
|
|
||||||
## Checks for libraries.
|
|
||||||
## FIXME: Replace `main' with a function in `-lei':
|
|
||||||
#AC_CHECK_LIB([ei], [main])
|
|
||||||
## FIXME: Replace `main' with a function in `-lerl_interface':
|
|
||||||
#AC_CHECK_LIB([erl_interface], [main])
|
|
||||||
## FIXME: Replace `main' with a function in `-lsqlite3':
|
|
||||||
#AC_CHECK_LIB([sqlite3], [main])
|
|
||||||
|
|
||||||
# Checks for header files.
|
|
||||||
AC_CHECK_HEADERS([stdlib.h string.h unistd.h])
|
|
||||||
|
|
||||||
# Checks for typedefs, structures, and compiler characteristics.
|
|
||||||
AC_C_INLINE
|
|
||||||
|
|
||||||
# Checks for library functions.
|
|
||||||
AC_FUNC_MALLOC
|
|
||||||
AC_FUNC_REALLOC
|
|
||||||
AC_CHECK_FUNCS([bzero strstr])
|
|
||||||
|
|
||||||
AC_ERLANG_NEED_ERLC
|
|
||||||
AC_ERLANG_SUBST_ROOT_DIR
|
|
||||||
AC_ERLANG_SUBST_LIB_DIR
|
|
||||||
AC_ERLANG_CHECK_LIB(erl_interface)
|
|
||||||
AC_ERLANG_CHECK_LIB(kernel)
|
|
||||||
AC_ERLANG_CHECK_LIB(stdlib)
|
|
||||||
AC_ERLANG_CHECK_LIB(crypto)
|
|
||||||
AC_ERLANG_CHECK_LIB(compiler)
|
|
||||||
AC_ERLANG_CHECK_LIB(hipe)
|
|
||||||
AC_ERLANG_CHECK_LIB(syntax_tools)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([null-atom],
|
|
||||||
[AC_HELP_STRING([--enable-null-atom=atom],
|
|
||||||
[Set to configure null-atom, default 'null'])],
|
|
||||||
[ ac_null_atom=$enableval ],
|
|
||||||
[ ac_null_atom=null ])
|
|
||||||
|
|
||||||
NULL_ATOM="$ac_null_atom"
|
|
||||||
AC_SUBST([NULL_ATOM])
|
|
||||||
AC_CONFIG_FILES([Makefile
|
|
||||||
Emakefile
|
|
||||||
priv/Makefile])
|
|
||||||
AC_OUTPUT
|
|
||||||
3
ebin/.gitignore
vendored
3
ebin/.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
*.beam
|
|
||||||
*.so
|
|
||||||
|
|
||||||
0
rebar.config
Normal file
0
rebar.config
Normal file
10
src/sqlite3.app.src
Normal file
10
src/sqlite3.app.src
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{application, sqlite3,
|
||||||
|
[
|
||||||
|
{description, "SQLite3 Interface"},
|
||||||
|
{vsn, "1"},
|
||||||
|
{modules, []},
|
||||||
|
{registered, []},
|
||||||
|
{applications, [kernel, stdlib, crypto, inets, lhttpc]},
|
||||||
|
{mod, {sqlite3, []}},
|
||||||
|
{env, []}
|
||||||
|
]}.
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||||
terminate/2, code_change/3]).
|
terminate/2, code_change/3]).
|
||||||
|
|
||||||
-define('DRIVER_NAME', 'sqlite3_drv').
|
-define('DRIVER_NAME', 'sqlite3_drv').
|
||||||
-record(state, {port, ops = []}).
|
-record(state, {port, ops = []}).
|
||||||
@@ -77,9 +77,9 @@ start_link(Db) ->
|
|||||||
-spec(start_link/2::(atom(), [{atom(), any()}]) -> result()).
|
-spec(start_link/2::(atom(), [{atom(), any()}]) -> result()).
|
||||||
start_link(Db, Options) ->
|
start_link(Db, Options) ->
|
||||||
Opts = case proplists:get_value(db, Options) of
|
Opts = case proplists:get_value(db, Options) of
|
||||||
undefined -> [{db, "./" ++ atom_to_list(Db) ++ ".db"} | Options];
|
undefined -> [{db, "./" ++ atom_to_list(Db) ++ ".db"} | Options];
|
||||||
_ -> Options
|
_ -> Options
|
||||||
end,
|
end,
|
||||||
?MODULE:open(Db, Opts).
|
?MODULE:open(Db, Opts).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
@@ -426,7 +426,7 @@ value_to_sql(X) -> sqlite3_lib:value_to_sql(X).
|
|||||||
init(Options) ->
|
init(Options) ->
|
||||||
Dbase = proplists:get_value(db, Options),
|
Dbase = proplists:get_value(db, Options),
|
||||||
{?MODULE, _, FileName} = code:get_object_code(?MODULE),
|
{?MODULE, _, FileName} = code:get_object_code(?MODULE),
|
||||||
SearchDir = filename:dirname(FileName),
|
SearchDir = filename:dirname(filename:dirname(FileName)) ++ "/priv",
|
||||||
case erl_ddll:load(SearchDir, atom_to_list(?DRIVER_NAME)) of
|
case erl_ddll:load(SearchDir, atom_to_list(?DRIVER_NAME)) of
|
||||||
ok ->
|
ok ->
|
||||||
Port = open_port({spawn, string:join ([atom_to_list (?DRIVER_NAME), Dbase], " ")}, [binary]),
|
Port = open_port({spawn, string:join ([atom_to_list (?DRIVER_NAME), Dbase], " ")}, [binary]),
|
||||||
@@ -570,15 +570,15 @@ create_cmd(Dbase) ->
|
|||||||
|
|
||||||
wait_result(Port) ->
|
wait_result(Port) ->
|
||||||
receive
|
receive
|
||||||
{Port, Reply} ->
|
{Port, Reply} ->
|
||||||
% io:format("Reply: ~p~n", [Reply]),
|
% io:format("Reply: ~p~n", [Reply]),
|
||||||
Reply;
|
Reply;
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
io:format("Error: ~p~n", [Reason]),
|
io:format("Error: ~p~n", [Reason]),
|
||||||
{error, Reason};
|
{error, Reason};
|
||||||
_Else ->
|
_Else ->
|
||||||
io:format("Else: ~p~n", [_Else]),
|
io:format("Else: ~p~n", [_Else]),
|
||||||
_Else
|
_Else
|
||||||
end.
|
end.
|
||||||
|
|
||||||
exec(_Port, {create_function, _FunctionName, _Function}) ->
|
exec(_Port, {create_function, _FunctionName, _Function}) ->
|
||||||
@@ -596,8 +596,8 @@ parse_table_info(Info) ->
|
|||||||
[_, Tail] = string:tokens(Info, "()"),
|
[_, Tail] = string:tokens(Info, "()"),
|
||||||
Cols = string:tokens(Tail, ","),
|
Cols = string:tokens(Tail, ","),
|
||||||
build_table_info(lists:map(fun(X) ->
|
build_table_info(lists:map(fun(X) ->
|
||||||
string:tokens(X, " ")
|
string:tokens(X, " ")
|
||||||
end, Cols), []).
|
end, Cols), []).
|
||||||
|
|
||||||
build_table_info([], Acc) ->
|
build_table_info([], Acc) ->
|
||||||
lists:reverse(Acc);
|
lists:reverse(Acc);
|
||||||
@@ -605,4 +605,3 @@ build_table_info([[ColName, ColType] | Tl], Acc) ->
|
|||||||
build_table_info(Tl, [{list_to_atom(ColName), sqlite3_lib:col_type(ColType)}| Acc]);
|
build_table_info(Tl, [{list_to_atom(ColName), sqlite3_lib:col_type(ColType)}| Acc]);
|
||||||
build_table_info([[ColName, ColType, "PRIMARY", "KEY"] | Tl], Acc) ->
|
build_table_info([[ColName, ColType, "PRIMARY", "KEY"] | Tl], Acc) ->
|
||||||
build_table_info(Tl, [{list_to_atom(ColName), primary_key}| Acc]).
|
build_table_info(Tl, [{list_to_atom(ColName), primary_key}| Acc]).
|
||||||
|
|
||||||
|
|||||||
@@ -1,178 +0,0 @@
|
|||||||
%%%-------------------------------------------------------------------
|
|
||||||
%%% File : sqlite_test_SUITE.erl
|
|
||||||
%%% Author : Tee Teoh <tteoh@teemac.ott.cti.com>
|
|
||||||
%%% Description :
|
|
||||||
%%%
|
|
||||||
%%% Created : 4 Sep 2008 by Tee Teoh <tteoh@teemac.ott.cti.com>
|
|
||||||
%%%-------------------------------------------------------------------
|
|
||||||
-module(sqlite_test_SUITE).
|
|
||||||
|
|
||||||
%% Note: This directive should only be used in test suites.
|
|
||||||
-compile(export_all).
|
|
||||||
|
|
||||||
-include("ct.hrl").
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% COMMON TEST CALLBACK FUNCTIONS
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: suite() -> Info
|
|
||||||
%%
|
|
||||||
%% Info = [tuple()]
|
|
||||||
%% List of key/value pairs.
|
|
||||||
%%
|
|
||||||
%% Description: Returns list of tuples to set default properties
|
|
||||||
%% for the suite.
|
|
||||||
%%
|
|
||||||
%% Note: The suite/0 function is only meant to be used to return
|
|
||||||
%% default data values, not perform any other operations.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
suite() ->
|
|
||||||
[{timetrap,{minutes,10}}].
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: init_per_suite(Config0) ->
|
|
||||||
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
|
|
||||||
%%
|
|
||||||
%% Config0 = Config1 = [tuple()]
|
|
||||||
%% A list of key/value pairs, holding the test case configuration.
|
|
||||||
%% Reason = term()
|
|
||||||
%% The reason for skipping the suite.
|
|
||||||
%%
|
|
||||||
%% Description: Initialization before the suite.
|
|
||||||
%%
|
|
||||||
%% Note: This function is free to add any key/value pairs to the Config
|
|
||||||
%% variable, but should NOT alter/remove any existing entries.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
init_per_suite(Config) ->
|
|
||||||
%%[{dbase, userct} | Config].
|
|
||||||
Config.
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}
|
|
||||||
%%
|
|
||||||
%% Config0 = Config1 = [tuple()]
|
|
||||||
%% A list of key/value pairs, holding the test case configuration.
|
|
||||||
%%
|
|
||||||
%% Description: Cleanup after the suite.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
end_per_suite(Config) ->
|
|
||||||
ok.
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: init_per_testcase(TestCase, Config0) ->
|
|
||||||
%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
|
|
||||||
%%
|
|
||||||
%% TestCase = atom()
|
|
||||||
%% Name of the test case that is about to run.
|
|
||||||
%% Config0 = Config1 = [tuple()]
|
|
||||||
%% A list of key/value pairs, holding the test case configuration.
|
|
||||||
%% Reason = term()
|
|
||||||
%% The reason for skipping the test case.
|
|
||||||
%%
|
|
||||||
%% Description: Initialization before each test case.
|
|
||||||
%%
|
|
||||||
%% Note: This function is free to add any key/value pairs to the Config
|
|
||||||
%% variable, but should NOT alter/remove any existing entries.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
init_per_testcase(TestCase, Config) ->
|
|
||||||
sqlite3:open(TestCase),
|
|
||||||
[{db, TestCase} | Config].
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: end_per_testcase(TestCase, Config0) ->
|
|
||||||
%% void() | {save_config,Config1}
|
|
||||||
%%
|
|
||||||
%% TestCase = atom()
|
|
||||||
%% Name of the test case that is finished.
|
|
||||||
%% Config0 = Config1 = [tuple()]
|
|
||||||
%% A list of key/value pairs, holding the test case configuration.
|
|
||||||
%%
|
|
||||||
%% Description: Cleanup after each test case.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
end_per_testcase(TestCase, _Config) ->
|
|
||||||
sqlite3:close(TestCase),
|
|
||||||
ok.
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: sequences() -> Sequences
|
|
||||||
%%
|
|
||||||
%% Sequences = [{SeqName,TestCases}]
|
|
||||||
%% SeqName = atom()
|
|
||||||
%% Name of a sequence.
|
|
||||||
%% TestCases = [atom()]
|
|
||||||
%% List of test cases that are part of the sequence
|
|
||||||
%%
|
|
||||||
%% Description: Specifies test case sequences.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
sequences() ->
|
|
||||||
[].
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: all() -> TestCases | {skip,Reason}
|
|
||||||
%%
|
|
||||||
%% TestCases = [TestCase | {sequence,SeqName}]
|
|
||||||
%% TestCase = atom()
|
|
||||||
%% Name of a test case.
|
|
||||||
%% SeqName = atom()
|
|
||||||
%% Name of a test case sequence.
|
|
||||||
%% Reason = term()
|
|
||||||
%% The reason for skipping all test cases.
|
|
||||||
%%
|
|
||||||
%% Description: Returns the list of test cases that are to be executed.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
all() ->
|
|
||||||
[create_table].
|
|
||||||
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% TEST CASES
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: TestCase() -> Info
|
|
||||||
%%
|
|
||||||
%% Info = [tuple()]
|
|
||||||
%% List of key/value pairs.
|
|
||||||
%%
|
|
||||||
%% Description: Test case info function - returns list of tuples to set
|
|
||||||
%% properties for the test case.
|
|
||||||
%%
|
|
||||||
%% Note: This function is only meant to be used to return a list of
|
|
||||||
%% values, not perform any other operations.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
create_table() ->
|
|
||||||
[].
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Function: TestCase(Config0) ->
|
|
||||||
%% ok | exit() | {skip,Reason} | {comment,Comment} |
|
|
||||||
%% {save_config,Config1} | {skip_and_save,Reason,Config1}
|
|
||||||
%%
|
|
||||||
%% Config0 = Config1 = [tuple()]
|
|
||||||
%% A list of key/value pairs, holding the test case configuration.
|
|
||||||
%% Reason = term()
|
|
||||||
%% The reason for skipping the test case.
|
|
||||||
%% Comment = term()
|
|
||||||
%% A comment about the test case that will be printed in the html log.
|
|
||||||
%%
|
|
||||||
%% Description: Test case function. (The name of it must be specified in
|
|
||||||
%% the all/0 list for the test case to be executed).
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
create_table(Config) ->
|
|
||||||
Dbase = proplists:get_value(db, Config),
|
|
||||||
sqlite3:open(Dbase),
|
|
||||||
sqlite3:create_table(Dbase, user, [{name, text}, {age, integer}, {wage, integer}]),
|
|
||||||
[user] = sqlite3:list_tables(Dbase),
|
|
||||||
[{name, primary_key}, {age, integer}, {wage, integer}] = sqlite3:table_info(Dbase, user),
|
|
||||||
sqlite3:write(Dbase, user, [{name, "abby"}, {age, 20}, {wage, 2000}]),
|
|
||||||
sqlite3:write(Dbase, user, [{name, "marge"}, {age, 30}, {wage, 3000}]),
|
|
||||||
[{columns, Columns}, {rows, Rows}] = sqlite3:sql_exec(Dbase, "select * from user;"),
|
|
||||||
Columns = ["name","age","wage"],
|
|
||||||
Rows = [{<<"abby">>,20,2000}, {<<"marge">>,30,3000}],
|
|
||||||
[{columns, Columns}, {rows, RowsAbby}] = sqlite3:read(Dbase, user, {name, "abby"}),
|
|
||||||
RowsAbby = [{<<"abby">>,20,2000}],
|
|
||||||
sqlite3:delete(Dbase, user, {name, "abby"}),
|
|
||||||
sqlite3:drop_table(Dbase, user),
|
|
||||||
ok.
|
|
||||||
Reference in New Issue
Block a user