Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F140742
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/build-test/package.sh b/build-test/package.sh
index d56b7fe..815bdd7 100755
--- a/build-test/package.sh
+++ b/build-test/package.sh
@@ -1,42 +1,43 @@
#!/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
+
+# Default operation
+sed -i "" -e 's/^.*dep_from_hexpm.*$/ {:myhtmlex, path: "..\/myhtmlex-local"}/' mix.exs
mix deps.get
mix compile
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")'
+# Nif operation
+sed -i "" -e 's/^.*myhtmlex-local.*$/ {:myhtmlex, path: "..\/myhtmlex-local", runtime: false}/' mix.exs
+echo "config :myhtmlex, mode: Myhtmlex.Nif" >> config/config.exs
+mix run -e 'IO.inspect {"html", [], [{"head", [], []}, {"body", [], ["foo"]}]} = Myhtmlex.decode("foo")'
trap : 0
cd $start_dir
echo "ok"
diff --git a/lib/myhtmlex/safe.ex b/lib/myhtmlex/safe.ex
index 92be6c0..d07291f 100644
--- a/lib/myhtmlex/safe.ex
+++ b/lib/myhtmlex/safe.ex
@@ -1,30 +1,30 @@
defmodule Myhtmlex.Safe do
@moduledoc false
use Application
app = Mix.Project.config[:app]
def start(_type, _args) do
import Supervisor.Spec
unless Node.alive? do
Nodex.Distributed.up
end
myhtml_worker = Path.join(:code.priv_dir(unquote(app)), "myhtml_worker")
children = [
- worker(Nodex.Cnode, [%{exec_path: myhtml_worker}, [name: __MODULE__]])
+ worker(Nodex.Cnode, [%{exec_path: myhtml_worker}, [name: Myhtmlex.Safe.Cnode]])
]
Supervisor.start_link(children, strategy: :one_for_one, name: Myhtmlex.Safe.Supervisor)
end
def decode(bin) do
decode(bin, [])
end
def decode(bin, flags) do
- {:ok, res} = Nodex.Cnode.call(__MODULE__, {:decode, bin, flags})
+ {:ok, res} = Nodex.Cnode.call(Myhtmlex.Safe.Cnode, {:decode, bin, flags})
res
end
end
diff --git a/mix.exs b/mix.exs
index 0568e63..7283063 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,98 +1,106 @@
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],
+ deps: deps(),
+ package: package(),
+ compilers: [:myhtmlex_make] ++ Mix.compilers,
+ build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
+ name: "Myhtmlex",
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()
+ docs: docs()
]
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
[
+ extra_applications: [:logger],
mod: {Myhtmlex.Safe, []},
- registered: [Myhtmlex.Safe],
+ # used to detect conflicts with other applications named processes
+ registered: [Myhtmlex.Safe.Cnode, Myhtmlex.Safe.Supervisor],
env: [
mode: Myhtmlex.Safe
]
]
end
- # Run "mix help deps" to learn about dependencies.
defp deps do
[
# documentation helpers
{:ex_doc, ">= 0.0.0", only: :docs},
# benchmarking helpers
{:benchfella, "~> 0.3.0", only: :dev},
# cnode helpers
{:nodex, "~> 0.1.1"}
]
end
+
+ defp docs do
+ [
+ main: "Myhtmlex"
+ ]
+ end
end
defmodule Mix.Tasks.Compile.MyhtmlexMake do
@artifacts [
"priv/myhtmlex.so",
"priv/myhtml_worker"
]
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
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Jan 21, 8:04 AM (1 d, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55693
Default Alt Text
(5 KB)
Attached To
Mode
R16 fast_html
Attached
Detach File
Event Timeline
Log In to Comment