Commit 692c1d2d authored by kaniini's avatar kaniini

Merge branch 'feature/makefile-simplify' into 'master'

Simplify the makefile since we don't have a NIF anymore

See merge request pleroma/myhtmlex!7
parents 73338a46 9f737d4b
Pipeline #19617 passed with stage
in 54 seconds
MIX = mix MIX = mix
MYHTML_WORKER_CFLAGS = -g -O2 -std=c99 -pedantic -Wcomment -Wextra -Wno-old-style-declaration -Wall CNODE_CFLAGS = -g -O2 -std=c99 -pedantic -Wcomment -Wextra -Wno-old-style-declaration -Wall
# we need to compile position independent code
MYHTML_WORKER_CFLAGS += -fpic -DPIC
# For some reason __erl_errno is undefined unless _REENTRANT is defined
MYHTML_WORKER_CFLAGS += -D_REENTRANT
# myhtmlex is using stpcpy, as defined in gnu string.h
# MYHTML_WORKER_CFLAGS += -D_GNU_SOURCE
# base on the same posix c source as myhtml
# MYHTML_WORKER_CFLAGS += -D_POSIX_C_SOURCE=199309
# turn warnings into errors
# MYHTML_WORKER_CFLAGS += -Werror
# ignore unused variables
# MYHTML_WORKER_CFLAGS += -Wno-unused-variable
# ignore unused parameter warnings # ignore unused parameter warnings
MYHTML_WORKER_CFLAGS += -Wno-unused-parameter CNODE_CFLAGS += -Wno-unused-parameter
# set erlang include path # set erlang include path
ERLANG_PATH = $(shell erl -eval 'io:format("~s", [lists:concat([code:root_dir(), "/erts-", erlang:system_info(version)])])' -s init stop -noshell) ERLANG_PATH = $(shell erl -eval 'io:format("~s", [lists:concat([code:root_dir(), "/erts-", erlang:system_info(version)])])' -s init stop -noshell)
MYHTML_WORKER_CFLAGS += -I$(ERLANG_PATH)/include CNODE_CFLAGS += -I$(ERLANG_PATH)/include
# expecting myhtml as a submodule in c_src/ # expecting myhtml as a submodule in c_src/
# that way we can pin a version and package the whole thing in hex # that way we can pin a version and package the whole thing in hex
# hex does not allow for non-app related dependencies. # hex does not allow for non-app related dependencies.
MYHTML_PATH = c_src/myhtml MYHTML_PATH = c_src/myhtml
MYHTML_STATIC = $(MYHTML_PATH)/lib/libmyhtml_static.a MYHTML_STATIC = $(MYHTML_PATH)/lib/libmyhtml_static.a
MYHTML_WORKER_CFLAGS += -I$(MYHTML_PATH)/include CNODE_CFLAGS += -I$(MYHTML_PATH)/include
# avoid undefined reference errors to phtread_mutex_trylock # avoid undefined reference errors to phtread_mutex_trylock
MYHTML_WORKER_CFLAGS += -lpthread CNODE_CFLAGS += -lpthread
# that would be used for a dynamically linked build
# MYHTML_WORKER_CFLAGS += -L$(MYHTML_PATH)/lib
MYHTML_WORKER_LDFLAGS = -shared
# C-Node # C-Node
ERL_INTERFACE = $(wildcard $(ERLANG_PATH)/../lib/erl_interface-*) ERL_INTERFACE = $(wildcard $(ERLANG_PATH)/../lib/erl_interface-*)
CNODE_CFLAGS = $(MYHTML_WORKER_CFLAGS)
CNODE_CFLAGS += -L$(ERL_INTERFACE)/lib CNODE_CFLAGS += -L$(ERL_INTERFACE)/lib
CNODE_CFLAGS += -I$(ERL_INTERFACE)/include CNODE_CFLAGS += -I$(ERL_INTERFACE)/include
...@@ -49,26 +32,9 @@ endif ...@@ -49,26 +32,9 @@ endif
CNODE_LDFLAGS += -lei -pthread CNODE_LDFLAGS += -lei -pthread
# enumerate docker build tests
BUILD_TESTS := $(patsubst %.dockerfile, %.dockerfile.PHONY, $(wildcard ./build-test/*.dockerfile))
# platform specific environment
UNAME = $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
MYHTML_WORKER_LDFLAGS += -dynamiclib -undefined dynamic_lookup
else
# myhtmlex is using stpcpy, as defined in gnu string.h
MYHTML_WORKER_CFLAGS += -D_GNU_SOURCE
# base on the same posix c source as myhtml
# MYHTML_WORKER_CFLAGS += -D_POSIX_C_SOURCE=199309
endif
.PHONY: all .PHONY: all
all: myhtmlex all: priv/myhtml_worker
myhtmlex: priv/myhtml_worker
$(MIX) compile
$(MYHTML_STATIC): $(MYHTML_PATH) $(MYHTML_STATIC): $(MYHTML_PATH)
$(MAKE) -C $(MYHTML_PATH) library MyCORE_BUILD_WITHOUT_THREADS=YES $(MAKE) -C $(MYHTML_PATH) library MyCORE_BUILD_WITHOUT_THREADS=YES
...@@ -84,19 +50,3 @@ clean: clean-myhtml ...@@ -84,19 +50,3 @@ clean: clean-myhtml
clean-myhtml: clean-myhtml:
$(MAKE) -C $(MYHTML_PATH) clean $(MAKE) -C $(MYHTML_PATH) clean
# publishing the package and docs separately is required
# otherwise the build artifacts are included in the package
# and the tarball gets too big to be published
publish: clean
$(MIX) hex.publish package
$(MIX) hex.publish docs
test:
$(MIX) test
build-tests: test $(BUILD_TESTS)
%.dockerfile.PHONY: %.dockerfile
docker build -f $< .
...@@ -8,7 +8,7 @@ defmodule FastHTML.Mixfile do ...@@ -8,7 +8,7 @@ defmodule FastHTML.Mixfile do
elixir: "~> 1.5", elixir: "~> 1.5",
deps: deps(), deps: deps(),
package: package(), package: package(),
compilers: [:my_html_worker_make] ++ Mix.compilers(), compilers: [:fast_html_cnode_make] ++ Mix.compilers(),
build_embedded: Mix.env() == :prod, build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod, start_permanent: Mix.env() == :prod,
name: "FastHTML", name: "FastHTML",
...@@ -78,7 +78,7 @@ defmodule FastHTML.Mixfile do ...@@ -78,7 +78,7 @@ defmodule FastHTML.Mixfile do
end end
end end
defmodule Mix.Tasks.Compile.MyHtmlWorkerMake do defmodule Mix.Tasks.Compile.FastHtmlCnodeMake do
@artifacts [ @artifacts [
"priv/myhtml_worker" "priv/myhtml_worker"
] ]
...@@ -108,25 +108,40 @@ defmodule Mix.Tasks.Compile.MyHtmlWorkerMake do ...@@ -108,25 +108,40 @@ defmodule Mix.Tasks.Compile.MyHtmlWorkerMake do
def run(_) do def run(_) do
make_cmd = find_make() make_cmd = find_make()
if match?({:win32, _}, :os.type()) do exit_code =
IO.warn("Windows is not yet a target.") if match?({:win32, _}, :os.type()) do
exit(1) IO.warn("Windows is not yet a target.")
else 1
{result, _error_code} = else
System.cmd( {result, exit_code} =
make_cmd, System.cmd(
@artifacts, make_cmd,
stderr_to_stdout: true, @artifacts,
env: [ stderr_to_stdout: true,
{"MIX_ENV", to_string(Mix.env())}, env: [
{"OTP22_DEF", (otp_22_or_newer?() && "YES") || "NO"} {"MIX_ENV", to_string(Mix.env())},
] {"OTP22_DEF", (otp_22_or_newer?() && "YES") || "NO"}
) ]
)
IO.binwrite(result) IO.binwrite(result)
end exit_code
end
:ok if exit_code == 0 do
:ok
else
{:error,
[
%Mix.Task.Compiler.Diagnostic{
compiler_name: "FastHTML Cnode",
message: "Make exited with #{exit_code}",
severity: :error,
file: nil,
position: nil
}
]}
end
end end
def clean() do def clean() do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment