Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85823332
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/Makefile b/Makefile
index e7d221f..4eeb8d3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,102 +1,52 @@
MIX = mix
-MYHTML_WORKER_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
+CNODE_CFLAGS = -g -O2 -std=c99 -pedantic -Wcomment -Wextra -Wno-old-style-declaration -Wall
+
# ignore unused parameter warnings
-MYHTML_WORKER_CFLAGS += -Wno-unused-parameter
+CNODE_CFLAGS += -Wno-unused-parameter
# 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)
-MYHTML_WORKER_CFLAGS += -I$(ERLANG_PATH)/include
+CNODE_CFLAGS += -I$(ERLANG_PATH)/include
# expecting myhtml as a submodule in c_src/
# that way we can pin a version and package the whole thing in hex
# hex does not allow for non-app related dependencies.
MYHTML_PATH = c_src/myhtml
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
-MYHTML_WORKER_CFLAGS += -lpthread
-
-# that would be used for a dynamically linked build
-# MYHTML_WORKER_CFLAGS += -L$(MYHTML_PATH)/lib
-
-MYHTML_WORKER_LDFLAGS = -shared
+CNODE_CFLAGS += -lpthread
# C-Node
ERL_INTERFACE = $(wildcard $(ERLANG_PATH)/../lib/erl_interface-*)
-CNODE_CFLAGS = $(MYHTML_WORKER_CFLAGS)
CNODE_CFLAGS += -L$(ERL_INTERFACE)/lib
CNODE_CFLAGS += -I$(ERL_INTERFACE)/include
CNODE_LDFLAGS =
ifeq ($(OTP22_DEF),YES)
CNODE_CFLAGS += -DOTP_22_OR_NEWER
else
CNODE_LDFLAGS += -lerl_interface
endif
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
-all: myhtmlex
-
-myhtmlex: priv/myhtml_worker
- $(MIX) compile
+all: priv/myhtml_worker
$(MYHTML_STATIC): $(MYHTML_PATH)
$(MAKE) -C $(MYHTML_PATH) library MyCORE_BUILD_WITHOUT_THREADS=YES
priv/myhtml_worker: c_src/myhtml_worker.c $(MYHTML_STATIC)
$(CC) -o $@ $< $(MYHTML_STATIC) $(CNODE_CFLAGS) $(CNODE_LDFLAGS)
clean: clean-myhtml
$(RM) -r priv/myhtmlex*
$(RM) priv/myhtml_worker
$(RM) myhtmlex-*.tar
$(RM) -r package-test
clean-myhtml:
$(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 $< .
-
diff --git a/mix.exs b/mix.exs
index f54e364..9e28b0b 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,138 +1,153 @@
defmodule FastHTML.Mixfile do
use Mix.Project
def project do
[
app: :fast_html,
version: "0.2.1",
elixir: "~> 1.5",
deps: deps(),
package: package(),
- compilers: [:my_html_worker_make] ++ Mix.compilers(),
+ compilers: [:fast_html_cnode_make] ++ Mix.compilers(),
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
name: "FastHTML",
description: """
A module to decode HTML into a tree,
porting all properties of the underlying
library myhtml, being fast and correct
in regards to the html spec.
Originally based on Myhtmlex.
""",
docs: docs()
]
end
def package do
[
maintainers: ["Ariadne Conill"],
licenses: ["GNU LGPL"],
links: %{
"GitLab" => "https://git.pleroma.social/pleroma/fast_html",
"Issues" => "https://git.pleroma.social/pleroma/fast_html/issues",
"MyHTML" => "https://github.com/lexborisov/myhtml"
},
files: [
"lib",
"c_src",
"priv/.gitignore",
"test",
"Makefile",
"mix.exs",
"README.md",
"LICENSE"
]
]
end
def application do
[
extra_applications: [:logger],
mod: {Myhtmlex.Safe, []},
# used to detect conflicts with other applications named processes
registered: [Myhtmlex.Safe.Cnode, Myhtmlex.Safe.Supervisor],
env: [
mode: Myhtmlex.Safe
]
]
end
defp deps do
[
# documentation helpers
{:ex_doc, ">= 0.0.0", only: :dev},
# benchmarking helpers
{:benchfella, "~> 0.3.0", only: :dev},
# cnode helpers
{:nodex,
git: "https://git.pleroma.social/pleroma/nodex",
ref: "cb6730f943cfc6aad674c92161be23a8411f15d1"}
]
end
defp docs do
[
main: "FastHTML"
]
end
end
-defmodule Mix.Tasks.Compile.MyHtmlWorkerMake do
+defmodule Mix.Tasks.Compile.FastHtmlCnodeMake do
@artifacts [
"priv/myhtml_worker"
]
def find_make do
_make_cmd =
System.get_env("MAKE") ||
case :os.type() do
{:unix, :freebsd} -> "gmake"
{:unix, :openbsd} -> "gmake"
{:unix, :netbsd} -> "gmake"
{:unix, :dragonfly} -> "gmake"
_ -> "make"
end
end
defp otp_version do
:erlang.system_info(:otp_release)
|> to_string()
|> String.to_integer()
end
defp otp_22_or_newer? do
otp_version() >= 22
end
def run(_) do
make_cmd = find_make()
- if match?({:win32, _}, :os.type()) do
- IO.warn("Windows is not yet a target.")
- exit(1)
- else
- {result, _error_code} =
- System.cmd(
- make_cmd,
- @artifacts,
- stderr_to_stdout: true,
- env: [
- {"MIX_ENV", to_string(Mix.env())},
- {"OTP22_DEF", (otp_22_or_newer?() && "YES") || "NO"}
- ]
- )
+ exit_code =
+ if match?({:win32, _}, :os.type()) do
+ IO.warn("Windows is not yet a target.")
+ 1
+ else
+ {result, exit_code} =
+ System.cmd(
+ make_cmd,
+ @artifacts,
+ stderr_to_stdout: true,
+ env: [
+ {"MIX_ENV", to_string(Mix.env())},
+ {"OTP22_DEF", (otp_22_or_newer?() && "YES") || "NO"}
+ ]
+ )
- IO.binwrite(result)
- end
+ IO.binwrite(result)
+ 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
def clean() do
make_cmd = find_make()
{result, _error_code} = System.cmd(make_cmd, ["clean"], stderr_to_stdout: true)
Mix.shell().info(result)
:ok
end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Oct 29, 4:18 AM (3 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1797528
Default Alt Text
(7 KB)
Attached To
Mode
R16 fast_html
Attached
Detach File
Event Timeline