Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Willemt Raft
Commits
1d7aa60f
Commit
1d7aa60f
authored
Feb 27, 2014
by
Willemt
Browse files
Merge pull request #2 from xant/master
targets to build both shared and static libraries + compile on osx as well
parents
0a55c7f8
d0ef9a17
Changes
4
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
1d7aa60f
...
...
@@ -5,11 +5,24 @@ LLQUEUE_DIR = $(CONTRIB_DIR)/CLinkedListQueue
GCOV_OUTPUT
=
*
.gcda
*
.gcno
*
.gcov
GCOV_CCFLAGS
=
-fprofile-arcs
-ftest-coverage
SHELL
=
/bin/bash
CC
=
gcc
CCFLAGS
=
-g
-O2
-Werror
-Werror
=
return
-type
-Werror
=
uninitialized
-Wcast-align
-fno-omit-frame-pointer
-fno-common
-fsigned-char
$(GCOV_CCFLAGS)
-I
$(LLQUEUE_DIR)
-Iinclude
CFLAGS
+=
-Iinclude
-Werror
-Werror
=
return
-type
-Werror
=
uninitialized
-Wcast-align
\
-Wno-pointer-sign
-fno-omit-frame-pointer
-fno-common
-fsigned-char
\
$(GCOV_CCFLAGS)
-I
$(LLQUEUE_DIR)
-Iinclude
-fPIC
-g
-O2
all
:
tests_main
UNAME
:=
$(
shell
uname
)
ifeq
($(UNAME), Darwin)
SHAREDFLAGS
=
-dynamiclib
SHAREDEXT
=
dylib
else
SHAREDFLAGS
=
-shared
SHAREDEXT
=
so
endif
OBJECTS
=
raft_server.o raft_server_properties.o raft_node.o raft_log.o
all
:
static shared
clinkedlistqueue
:
mkdir
-p
$(LLQUEUE_DIR)
/.git
git
--git-dir
=
$(LLQUEUE_DIR)
/.git init
...
...
@@ -24,10 +37,22 @@ $(TEST_DIR)/main_test.c:
fi
cd
$(TEST_DIR)
&&
sh make-tests.sh
"test_*.c"
>
main_test.c
&&
cd
..
tests_main
:
raft_server.c raft_server_properties.c raft_log.c raft_node.c $(TEST_DIR)/main_test.c $(TEST_DIR)/test_server.c $(TEST_DIR)/test_node.c $(TEST_DIR)/test_log.c $(TEST_DIR)/test_scenario.c $(TEST_DIR)/mock_send_functions.c $(TEST_DIR)/CuTest.c $(LLQUEUE_DIR)/linked_list_queue.c
$(CC)
$(CCFLAGS)
-o
$@
$^
.PHONY
:
shared
shared
:
$(OBJECTS)
$(CC)
$(OBJECTS)
$(LDFLAGS)
$(CFLAGS)
$(SHAREDFLAGS)
-o
libcraft.
$(SHAREDEXT)
.PHONY
:
static
static
:
$(OBJECTS)
ar
-r
libcraft.a
$(OBJECTS)
.PHONY
:
tests
tests
:
raft_server.c raft_server_properties.c raft_log.c raft_node.c $(TEST_DIR)/main_test.c $(TEST_DIR)/test_server.c $(TEST_DIR)/test_node.c $(TEST_DIR)/test_log.c $(TEST_DIR)/test_scenario.c $(TEST_DIR)/mock_send_functions.c $(TEST_DIR)/CuTest.c $(LLQUEUE_DIR)/linked_list_queue.c
$(CC)
$(CFLAGS)
-o
tests_main
$^
./tests_main
gcov raft_server.c
clean
:
rm
-f
$(TEST_DIR)
/main_test.c
*
.o
$(GCOV_OUTPUT)
@
rm
-f
$(TEST_DIR)
/main_test.c
*
.o
$(GCOV_OUTPUT)
;
\
if
[
-f
"libcraft.
$(SHAREDEXT)
"
]
;
then
rm
libcraft.
$(SHAREDEXT)
;
fi
;
\
if
[
-f
libcraft.a
]
;
then
rm
libcraft.a
;
fi
;
\
if
[
-f
tests_main
]
;
then
rm
tests_main
;
fi
;
include/raft_log.h
View file @
1d7aa60f
...
...
@@ -6,6 +6,8 @@ typedef void* log_t;
log_t
*
log_new
();
void
log_free
(
log_t
*
me_
);
int
log_append_entry
(
log_t
*
me_
,
raft_entry_t
*
c
);
int
log_count
(
log_t
*
me_
);
...
...
@@ -14,6 +16,8 @@ raft_entry_t* log_get_from_idx(log_t* me_, int idx);
raft_entry_t
*
log_peektail
(
log_t
*
me_
);
void
log_mark_peer_has_committed
(
log_t
*
me_
,
int
idx
);
void
log_mark_node_has_committed
(
log_t
*
me_
,
int
idx
);
void
log_delete
(
log_t
*
me_
,
int
idx
);
#endif
/* RAFT_LOG_H_ */
include/raft_private.h
View file @
1d7aa60f
...
...
@@ -99,10 +99,12 @@ int raft_apply_entry(raft_server_t* me_);
int
raft_append_entry
(
raft_server_t
*
me_
,
raft_entry_t
*
c
);
void
raft_set_commit_idx
(
raft_server_t
*
me
,
int
commit_idx
);
int
raft_get_commit_idx
(
raft_server_t
*
me_
);
void
raft_set_last_applied_idx
(
raft_server_t
*
me
,
int
idx
);
void
raft_set_state
(
raft_server_t
*
me_
,
int
state
);
int
raft_get_state
(
raft_server_t
*
me_
);
raft_node_t
*
raft_node_new
(
void
*
udata
);
...
...
tests/make-tests.sh
View file @
1d7aa60f
...
...
@@ -23,7 +23,7 @@ cat $FILES | grep '^void Test' |
-e
's/$/(CuTest*);/'
\
-e
's/^/extern /'
echo
-n
\
echo
\
'
void RunAllTests(void)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment