diff --git a/Makefile b/Makefile index 26e1a8d5..a2c70a42 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ clean-devel: clean -rm -rf _build clean: + -rm -f .build_date ./rebar3 clean compile: @@ -16,14 +17,17 @@ test: ./rebar3 xref ./rebar3 eunit ./rebar3 cover - ./covertool -cover _build/test/cover/eunit.coverdata -appname ephp -output cobertura.xml + ./covertool \ + -cover _build/test/cover/eunit.coverdata \ + -appname ephp \ + -output cobertura.xml ephp: compile ./rebar3 escriptize cp -f _build/default/bin/ephp . + -rm -f .build_date shell: ./rebar3 shell .PHONY: doc test compile all shell - diff --git a/rebar.config.script b/rebar.config.script index 3e9d609a..f7defdfc 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -1,9 +1,12 @@ -ErlOpts = proplists:get_value(erl_opts, CONFIG), -case lists:filter(fun({d, 'BUILD_DATE', _}) -> true; (_) -> false end, ErlOpts) of - [] -> - OldErlOpts = [{erl_opts, ErlOpts}], - NewErlOpts = [{erl_opts, [{d, 'BUILD_DATE', {date(), time()}}|ErlOpts]}], - (CONFIG -- OldErlOpts) ++ NewErlOpts; - [_] -> - CONFIG -end. +case filelib:is_regular(".build_date") of + true -> ok; + false -> os:cmd("LANG=POSIX date '+%b %d %Y %T' > .build_date") +end, +BuildDate = binary_to_list(element(2,file:read_file(".build_date"))), +ErlOpts = lists:filter(fun + ({d, 'BUILD_DATE', _}) -> false; + (_) -> true +end, proplists:get_value(erl_opts, CONFIG)), +OldErlOpts = [{erl_opts, ErlOpts}], +NewErlOpts = [{erl_opts, [{d, 'BUILD_DATE', BuildDate}|ErlOpts]}], +(CONFIG -- OldErlOpts) ++ NewErlOpts. diff --git a/src/ephp_lib_info.erl b/src/ephp_lib_info.erl index ae13ddaf..2927c52b 100644 --- a/src/ephp_lib_info.erl +++ b/src/ephp_lib_info.erl @@ -93,14 +93,4 @@ get_vsn() -> -spec get_build_date() -> binary(). get_build_date() -> - {{Y,M,D},{H,I,S}} = ?BUILD_DATE, - Month = ephp_datetime:get_abbr_month(M), - Day = ephp_data:pad_to_bin(D,2), - Year = integer_to_binary(Y), - Hour = ephp_data:pad_to_bin(H,2), - Min = ephp_data:pad_to_bin(I,2), - Sec = ephp_data:pad_to_bin(S,2), - << - Month/binary, " ", Day/binary, " ", Year/binary, " ", - Hour/binary, ":", Min/binary, ":", Sec/binary - >>. + list_to_binary(?BUILD_DATE).