Skip to content

Commit

Permalink
Update targets to properly handle -j (2600hz#5409)
Browse files Browse the repository at this point in the history
* make sure autogen'd files are compiled

* handle already started processes

* update targets to allow better -J
  • Loading branch information
jamesaimonetti authored and harenson committed Jan 11, 2019
1 parent d522e6d commit 450f688
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 46 deletions.
77 changes: 50 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,78 @@ CHANGED_SWAGGER := $(shell git --no-pager diff --name-only HEAD origin/master --
# to prevent parallel builds, or make JOBS="8".
JOBS ?= 1

KAZOODIRS = core/Makefile applications/Makefile

.PHONY: $(KAZOODIRS) kazoo deps core apps \
.PHONY: kazoo deps core apps \
apis \
build-release build-ci-release tar-release release read-release-cookie \
bump-copyright apis validate-swagger sdks coverage-report fs-headers docs validate-schemas \
bump-copyright \
circle \
clean clean-test clean-release \
dialyze dialyze-it dialyze-apps dialyze-core dialyze-kazoo dialyze-hard dialyze-changed \
elvis install ci diff \
fixture_shell code_checks \
clean clean-test clean-release clean-kazoo clean-core clean-apps \
code_checks \
coverage-report \
dialyze dialyze-apps dialyze-core dialyze-kazoo dialyze-hard dialyze-changed \
dialyze-it dialyze-it-hard dialyze-it-changed \
diff \
docs \
elvis \
fixture_shell \
fmt clean-fmt \
fs-headers \
install \
sdks \
validate-schemas \
validate-swagger \
xref xref_release

all: compile

compile: ACTION = all
compile: deps kazoo

$(KAZOODIRS):
@$(MAKE) -C $(@D) $(ACTION)

clean: ACTION = clean
clean: $(KAZOODIRS)
clean: clean-kazoo
$(if $(wildcard *crash.dump), rm *crash.dump)
$(if $(wildcard scripts/log/*), rm -rf scripts/log/*)
$(if $(wildcard rel/dev-vm.args), rm rel/dev-vm.args)
$(if $(wildcard $(FMT)), rm -r $(dir $(FMT)))
clean-kazoo: clean-core clean-apps
clean-core:
@$(MAKE) -j$(JOBS) -C core/ clean
clean-apps:
@$(MAKE) -j$(JOBS) -C applications/ clean

clean-test: clean-test-core clean-test-apps
clean-test-core:
@$(MAKE) -j$(JOBS) -C core/ clean-test
clean-test-apps:
@$(MAKE) -j$(JOBS) -C applications/ clean-test

clean-test: ACTION = clean-test
clean-test: $(KAZOODIRS)

clean-kazoo: ACTION = clean
clean-kazoo: $(KAZOODIRS)

compile-test: ACTION = compile-test
compile-test: ERLC_OPTS += +nowarn_missing_spec
compile-test: deps $(KAZOODIRS)
compile-test: deps compile-test-core compile-test-apps
compile-test-core:
@$(MAKE) -j$(JOBS) -C core/ compile-test
compile-test-apps:
@$(MAKE) -j$(JOBS) -C applications/ compile-test

eunit: eunit-core eunit-apps

eunit: ACTION = eunit
eunit: $(KAZOODIRS)
eunit-core:
@$(MAKE) -j$(JOBS) -C core/ eunit
eunit-apps:
@$(MAKE) -j$(JOBS) -C applications/ eunit

proper: ACTION = eunit
proper: ERLC_OPTS += -DPROPER
proper: $(KAZOODIRS)
proper: proper-core proper-apps
proper-core:
@$(MAKE) -j$(JOBS) -C core/ proper
proper-apps:
@$(MAKE) -j$(JOBS) -C applications/ proper

test: ACTION = test
test: ERLC_OPTS += -DPROPER
test: ERLC_OPTS += +nowarn_missing_spec
test: $(KAZOODIRS)
test: test-core test-apps
test-core:
@$(MAKE) -j$(JOBS) -C core/ test
test-apps:
@$(MAKE) -j$(JOBS) -C applications/ test

coverage-report:
$(ROOT)/scripts/cover.escript
Expand Down
2 changes: 2 additions & 0 deletions core/kazoo_documents/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ all: compile

compile: compile-autogen $(ERL_FILES)

compile-test: compile-autogen $(ERL_FILES)

compile-autogen: $(addsuffix -compile,$(SRC_FILES))

clean: clean-autogen
Expand Down
14 changes: 7 additions & 7 deletions core/kazoo_documents/test/kzd_test_fixtures.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
setup() ->
?LOG_DEBUG(":: Setting up Kazoo FixtureDB"),

{ok, _} = application:ensure_all_started(kazoo_config),
{'ok', _} = application:ensure_all_started('kazoo_config'),
kazoo_fixturedb:start().

cleanup(LinkPid) ->
_DataLink = erlang:exit(LinkPid, normal),
Ref = monitor(process, LinkPid),
_DataLink = erlang:exit(LinkPid, 'normal'),
Ref = monitor('process', LinkPid),
receive
{'DOWN', Ref, process, LinkPid, _Reason} ->
_KConfig = application:stop(kazoo_config),
{'DOWN', Ref, 'process', LinkPid, _Reason} ->
_KConfig = application:stop('kazoo_config'),
?LOG_DEBUG(":: Stopped Kazoo FixtureDB, data_link: ~p kazoo_config: ~p", [_DataLink, _KConfig])
after 1000 ->
_KConfig = application:stop(kazoo_config),
after ?MILLISECONDS_IN_SECOND ->
_KConfig = application:stop('kazoo_config'),
?LOG_DEBUG(":: Stopped Kazoo FixtureDB, data_link: timeout kazoo_config: ~p", [_KConfig])
end.
25 changes: 14 additions & 11 deletions core/kazoo_fixturedb/src/kz_fixturedb_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,31 @@ update_revision(JObj) ->
%%------------------------------------------------------------------------------
-spec start_me() -> pid().
start_me() ->
start_me(false).
start_me('false').

-spec start_me(boolean()) -> pid().
start_me(SilentLager) ->
?LOG_DEBUG(":: Starting up Kazoo FixtureDB"),
{ok, _} = application:ensure_all_started(kazoo_config),
{ok, Pid} = kazoo_data_link_sup:start_link(),
{'ok', _} = application:ensure_all_started('kazoo_config'),
Pid = case kazoo_data_link_sup:start_link() of
{'ok', P} -> P;
{'error', {'already_started', P}} -> P
end,
'ignore' = kazoo_data_bootstrap:start_link(),

_ = case SilentLager of
true ->
_ = lager:set_loglevel(lager_console_backend, none),
_ = lager:set_loglevel(lager_file_backend, none),
lager:set_loglevel(lager_syslog_backend, none);
false -> ok
'true' ->
_ = lager:set_loglevel('lager_console_backend', 'none'),
_ = lager:set_loglevel('lager_file_backend', 'none'),
lager:set_loglevel('lager_syslog_backend', 'none');
'false' -> 'ok'
end,
Pid.

-spec stop_me(pid()) -> ok.
-spec stop_me(pid()) -> 'ok'.
stop_me(Pid) ->
_ = erlang:exit(Pid, normal),
_ = application:stop(kazoo_config),
_ = erlang:exit(Pid, 'normal'),
_ = application:stop('kazoo_config'),
?LOG_DEBUG(":: Stopped Kazoo FixtureDB").

-spec get_doc_path(kz_term:ne_binary(), kz_term:ne_binary()) -> file:filename_all().
Expand Down
1 change: 0 additions & 1 deletion make/kz.mk
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ json: JSON = $(shell find . -name '*.json')
json:
@$(ROOT)/scripts/format-json.sh $(JSON)


compile-test: clean-test $(COMPILE_MOAR) test/$(PROJECT).app json

test/$(PROJECT).app: ERLC_OPTS += -DTEST
Expand Down

0 comments on commit 450f688

Please sign in to comment.