diff options
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | Makefile | 24 | ||||
-rw-r--r-- | core/deps.mk | 2 | ||||
-rw-r--r-- | doc/src/guide/installation.asciidoc | 12 | ||||
-rw-r--r-- | plugins/c_src.mk | 8 | ||||
-rw-r--r-- | test/Makefile | 229 |
6 files changed, 172 insertions, 109 deletions
@@ -1,6 +1,4 @@ doc/guide.pdf doc/html -test/app1/ -test/pkgs.log -test/temp-python/ -test/tmp/ +test/logs/ +test/packages/ @@ -25,18 +25,36 @@ all: | sed 's/^ERLANG_MK_VERSION = .*/ERLANG_MK_VERSION = $(ERLANG_MK_VERSION)/' > $(ERLANG_MK) ifdef p +# Remove p from the list of variables since that conflicts with bootstrapping. +MAKEOVERRIDES := $(filter-out p=$p,$(MAKEOVERRIDES)) + check: - $(MAKE) -C test pkg-$p + $(MAKE) -C test pkg-$p KEEP_BUILDS=1 else ifdef c check: - $(MAKE) -C test $c LEGACY=$(LEGACY) + $(MAKE) -C test $c else check: - $(MAKE) -C test LEGACY=$(LEGACY) + $(MAKE) -C test endif endif +packages: + $(MAKE) -C test packages + +summary: + @mkdir -p test/logs/ + @touch test/logs/latest.log test/packages/errors.log + -@sort test/packages/errors.log | diff test/logs/latest.log - + @sort test/packages/errors.log > test/logs/latest.log + @cp test/logs/latest.log "test/logs/$(subst $(empty) $(empty),_,$(shell date --rfc-3339 seconds))" + +search: + @$(MAKE) --no-print-directory \ + -f core/core.mk $(addprefix -f,$(wildcard index/*.mk)) -f core/index.mk \ + search + clean: $(MAKE) -C test clean rm -rf doc/guide.pdf doc/html diff --git a/core/deps.mk b/core/deps.mk index 18ae0f8..c70e751 100644 --- a/core/deps.mk +++ b/core/deps.mk @@ -151,6 +151,7 @@ define dep_autopatch_rebar endef define dep_autopatch_rebar.erl + application:load(rebar), application:set_env(rebar, log_level, debug), Conf1 = case file:consult("$(call core_native_path,$(DEPS_DIR)/$1/rebar.config)") of {ok, Conf0} -> Conf0; @@ -177,6 +178,7 @@ define dep_autopatch_rebar.erl Write("IGNORE_DEPS += edown eper eunit_formatters meck node_package " "rebar_lock_deps_plugin rebar_vsn_plugin reltool_util\n"), Write("C_SRC_DIR = /path/do/not/exist\n"), + Write("C_SRC_TYPE = rebar\n"), Write("DRV_CFLAGS = -fPIC\nexport DRV_CFLAGS\n"), Write(["ERLANG_ARCH = ", rebar_utils:wordsize(), "\nexport ERLANG_ARCH\n"]), fun() -> diff --git a/doc/src/guide/installation.asciidoc b/doc/src/guide/installation.asciidoc index 94232b8..f03dafa 100644 --- a/doc/src/guide/installation.asciidoc +++ b/doc/src/guide/installation.asciidoc @@ -43,8 +43,9 @@ if you need additional references. You can install Erlang/OTP silently using the `/S` switch on the command line: -[source,batch] +---- C:\Users\essen\Downloads> otp_win64_18.0.exe /S +---- ==== Installing MSYS2 @@ -66,16 +67,18 @@ and extract it under 'C:\'. Assuming you downloaded the archive as 'msys2.tar.xz' and put it in 'C:\', you can use the following commands to extract it: -[source,batch] +---- C:\> 7z x msys2.tar.xz C:\> 7z x msys2.tar > NUL +---- Then you can run the two commands needed to perform the post-installation setup: -[source,batch] +---- C:\> C:\msys64\usr\bin\bash -lc "pacman --needed --noconfirm -Sy bash pacman pacman-mirrors msys2-runtime" C:\> C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syu" +---- ==== Installing the required MSYS2 packages @@ -96,8 +99,9 @@ You can also run commands under the MSYS2 environment from the Windows command line or batch files. This command will install GNU Make and Git: -[source,batch] +---- C:\> C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S git make" +---- You can use similar `bash` commands if you need to run programs inside the MSYS2 environment from a batch file. diff --git a/plugins/c_src.mk b/plugins/c_src.mk index 9fa8111..efe7bfe 100644 --- a/plugins/c_src.mk +++ b/plugins/c_src.mk @@ -32,10 +32,6 @@ CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR) LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei -ifeq ($(C_SRC_TYPE),shared) -LDFLAGS += -shared -endif - # Verbosity. c_verbose_0 = @echo " C " $(?F); @@ -77,7 +73,9 @@ test-build:: $(C_SRC_ENV) $(C_SRC_OUTPUT) $(C_SRC_OUTPUT): $(OBJECTS) $(verbose) mkdir -p priv/ - $(link_verbose) $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT) + $(link_verbose) $(CC) $(OBJECTS) \ + $(LDFLAGS) $(if $(filter $(C_SRC_TYPE),shared),-shared) $(LDLIBS) \ + -o $(C_SRC_OUTPUT) %.o: %.c $(COMPILE_C) $(OUTPUT_OPTION) $< diff --git a/test/Makefile b/test/Makefile index 20b2328..dc11ccd 100644 --- a/test/Makefile +++ b/test/Makefile @@ -79,11 +79,11 @@ else ifeq ($V,1) else ifeq ($V,2) t = @echo " TEST " $@; v = V=0 - i = @echo "== $@:" + i = @echo == $@: else t = v = V=1 - i = @echo "== $@:" + i = @echo == $@: endif # Main targets. @@ -93,7 +93,7 @@ endif all:: core clean:: clean-core - $t rm -f erl_crash.dump + $t rm -rf erl_crash.dump packages/ build: $i "Generate a bleeding edge Erlang.mk" @@ -177,6 +177,138 @@ core-help: build clean-core-help $i "Run 'make help' and check that it prints help" $t test -n "`$(MAKE) -C $(APP) help` | grep Usage" +# Packages. + +PACKAGES = $(foreach pkg,$(sort $(wildcard ../index/*.mk)),$(notdir $(basename $(pkg)))) + +packages: $(addprefix pkg-,$(PACKAGES)) + +define pkg_target +.PHONY: pkg-$1 + +pkg-$1: clean build + +# Make sure $@ is defined inside the define. + $(eval @ = pkg-$1) + +# Get the real application's name. + $(eval APP_NAME = `sed '2!d;s/pkg_$1_name = //' ../index/$1.mk`) + + $i "Bootstrap a new OTP library in packages/$1_pkg" + $t mkdir -p packages/$1_pkg/ + $t cp ../erlang.mk packages/$1_pkg/ + $t cd packages/$1_pkg/ && $(MAKE) -f erlang.mk bootstrap-lib $v + + $i "Add package $1 to the Makefile" + $t perl -ni.bak -e 'print;if ($$$$.==1) {print "DEPS = $1\n"}' packages/$1_pkg/Makefile + + $(if $(filter amqp_client,$1), + $i "Set RABBITMQ_CLIENT_PATCH" + $(eval PATCHES := RABBITMQ_CLIENT_PATCH=1)) + + $(if $(filter rabbit,$1), + $i "Set RABBITMQ_SERVER_PATCH" + $(eval PATCHES := RABBITMQ_SERVER_PATCH=1)) + + $i "Compile package $1" + $t if ! ( cd packages/$1_pkg/ && $(MAKE) $(PATCHES) $v ); then \ + echo "$1: compile error" >> packages/errors.log; \ + false; \ + fi + + $i "Check that $1 has a .app file" + $t if ! test -f packages/$1_pkg/deps/$(APP_NAME)/ebin/$(APP_NAME).app; then \ + echo "$1: no .app file" >> packages/errors.log; \ + false; \ + fi + + $i "Check that all applications and their modules can be loaded" + $t if ! ( cd packages/$1_pkg/ && $(ERL) -pa deps/*/ebin/ -eval " \ + Apps = [list_to_atom(App) || \"deps/\" ++ App \ + <- filelib:wildcard(\"deps/*\")], \ + [begin \ + io:format(\"Loading application ~p~n\", [App]), \ + case application:load(App) of \ + ok -> ok; \ + {error, {already_loaded, App}} -> ok \ + end, \ + {ok, Mods} = application:get_key(App, modules), \ + [try io:format(\" Loading module ~p~n\", [Mod]), \ + {module, Mod} = code:load_file(Mod) \ + catch C:R -> timer:sleep(500), erlang:C(R) \ + end || Mod <- Mods] \ + end || App <- Apps], \ + halt()." ); then \ + echo "$1: load error" >> packages/errors.log; \ + false; \ + fi + + $i "Recompile package $1" + $t if ! ( cd packages/$1_pkg/ && $(MAKE) $(PATCHES) $v ); then \ + echo "$(1): recompile error" >> packages/errors.log; \ + false; \ + fi + + $i "Check that $1 has a .app file" + $t if ! test -f packages/$1_pkg/deps/$(APP_NAME)/ebin/$(APP_NAME).app; then \ + echo "$1: no .app file" >> packages/errors.log; \ + false; \ + fi + + $i "Check that all applications and their modules can still be loaded" + $t if ! ( cd packages/$1_pkg/ && $(ERL) -pa deps/*/ebin/ -eval " \ + Apps = [list_to_atom(App) || \"deps/\" ++ App \ + <- filelib:wildcard(\"deps/*\")], \ + [begin \ + io:format(\"Loading application ~p~n\", [App]), \ + case application:load(App) of \ + ok -> ok; \ + {error, {already_loaded, App}} -> ok \ + end, \ + {ok, Mods} = application:get_key(App, modules), \ + [try io:format(\" Loading module ~p~n\", [Mod]), \ + {module, Mod} = code:load_file(Mod) \ + catch C:R -> timer:sleep(500), erlang:C(R) \ + end || Mod <- Mods] \ + end || App <- Apps], \ + halt()." ); then \ + echo "$1: recompile+load error" >> packages/errors.log; \ + false; \ + fi + + $i "Check that no erl_crash.dump file exists" + $t if ( ! find packages/$1_pkg/ -type f -name erl_crash.dump ); then \ + echo "$(1): erl_crash.dump found" >> packages/errors.log; \ + fi + + $(if $(KEEP_BUILDS),, + $i "OK; delete the build directory" + $t rm -rf packages/$1_pkg/) +endef + +$(foreach pkg,$(PACKAGES),$(eval $(call pkg_target,$(pkg)))) + +################## + +# Test application used for testing. +app1: + $(call app1_setup) + +# Extra module in app1 used for testing eunit +define create-module-t +printf '%s\n' \ + '-module(t).' \ + '-export([succ/1]).' \ + 'succ(N) -> N + 1.' \ + '-ifdef(TEST).' \ + '-include_lib("eunit/include/eunit.hrl").' \ + 'succ_test() ->' \ + ' ?assertEqual(2, succ(1)),' \ + ' os:cmd("echo t >> test-eunit.log").' \ + '-endif.' \ + > app1/src/t.erl +endef + # Legacy tests. # # The following tests are slowly being converted. @@ -187,7 +319,7 @@ core-help: build clean-core-help legacy: clean-legacy ct eunit tests-cover docs pkgs clean-legacy: - $t rm -rf app1 pkgs.log + $t rm -rf app1 ct: app1 $i "ct: Testing ct and related targets." @@ -338,92 +470,3 @@ define app1_setup "succ(N) -> N + 1." \ > app1/src/m.erl endef - -define pkg_test_target -pkg-$(1)-clean: - $t rm -rf app1 erl_crash.dump - -pkg-$(1)-app1: - $(call app1_setup) - -# Running 'make' twice to make sure it recompiles fine. -pkg-$(1): pkg-$(1)-clean pkg-$(1)-app1 - $i - $i " pkgs: Checking that '$(1)' builds correctly" - $i - $t printf "%s\n" \ - "PROJECT = app1" \ - "DEPS = $(1)" \ - "include erlang.mk" \ - > app1/Makefile - $t \ - if [ "$(1)" = "amqp_client" ]; then \ - $(MAKE) -C app1 RABBITMQ_CLIENT_PATCH=1; \ - elif [ "$(1)" = "rabbit" ]; then \ - $(MAKE) -C app1 RABBITMQ_SERVER_PATCH=1; \ - else \ - $(MAKE) -C app1; \ - fi; \ - if [ $$$$? -ne 0 ]; then \ - echo "$(1): make error" >> pkgs.log; \ - else \ - $(MAKE) -C app1; if [ $$$$? -ne 0 ]; then \ - echo "$(1): re-make error" >> pkgs.log; \ - else \ - find . -type f -name erl_crash.dump; if [ $$$$? -ne 0 ]; then \ - echo "$(1): erl_crash.dump found" >> pkgs.log; \ - else \ - erl +A0 -noinput -boot start_clean -pa app1/deps/*/ebin -eval " \ - Apps = [list_to_atom(App) || \"app1/deps/\" ++ App \ - <- filelib:wildcard(\"app1/deps/*\")], \ - [begin \ - io:format(\"Loading application ~p~n\", [App]), \ - case application:load(App) of \ - {error, _} -> ok; \ - ok -> \ - {ok, Mods} = application:get_key(App, modules), \ - [try io:format(\" Loading module ~p~n\", [Mod]), \ - {module, Mod} = code:load_file(Mod) \ - catch C:R -> timer:sleep(500), erlang:C(R) \ - end || Mod <- Mods] \ - end \ - end || App <- Apps], \ - halt()."; if [ $$$$? -ne 0 ]; then \ - echo "$(1): load error" >> pkgs.log; \ - fi \ - fi \ - fi \ - fi -endef - -PACKAGES = $(foreach pkg,$(sort $(wildcard ../index/*.mk)),$(notdir $(basename $(pkg)))) - -$(foreach pkg,$(PACKAGES),$(eval $(call pkg_test_target,$(pkg)))) - -pkgs: $(addprefix pkg-,$(PACKAGES)) - @if [ -f pkgs.log ]; then \ - echo "+-------------------------------+"; \ - echo "| ERRORS WHILE TESTING PACKAGES |"; \ - echo "+-------------------------------+"; \ - cat pkgs.log; \ - exit 33; \ - fi - -# Test application used for testing. -app1: - $(call app1_setup) - -# Extra module in app1 used for testing eunit -define create-module-t -printf '%s\n' \ - '-module(t).' \ - '-export([succ/1]).' \ - 'succ(N) -> N + 1.' \ - '-ifdef(TEST).' \ - '-include_lib("eunit/include/eunit.hrl").' \ - 'succ_test() ->' \ - ' ?assertEqual(2, succ(1)),' \ - ' os:cmd("echo t >> test-eunit.log").' \ - '-endif.' \ - > app1/src/t.erl -endef |