Page MenuHomePhorge

No OneTemporary

Size
6 KB
Referenced Files
None
Subscribers
None
diff --git a/.gitignore b/.gitignore
index 2027581..cbb20b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,23 +1,24 @@
# The directory Mix will write compiled artifacts to.
/_build/
# If you run "mix test --cover", coverage assets end up here.
/cover/
# The directory Mix downloads your dependencies sources to.
/deps/
# Where 3rd-party dependencies like ExDoc output generated docs.
/doc/
# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch
# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump
# Also ignore archive artifacts (built via "mix archive.build").
*.ez
priv/*
!priv/.gitignore
bench/snapshots
+package-test
diff --git a/Makefile b/Makefile
index 8848d71..b0e89ce 100644
--- a/Makefile
+++ b/Makefile
@@ -1,73 +1,74 @@
MIX = mix
MYHTMLEX_CFLAGS = -g -O2 -std=c99 -pedantic -Wcomment -Wall
# we need to compile position independent code
MYHTMLEX_CFLAGS += -fpic -DPIC
# For some reason __erl_errno is undefined unless _REENTRANT is defined
MYHTMLEX_CFLAGS += -D_REENTRANT
# myhtmlex is using stpcpy, as defined in gnu string.h
# MYHTMLEX_CFLAGS += -D_GNU_SOURCE
# base on the same posix c source as myhtml
# MYHTMLEX_CFLAGS += -D_POSIX_C_SOURCE=199309
# turn warnings into errors
# MYHTMLEX_CFLAGS += -Werror
# ignore unused variables
# MYHTMLEX_CFLAGS += -Wno-unused-variable
# ignore unused parameter warnings
MYHTMLEX_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)
MYHTMLEX_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
MYHTMLEX_CFLAGS += -I$(MYHTML_PATH)/include
# that would be used for a dynamically linked build
# MYHTMLEX_CFLAGS += -L$(MYHTML_PATH)/lib
MYHTMLEX_LDFLAGS = -shared
# C-Node
ERL_INTERFACE = $(wildcard $(ERLANG_PATH)/../lib/erl_interface-*)
CNODE_CFLAGS = $(MYHTMLEX_CFLAGS)
CNODE_CFLAGS += -L$(ERL_INTERFACE)/lib
CNODE_CFLAGS += -I$(ERL_INTERFACE)/include
CNODE_CFLAGS += -lerl_interface -lei
# platform specific
UNAME = $(shell uname -s)
ifeq ($(wilcard Makefile.$(UNAME)),)
include Makefile.$(UNAME)
endif
.PHONY: all
all: myhtmlex
myhtmlex: priv/myhtmlex.so
$(MIX) compile
$(MYHTML_STATIC): $(MYHTML_PATH)
$(MAKE) -C $(MYHTML_PATH) library
priv/myhtmlex.so: c_src/myhtmlex.c $(MYHTML_STATIC)
$(CC) $(MYHTMLEX_CFLAGS) $(MYHTMLEX_LDFLAGS) -o $@ $< $(MYHTML_STATIC)
priv/cclient: c_src/cclient.c $(MYHTML_STATIC)
$(CC) $(CNODE_CFLAGS) -o $@ $< $(MYHTML_STATIC)
clean: clean-myhtml
$(RM) -r priv/myhtmlex*
$(RM) priv/cclient
$(RM) myhtmlex-*.tar
+ $(RM) -r package-test
clean-myhtml:
$(MAKE) -C $(MYHTML_PATH) clean
publish: clean
$(MIX) hex.publish
diff --git a/build-test/package.sh b/build-test/package.sh
index b3e90dc..d56b7fe 100755
--- a/build-test/package.sh
+++ b/build-test/package.sh
@@ -1,37 +1,42 @@
#!/bin/sh
start_dir=`pwd`
abort()
{
cd $start_dir
exit 1
}
trap 'abort' 0
set -e
make clean
test -d package-test || mkdir package-test
rm -rf package-test/*
mkdir package-test/myhtmlex-local
mix hex.build
mv myhtmlex-*.tar package-test/myhtmlex-local/
cd package-test/myhtmlex-local
tar -xf *.tar
tar -xzf *.tar.gz
cd ..
mix new myhtmlex_pkg_test
cd myhtmlex_pkg_test
-sed -i"" -e 's/^.*dep_from_hexpm.*$/ {:myhtmlex, path: "..\/myhtmlex-local", app: false}/' mix.exs
+sed -i"" -e 's/^.*dep_from_hexpm.*$/ {:myhtmlex, path: "..\/myhtmlex-local", app: false}/' mix.exs
mix deps.get
mix compile
-mix run -e 'IO.inspect Myhtmlex.decode("foo")'
+mix run -e 'IO.inspect {"html", [], [{"head", [], []}, {"body", [], ["foo"]}]} = Myhtmlex.decode("foo")'
+
+sed -i"" -e 's/extra_applications: \[:logger\]$/extra_applications: \[:logger, :myhtmlex\]/' mix.exs
+sed -i"" -e 's/^.*myhtmlex-local.*$/ {:myhtmlex, path: "..\/myhtmlex-local"}/' mix.exs
+mix deps.get
+mix compile
+mix run -e 'IO.inspect {"html", [], [{"head", [], []}, {"body", [], ["foo"]}]} = Myhtmlex.Safe.decode("foo")'
trap : 0
-rm -rf $start_dir/package-test
cd $start_dir
echo "ok"
diff --git a/mix.exs b/mix.exs
index bec68c5..5f8c484 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,93 +1,98 @@
defmodule Myhtmlex.Mixfile do
use Mix.Project
def project do
[
+ name: "Myhtmlex",
app: :myhtmlex,
version: "0.2.0",
elixir: "~> 1.5",
compilers: [:myhtmlex_make, :elixir, :app],
start_permanent: Mix.env == :prod,
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.
""",
package: package(),
deps: deps()
]
end
def package do
[
maintainers: ["Lukas Rieder"],
licenses: ["GNU LGPL"],
links: %{
"Github" => "https://github.com/Overbryd/myhtmlex",
"Issues" => "https://github.com/Overbryd/myhtmlex/issues",
"MyHTML" => "https://github.com/lexborisov/myhtml"
},
files: [
"lib",
"c_src",
"priv/.gitignore",
"test",
"Makefile",
"Makefile.Darwin",
"Makefile.Linux",
"mix.exs",
"README.md",
"LICENSE"
]
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
- mod: {Myhtmlex.Safe, []}
+ mod: {Myhtmlex.Safe, []},
+ registered: [Myhtmlex.Safe],
+ env: [
+ mode: Myhtmlex.Nif
+ ]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
# documentation helpers
- {:ex_doc, ">= 0.0.0", only: :dev},
+ {:ex_doc, ">= 0.0.0", only: :docs},
# benchmarking helpers
{:benchfella, "~> 0.3.0", only: :dev},
# cnode helpers
{:nodex, "~> 0.1.1"}
]
end
end
defmodule Mix.Tasks.Compile.MyhtmlexMake do
@artifacts [
"priv/myhtmlex.so",
"priv/cclient"
]
def run(_) do
if match? {:win32, _}, :os.type do
IO.warn "Windows is not yet a target."
exit(1)
else
{result, _error_code} = System.cmd("make",
@artifacts,
stderr_to_stdout: true,
env: [{"MIX_ENV", to_string(Mix.env)}]
)
IO.binwrite result
end
:ok
end
def clean() do
{result, _error_code} = System.cmd("make", ["clean"], stderr_to_stdout: true)
Mix.shell.info result
:ok
end
end

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jan 21, 10:52 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55765
Default Alt Text
(6 KB)

Event Timeline