Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An attempt to optionally use the compile server in erlc. #902

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions core/erlc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ makedep_verbose_0 = @echo " DEPEND" $(PROJECT).d;
makedep_verbose_2 = set -x;
makedep_verbose = $(makedep_verbose_$(V))

ifeq ($(ERLC_USE_SERVER), true)
erlc_verbose_0 = @echo " ERLC " $(filter-out $(patsubst %,%.erl,$(ERLC_EXCLUDE)),\
$(filter %.erl %.core,$(^F)));
else
erlc_verbose_0 = @echo " ERLC " $(filter-out $(patsubst %,%.erl,$(ERLC_EXCLUDE)),\
$(filter %.erl %.core,$(?F)));
endif
erlc_verbose_2 = set -x;
erlc_verbose = $(erlc_verbose_$(V))

Expand Down Expand Up @@ -84,14 +89,17 @@ define app_file
endef
endif

ifneq ($(ERLC_USE_SERVER), true)
app-build: ebin/$(PROJECT).app
$(verbose) :
endif

# Source files.

ALL_SRC_FILES := $(sort $(call core_find,src/,*))

ERL_FILES := $(filter %.erl,$(ALL_SRC_FILES))
ORIG_ERL_FILES := $(ERL_FILES)
CORE_FILES := $(filter %.core,$(ALL_SRC_FILES))

# ASN.1 files.
Expand Down Expand Up @@ -265,16 +273,25 @@ define makedep.erl
endef

ifeq ($(if $(NO_MAKEDEP),$(wildcard $(PROJECT).d),),)

ifeq ($(ERLC_USE_SERVER), true)
$(PROJECT).d:: $(ERL_FILES) $(call core_find,include/,*.hrl) $(MAKEFILE_LIST)
erlc -M -MG $(if $(IS_DEP),$(filter-out -Werror,$(ERLC_OPTS)),$(ERLC_OPTS)) -o ebin/ \
-pa ebin/ -I include/ $(filter-out $(ERLC_EXCLUDE_PATHS),$(COMPILE_FIRST_PATHS) $(1)) $(ERL_FILES) > $@
else
$(PROJECT).d:: $(ERL_FILES) $(call core_find,include/,*.hrl) $(MAKEFILE_LIST)
$(makedep_verbose) $(call erlang,$(call makedep.erl,$@))
endif

endif

ifeq ($(IS_APP)$(IS_DEP),)
ifneq ($(words $(ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES)),0)
ORIG_ERL_FILES = $(filter-out $(GENERATED_ERL_FILES), $(ERL_FILES))
ifneq ($(words $(ORIG_ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES)),0)
# Rebuild everything when the Makefile changes.
$(ERLANG_MK_TMP)/last-makefile-change: $(MAKEFILE_LIST) | $(ERLANG_MK_TMP)
$(verbose) if test -f $@; then \
touch $(ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES); \
touch $(ORIG_ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES); \
touch -c $(PROJECT).d; \
fi
$(verbose) touch $@
Expand Down Expand Up @@ -306,9 +323,22 @@ define validate_app_file
end
endef

ifeq ($(ERLC_USE_SERVER), true)
ebin/%.beam: src/%.erl
$(verbose) mkdir -p $(dir $@)
$(call compile_erl, $<)

ERL_BEAM_FILES += $(patsubst src/%.erl, ebin/%.beam, $(ERL_FILES))

app:: $(ERL_BEAM_FILES)
app-build: ebin/$(PROJECT).app $(ERL_BEAM_FILES)
endif

ebin/$(PROJECT).app:: $(ERL_FILES) $(CORE_FILES) $(wildcard src/$(PROJECT).app.src)
$(eval FILES_TO_COMPILE := $(filter-out src/$(PROJECT).app.src,$?))
ifneq ($(ERLC_USE_SERVER), true)
$(if $(strip $(FILES_TO_COMPILE)),$(call compile_erl,$(FILES_TO_COMPILE)))
endif
# Older git versions do not have the --first-parent flag. Do without in that case.
$(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null \
|| git describe --dirty --abbrev=7 --tags --always 2>/dev/null || true))
Expand Down
2 changes: 1 addition & 1 deletion plugins/eunit.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ eunit: test-build cover-data-dir
$(gen_verbose) $(call erlang,$(call eunit.erl,fun $(t)/0),$(EUNIT_ERL_OPTS))
endif
else
EUNIT_EBIN_MODS = $(notdir $(basename $(ERL_FILES) $(BEAM_FILES)))
EUNIT_EBIN_MODS = $(notdir $(basename $(ORIG_ERL_FILES) $(BEAM_FILES)))
EUNIT_TEST_MODS = $(notdir $(basename $(call core_find,$(TEST_DIR)/,*.erl)))

EUNIT_MODS = $(foreach mod,$(EUNIT_EBIN_MODS) $(filter-out \
Expand Down