123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- # Core: Compatibility with other build tools.
- #
- # Note: autopatch functionality is covered separately.
- CORE_COMPAT_TARGETS = $(call list_targets,core-compat)
- REBAR_BINARY = https://github.com/rebar/rebar/releases/download/2.6.0/rebar
- REBAR3_BINARY = https://s3.amazonaws.com/rebar3/rebar3
- .PHONY: core-compat $(CORE_COMPAT_TARGETS)
- core-compat: $(CORE_COMPAT_TARGETS)
- core-compat-auto-rebar: init
- $i "Bootstrap a new OTP library named $(APP)"
- $t mkdir $(APP)/
- $t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
- $i "Add rebar.config as a dependency of 'app' target"
- $t echo "app:: rebar.config" >> $(APP)/Makefile
- $i "Build the application"
- $t $(MAKE) -C $(APP) $v
- $i "Check that rebar.config was created"
- $t test -f $(APP)/rebar.config
- $i "Check that rebar.config can be loaded"
- $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
- $i "Create a temporary file"
- $t touch $(APP)/older_file
- $t $(SLEEP)
- $i "Build the application again"
- $t $(MAKE) -C $(APP) $v
- $i "Check that rebar.config is newer than the temporary file"
- $t test $(APP)/rebar.config -nt $(APP)/older_file
- $i "Check that rebar.config can be loaded"
- $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
- $i "Distclean the application"
- $t $(MAKE) -C $(APP) distclean $v
- $i "Download rebar"
- $t curl -s -L -o $(APP)/rebar $(REBAR_BINARY)
- $t chmod +x $(APP)/rebar
- $i "Use rebar to build the application"
- $t cd $(APP) && ./rebar compile $v
- core-compat-rebar: init
- $i "Bootstrap a new OTP library named $(APP)"
- $t mkdir $(APP)/
- $t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
- $i "Run 'make rebar.config'"
- $t $(MAKE) -C $(APP) rebar.config $v
- $i "Check that rebar.config was created"
- $t test -f $(APP)/rebar.config
- $i "Check that rebar.config can be loaded"
- $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
- $i "Create a temporary file"
- $t touch $(APP)/older_file
- $t $(SLEEP)
- $i "Run 'make rebar.config' again"
- $t $(MAKE) -C $(APP) rebar.config $v
- $i "Check that rebar.config is newer than the temporary file"
- $t test $(APP)/rebar.config -nt $(APP)/older_file
- $i "Check that rebar.config can be loaded"
- $t $(ERL) -eval "{ok, _} = file:consult(\"$(APP)/rebar.config\"), halt()"
- $i "Distclean the application"
- $t $(MAKE) -C $(APP) distclean $v
- $i "Download rebar"
- $t curl -s -L -o $(APP)/rebar $(REBAR_BINARY)
- $t chmod +x $(APP)/rebar
- $i "Use rebar to build the application"
- $t cd $(APP) && ./rebar compile $v
- core-compat-rebar-deps-git: init
- $i "Bootstrap a new OTP library named $(APP)"
- $t mkdir $(APP)/
- $t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
- $i "Add Cowboy as a dependency"
- $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy = git https://github.com/ninenines/cowboy 1.0.0\n"}' $(APP)/Makefile
- $i "Run 'make rebar.config'"
- $t $(MAKE) -C $(APP) rebar.config $v
- $i "Check that rebar.config was created"
- $t test -f $(APP)/rebar.config
- $i "Check that Cowboy is listed in rebar.config"
- $t $(ERL) -eval " \
- {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
- {_, [{cowboy, _, {git, _, \"1.0.0\"}}]} = lists:keyfind(deps, 1, C), \
- halt()"
- $i "Distclean the application"
- $t $(MAKE) -C $(APP) distclean $v
- $i "Download rebar"
- $t curl -s -L -o $(APP)/rebar $(REBAR_BINARY)
- $t chmod +x $(APP)/rebar
- $i "Use rebar to build the application"
- $t cd $(APP) && ./rebar get-deps compile $v
- core-compat-rebar-deps-hex: init
- $i "Bootstrap a new OTP library named $(APP)"
- $t mkdir $(APP)/
- $t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
- $i "Add Cowboy as a dependency"
- $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\ndep_cowboy = hex 1.0.0\n"}' $(APP)/Makefile
- $i "Run 'make rebar.config'"
- $t $(MAKE) -C $(APP) rebar.config $v
- $i "Check that rebar.config was created"
- $t test -f $(APP)/rebar.config
- $i "Check that Cowboy is listed in rebar.config"
- $t $(ERL) -eval " \
- {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
- {_, [{cowboy, \"1.0.0\"}]} = lists:keyfind(deps, 1, C), \
- halt()"
- $i "Distclean the application"
- $t $(MAKE) -C $(APP) distclean $v
- $i "Download rebar3"
- $t curl -s -L -o $(APP)/rebar3 $(REBAR3_BINARY)
- $t chmod +x $(APP)/rebar3
- $i "Use rebar to build the application"
- $t cd $(APP) && ./rebar3 compile $v
- core-compat-rebar-deps-pkg: init
- $i "Bootstrap a new OTP library named $(APP)"
- $t mkdir $(APP)/
- $t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
- $i "Add Cowboy package as a dependency"
- $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = cowboy\n"}' $(APP)/Makefile
- $i "Run 'make rebar.config'"
- $t $(MAKE) -C $(APP) rebar.config $v
- $i "Check that rebar.config was created"
- $t test -f $(APP)/rebar.config
- $i "Check that Cowboy is listed in rebar.config"
- $t $(ERL) -eval " \
- {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
- {_, [{cowboy, _, {git, \"https://github.com/\" ++ _, _}}]} = lists:keyfind(deps, 1, C), \
- halt()"
- $i "Distclean the application"
- $t $(MAKE) -C $(APP) distclean $v
- $i "Download rebar"
- $t curl -s -L -o $(APP)/rebar $(REBAR_BINARY)
- $t chmod +x $(APP)/rebar
- $i "Use rebar to build the application"
- $t cd $(APP) && ./rebar get-deps compile $v
- core-compat-rebar-erlc-opts: init
- $i "Bootstrap a new OTP library named $(APP)"
- $t mkdir $(APP)/
- $t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
- $i "Add extra options to ERLC_OPTS"
- $t echo "ERLC_OPTS += +warn_export_all +warn_missing_spec +warn_untyped_record" >> $(APP)/Makefile
- $i "Run 'make rebar.config'"
- $t $(MAKE) -C $(APP) rebar.config $v
- $i "Check that rebar.config was created"
- $t test -f $(APP)/rebar.config
- $i "Check that -Werror is not listed in rebar.config"
- $t $(ERL) -eval " \
- {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
- {_, Opts} = lists:keyfind(erl_opts, 1, C), \
- false = lists:member(warning_as_errors, Opts), \
- halt()"
- $i "Check that debug_info is listed in rebar.config"
- $t $(ERL) -eval " \
- {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
- {_, Opts} = lists:keyfind(erl_opts, 1, C), \
- true = lists:member(debug_info, Opts), \
- halt()"
- $i "Check that extra options are listed in rebar.config"
- $t $(ERL) -eval " \
- {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
- {_, Opts} = lists:keyfind(erl_opts, 1, C), \
- true = lists:member(warn_export_all, Opts), \
- true = lists:member(warn_missing_spec, Opts), \
- true = lists:member(warn_untyped_record, Opts), \
- halt()"
- $i "Distclean the application"
- $t $(MAKE) -C $(APP) distclean $v
- $i "Download rebar"
- $t curl -s -L -o $(APP)/rebar $(REBAR_BINARY)
- $t chmod +x $(APP)/rebar
- $i "Use rebar to build the application"
- $t cd $(APP) && ./rebar compile $v
- core-compat-rebar-pt: init
- $i "Bootstrap a new OTP library named $(APP)"
- $t mkdir $(APP)/
- $t cp ../erlang.mk $(APP)/
- $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
- $i "Generate .erl files"
- $t echo "-module(boy)." > $(APP)/src/boy.erl
- $t echo "-module(girl)." > $(APP)/src/girl.erl
- $i "Add lager to the list of dependencies"
- $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = lager\n"}' $(APP)/Makefile
- $i "Add the lager_transform parse_transform to ERLC_OPTS"
- $t echo "ERLC_OPTS += +'{parse_transform, lager_transform}' +'{lager_truncation_size, 1234}'" >> $(APP)/Makefile
- $i "Build the application"
- $t $(MAKE) -C $(APP) $v
- $i "Run 'make rebar.config'"
- $t $(MAKE) -C $(APP) rebar.config $v
- $i "Check that rebar.config was created"
- $t test -f $(APP)/rebar.config
- $i "Check that the parse_transform option is listed in rebar.config"
- $t $(ERL) -eval " \
- {ok, C} = file:consult(\"$(APP)/rebar.config\"), \
- {_, Opts} = lists:keyfind(erl_opts, 1, C), \
- true = lists:member({parse_transform, lager_transform}, Opts), \
- true = lists:member({lager_truncation_size, 1234}, Opts), \
- halt()"
- # For the new build method, we have to simulate keeping the .app file
- # inside the repository, by leaving it in the ebin/ directory before
- # calling Rebar.
- ifndef LEGACY
- $i "Move the .app file outside ebin/"
- $t mv $(APP)/ebin/$(APP).app $(APP)/
- endif
- $i "Distclean the application"
- $t $(MAKE) -C $(APP) distclean $v
- ifndef LEGACY
- $i "Put the .app file back into ebin/"
- $t mkdir $(APP)/ebin/
- $t mv $(APP)/$(APP).app $(APP)/ebin/
- endif
- $i "Download rebar"
- $t curl -s -L -o $(APP)/rebar $(REBAR_BINARY)
- $t chmod +x $(APP)/rebar
- $i "Use rebar to build the application"
- $t cd $(APP) && ./rebar get-deps compile $v
- $i "Check that all compiled files exist"
- $t test -f $(APP)/ebin/$(APP).app
- $t test -f $(APP)/ebin/boy.beam
- $t test -f $(APP)/ebin/girl.beam
|