From 3bb13593695d1db50885588cd96e1be85f5a8e45 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 22 Jun 2010 03:21:28 +0200 Subject: Added header and option support to Erlang CMake build --- cmake/erlang/ErlangTarget.cmake | 40 +++++++++++++++++++++++++--------------- src/core/CMakeLists.txt | 2 ++ src/core/ephraim.erl | 3 ++- src/core/ephraim_roster.erl | 9 ++++++--- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/cmake/erlang/ErlangTarget.cmake b/cmake/erlang/ErlangTarget.cmake index cfcc431..3a21800 100644 --- a/cmake/erlang/ErlangTarget.cmake +++ b/cmake/erlang/ErlangTarget.cmake @@ -1,25 +1,35 @@ macro(erl_target name) - set(in_files "") + parse_arguments(ARGS "HEADERS;OPTIONS" "" ${ARGN}) + + set(headers "") set(out_files "") - foreach(src ${ARGN}) - list(APPEND in_files "${CMAKE_CURRENT_SOURCE_DIR}/${src}") + foreach(header ${ARGS_HEADERS}) + list(APPEND headers "${CMAKE_CURRENT_SOURCE_DIR}/${header}") + endforeach(header ${ARGS_HEADERS}) + + foreach(src ${ARGS_DEFAULT_ARGS}) + set(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${src}") string(REPLACE ".erl" ".beam" src ${src}) set(out_file "${CMAKE_CURRENT_BINARY_DIR}/${src}") + + add_custom_command( + OUTPUT + ${out_file} + COMMAND + ${ERLC_EXECUTABLE} + ARGS + "-o" ${CMAKE_CURRENT_BINARY_DIR} + ${ARGS_OPTIONS} + ${in_file} + DEPENDS + ${in_file} + ${headers} + ) + list(APPEND out_files "${CMAKE_CURRENT_BINARY_DIR}/${src}") - endforeach(src ${ARGN}) + endforeach(src ${ARGS_DEFAULT_ARGS}) - add_custom_command( - OUTPUT - ${out_files} - COMMAND - ${ERLC_EXECUTABLE} - ARGS - "-o" ${CMAKE_CURRENT_BINARY_DIR} - ${in_files} - DEPENDS - ${in_files} - ) add_custom_target( ${name} ALL DEPENDS ${out_files} ) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index b0ab82c..792f279 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -4,4 +4,6 @@ erl_target(ephraim-core ephraim_conv.erl ephraim_roster.erl ephraim_util.erl +OPTIONS + +debug_info ) diff --git a/src/core/ephraim.erl b/src/core/ephraim.erl index dc8382d..523749c 100644 --- a/src/core/ephraim.erl +++ b/src/core/ephraim.erl @@ -10,7 +10,8 @@ -spec start() -> ok. start() -> - spawn(?MODULE, init, []). + spawn(?MODULE, init, []), + ok. -spec stop() -> ok. stop() -> diff --git a/src/core/ephraim_roster.erl b/src/core/ephraim_roster.erl index 678a8c3..2998782 100644 --- a/src/core/ephraim_roster.erl +++ b/src/core/ephraim_roster.erl @@ -9,13 +9,14 @@ -record(roster_entry, { name :: binary() | undefined, subscription :: atom() | undefined, + groups :: set(), resources :: dict() }). -record(resource_entry, { priority :: integer(), show :: atom(), - status :: string() + status :: binary() }). @@ -23,7 +24,7 @@ init() -> loop(#roster{entries=dict:new()}). --spec updateResource(#roster{}, binary(), integer(), atom(), atom(), string()) -> #roster{}. +-spec updateResource(#roster{}, binary(), integer(), atom(), atom(), binary()) -> #roster{}. updateResource(Roster, JID, Priority, Type, Show, Status) -> {Node, Domain, Resource} = exmpp_jid:to_lower(exmpp_jid:parse(JID)), BareJID = list_to_binary([Node, <<"@">>, Domain]), @@ -58,7 +59,8 @@ updateRosterEntry(Roster, JID, Name, Subscription) -> error -> dict:new() end, - NewEntry = #roster_entry{subscription=Subscription,name=Name,resources=Resources}, + Groups = sets:new(), + NewEntry = #roster_entry{subscription=Subscription,name=Name,resources=Resources,groups=Groups}, Entries = dict:store(JID, NewEntry, Roster#roster.entries), ephraim ! {ui_update, {roster_update, JID, dict:to_list(Resources)}}, Roster#roster{entries=Entries}. @@ -101,6 +103,7 @@ loop(Roster) -> {roster_iq, Payload} -> Roster2 = handleRosterIQs(Roster, Payload#xmlel.children), + io:format("ephraim_roster: IQ: ~p~n", [Payload]), loop(Roster2); Msg -> -- cgit v1.2.3