Commit 87064e55 authored by Philipp Huebner's avatar Philipp Huebner

Merge tag 'upstream/1.0.9'

Upstream version 1.0.9
parents 8674fd52 7ae7c931
# Version 1.0.9
* Use p1_utils 1.0.7 (Christophe Romain)
# Version 1.0.8
* Load local .so instead from system package when running tests (Paweł Chmielowski)
# Version 1.0.7
* Use p1_utils 1.0.6 (Christophe Romain)
* Make sure fast_yaml isn't compiled to native code (Holger Weiss)
# Version 1.0.6
* Update to p1_utils 1.0.5 (Mickaël Rémond)
......
/*
* Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
* Copyright (C) 2002-2017 ProcessOne, SARL. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for fast_yaml 1.0.0.
# Generated by GNU Autoconf 2.69 for fast_yaml 1.0.8.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
......@@ -577,8 +577,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='fast_yaml'
PACKAGE_TARNAME='fast_yaml'
PACKAGE_VERSION='1.0.0'
PACKAGE_STRING='fast_yaml 1.0.0'
PACKAGE_VERSION='1.0.8'
PACKAGE_STRING='fast_yaml 1.0.8'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
......@@ -1230,7 +1230,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures fast_yaml 1.0.0 to adapt to many kinds of systems.
\`configure' configures fast_yaml 1.0.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1291,7 +1291,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of fast_yaml 1.0.0:";;
short | recursive ) echo "Configuration of fast_yaml 1.0.8:";;
esac
cat <<\_ACEOF
......@@ -1380,7 +1380,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
fast_yaml configure 1.0.0
fast_yaml configure 1.0.8
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -1678,7 +1678,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by fast_yaml $as_me 1.0.0, which was
It was created by fast_yaml $as_me 1.0.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -4374,7 +4374,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by fast_yaml $as_me 1.0.0, which was
This file was extended by fast_yaml $as_me 1.0.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -4427,7 +4427,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
fast_yaml config.status 1.0.0
fast_yaml config.status 1.0.8
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
......@@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.53)
AC_PACKAGE_VERSION(1.0.0)
AC_INIT(fast_yaml, 1.0.0, [], [])
AC_PACKAGE_VERSION(1.0.8)
AC_INIT(fast_yaml, 1.0.8, [], [])
# Checks for programs.
AC_PROG_CC
......
......@@ -4,7 +4,7 @@
%%% Purpose : Rebar build script. Compliant with rebar and rebar3.
%%% Created : 11 Dec 2015 by Mickael Remond <mremond@process-one.net>
%%%
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%% Copyright (C) 2002-2017 ProcessOne, SARL. All Rights Reserved.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
......@@ -21,10 +21,10 @@
%%%----------------------------------------------------------------------
{erl_opts, [debug_info, {src_dirs, ["src"]}]}.
{port_env, [{"CFLAGS", "$CFLAGS"}, {"LDFLAGS", "$LDFLAGS"}]}.
{port_env, [{"CFLAGS", "$CFLAGS"}, {"LDFLAGS", "$LDFLAGS -lyaml"}]}.
{port_specs, [{"priv/lib/fast_yaml.so", ["c_src/fast_yaml.c"]}]}.
{deps, [{p1_utils, ".*", {git, "git://github.com/processone/p1_utils", {tag, "1.0.5"}}}]}.
{deps, [{p1_utils, ".*", {git, "git://github.com/processone/p1_utils", {tag, "1.0.7"}}}]}.
{clean_files, ["c_src/fast_yaml.gcda", "c_src/fast_yaml.gcno"]}.
......
......@@ -4,7 +4,7 @@
%%% Purpose : Rebar build script. Compliant with rebar and rebar3.
%%% Created : 11 Dec 2015 by Mickael Remond <mremond@process-one.net>
%%%
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%% Copyright (C) 2002-2017 ProcessOne, SARL. All Rights Reserved.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
......@@ -20,7 +20,7 @@
%%%
%%%----------------------------------------------------------------------
Cfg = case file:consult("vars.config") of
Cfg = case file:consult(filename:join([filename:dirname(SCRIPT),"vars.config"])) of
{ok, Terms} ->
Terms;
_Err ->
......@@ -30,77 +30,113 @@ Cfg = case file:consult("vars.config") of
{ldflags, CfgLDFlags} = lists:keyfind(ldflags, 1, Cfg),
{with_gcov, CfgWithGCov} = lists:keyfind(with_gcov, 1, Cfg),
ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
{OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of
{value, {_, V1}, V2} -> {V1, V2};
false -> {if Tail == [] -> Default; true -> [] end, Cfg}
end,
case Tail of
[] ->
[{Key, Op(OldVal)} | PartCfg];
_ ->
[{Key, F(F, OldVal, Tail, Op, Default)} | PartCfg]
end
end,
ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op, Default) end.
ModCfgS = fun(Cfg, Keys, Val) -> ModCfg0(ModCfg0, Cfg, Keys, fun(_V) -> Val end, "") end.
Cfg0 = ModCfg(CONFIG, [port_env, "CFLAGS"], fun(V) -> V ++ " " ++ CfgCFlags end, "$CFLAGS"),
Cfg00 = ModCfg(Cfg0, [port_env, "LDFLAGS"], fun(V) -> V ++ " " ++ CfgLDFlags end, "$LDFLAGS"),
Cfg1 = case CfgWithGCov of
"true" ->
V1 = ModCfg(Cfg00, [post_hooks], fun(V) -> V ++ [{eunit, "gcov -o c_src fast_yaml"},
{eunit, "mv *.gcov .eunit/"}] end, []),
V2 = ModCfg(V1, [port_env, "LDFLAGS"], fun(V) -> V ++ " --coverage" end, ""),
ModCfg(V2, [port_env, "CFLAGS"], fun(V) -> V ++ " --coverage" end, "");
_ ->
Cfg00
end,
%% Rebar3 support for hex.pm support:
%% - Transform dependencies specification to use hex.pm packages:
%% deps of the form: {Name, _Vsn, {git, _URL, {tag, Version}}}
%% are expected to refer to package and are rewritten for rebar3 as:
%% {Name, Version}
%% - Add rebar3_hex plugin
IsRebar3 = case application:get_key(rebar, vsn) of
{ok, VSN} ->
[VSN1 | _] = string:tokens(VSN, "-"),
[Maj, Min, Patch] = string:tokens(VSN1, "."),
(list_to_integer(Maj) >= 3);
undefined ->
lists:keymember(mix, 1, application:loaded_applications())
end,
Cfg2 = case IsRebar3 of
true ->
DepsFun = fun(DepsList) -> lists:map(fun({DepName,_, {git,_, {tag,Version}}}) ->
{DepName, Version};
(Dep) ->
Dep
end, DepsList)
end,
RB1 = ModCfg(Cfg1, [deps], DepsFun, []),
RB2 = ModCfg(RB1, [plugins], fun(V) -> V ++ [rebar3_hex, pc] end, []),
ModCfg(RB2, [provider_hooks], fun(V) -> V ++ [{pre,
[
{compile, {pc, compile}},
{clean, {pc, clean}}
]
}] end, []);
false ->
Cfg1
end,
%% When running Travis test, upload test coverage result to coveralls:
Config = case os:getenv("TRAVIS") of
"true" ->
JobId = os:getenv("TRAVIS_JOB_ID"),
Cfg3 = ModCfg(Cfg2, [deps], fun(V) -> [{coveralls, ".*", {git, "https://github.com/markusn/coveralls-erl.git", "master"}}|V] end, []),
ModCfg(Cfg3, [post_hooks], fun(V) -> V ++ [{eunit, "echo '\n%%! -pa .eunit/ deps/coveralls/ebin\nmain(_)->{ok,F}=file:open(\"erlang.json\",[write]),io:fwrite(F,\"~s\",[coveralls:convert_file(\".eunit/cover.coverdata\", \""++JobId++"\", \"travis-ci\")]).' > getcover.erl"},
{eunit, "escript ./getcover.erl"}] end, []);
_ ->
Cfg2
end,
{ok, VSN} ->
[VSN1 | _] = string:tokens(VSN, "-"),
[Maj, Min, Patch] = string:tokens(VSN1, "."),
(list_to_integer(Maj) >= 3);
undefined ->
lists:keymember(mix, 1, application:loaded_applications())
end,
JobId = case os:getenv("TRAVIS_JOB_ID") of false -> ""; V -> V end,
ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) ->
{OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of
{value, {_, V1}, V2} -> {V1, V2};
false -> {if Tail == [] -> Default; true -> [] end, Cfg}
end,
case Tail of
[] ->
[{Key, Op(OldVal)} | PartCfg];
_ ->
[{Key, F(F, OldVal, Tail, Op, Default)} | PartCfg]
end
end,
ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op,
Default) end,
ModCfgS = fun(Cfg, Keys, Val) -> ModCfg0(ModCfg0, Cfg, Keys, fun(_V) ->
Val end, "") end,
FilterConfig = fun(F, Cfg, [{Path, true, ModFun, Default} | Tail]) ->
F(F, ModCfg0(ModCfg0, Cfg, Path, ModFun, Default), Tail);
(F, Cfg, [_ | Tail]) ->
F(F, Cfg, Tail);
(F, Cfg, []) ->
Cfg
end,
AppendStr = fun(Append) ->
fun("") ->
Append;
(Val) ->
Val ++ " " ++ Append
end
end,
AppendList = fun(Append) ->
fun(Val) ->
Val ++ Append
end
end,
Rebar3DepsFilter = fun(DepsList) ->
lists:map(fun({DepName,_, {git,_, {tag,Version}}}) ->
{DepName, Version};
(Dep) ->
Dep
end, DepsList)
end,
GlobalDepsFilter = fun(Deps) ->
DepNames = lists:map(fun({DepName, _, _}) -> DepName;
({DepName, _}) -> DepName
end, Deps),
lists:filtermap(fun(Dep) ->
case code:lib_dir(Dep) of
{error, _} ->
{true,"Unable to locate dep '"++atom_to_list(Dep)++"' in system deps."};
_ ->
false
end
end, DepNames)
end,
Rules = [
{[port_env, "CFLAGS"], true,
AppendStr(CfgCFlags), "$CFLAGS"},
{[port_env, "LDFLAGS"], true,
AppendStr(CfgLDFlags), "$LDFLAGS"},
{[post_hooks], CfgWithGCov == "true",
AppendList([{eunit, "gcov -o c_src fast_yaml"},
{eunit, "mv *.gcov .eunit/"}]), []},
{[port_env, "LDFLAGS"], CfgWithGCov == "true",
AppendStr("--coverage"), ""},
{[port_env, "CFLAGS"], CfgWithGCov == "true",
AppendStr("--coverage"), ""},
{[deps], IsRebar3,
Rebar3DepsFilter, []},
{[plugins], IsRebar3,
AppendList([rebar3_hex, pc]), []},
{[provider_hooks], IsRebar3,
AppendList([{pre, [
{compile, {pc, compile}},
{clean, {pc, clean}}
]}]), []},
{[deps], os:getenv("TRAVIS") == "true",
AppendList([{coveralls, ".*", {git, "https://github.com/markusn/coveralls-erl.git", "master"}}]), []},
{[post_hooks], os:getenv("TRAVIS") == "true",
AppendList([{eunit, "echo '\n%%! -pa .eunit/ deps/coveralls/ebin\nmain(_)->{ok,F}=file:open(\"erlang.json\",[write]),io:fwrite(F,\"~s\",[coveralls:convert_file(\".eunit/cover.coverdata\", \""++JobId++"\", \"travis-ci\",\"\")]).' > getcover.erl"},
{eunit, "escript ./getcover.erl"}]), []},
{[deps], os:getenv("USE_GLOBAL_DEPS") /= false,
GlobalDepsFilter, []}
],
Config = FilterConfig(FilterConfig, CONFIG, Rules),
%io:format("Rules:~n~p~n~nCONFIG:~n~p~n~nConfig:~n~p~n", [Rules, CONFIG, Config]),
Config.
......
......@@ -5,7 +5,7 @@
%%% Created : 4 Apr 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%% Copyright (C) 2002-2017 ProcessOne, SARL. All Rights Reserved.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
......@@ -23,7 +23,7 @@
{application, fast_yaml,
[{description, "Fast YAML native library for Erlang / Elixir"},
{vsn, "1.0.6"},
{vsn, "1.0.9"},
{modules, []},
{registered, []},
{applications, [kernel, stdlib]},
......
......@@ -5,7 +5,7 @@
%%% Created : 7 Aug 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%% Copyright (C) 2002-2017 ProcessOne, SARL. All Rights Reserved.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
......@@ -23,6 +23,8 @@
-module(fast_yaml).
-compile(no_native).
%% API
-export([load_nif/0, decode/1, decode/2, start/0, stop/0,
decode_from_file/1, decode_from_file/2, encode/1, format_error/1]).
......@@ -47,6 +49,9 @@ stop() ->
load_nif() ->
SOPath = p1_nif_utils:get_so_path(?MODULE, [fast_yaml], "fast_yaml"),
load_nif(SOPath).
load_nif(SOPath) ->
case catch erlang:load_nif(SOPath, 0) of
ok ->
ok;
......@@ -55,7 +60,7 @@ load_nif() ->
Err
end.
-spec format_error(atom() | yaml_error()) -> string().
-spec format_error(atom() | yaml_error() | file:posix()) -> string().
format_error({Tag, Reason, Line, Column}) when Tag == parser_error;
Tag == scanner_error ->
......@@ -75,12 +80,14 @@ format_error(_) ->
decode(Data) ->
decode(Data, []).
-spec decode_from_file(file:filename()) -> {ok, term()} | {error, yaml_error()}.
-spec decode_from_file(file:filename()) -> {ok, term()} |
{error, yaml_error() | file:posix()}.
decode_from_file(File) ->
decode_from_file(File, []).
-spec decode_from_file(file:filename(), options()) -> {ok, term()} | {error, yaml_error()}.
-spec decode_from_file(file:filename(), options()) -> {ok, term()} |
{error, yaml_error() | file:posix()}.
decode_from_file(File, Opts) ->
case file:read_file(File) of
......@@ -159,7 +166,8 @@ indent(N) ->
-include_lib("eunit/include/eunit.hrl").
load_nif_test() ->
?assertEqual(ok, load_nif()).
SOPath = p1_nif_utils:get_so_path(?MODULE, [], "fast_yaml"),
?assertEqual(ok, load_nif(SOPath)).
decode_test1_test() ->
FileName = filename:join(["..", "test", "test1.yml"]),
......
......@@ -5,7 +5,7 @@
%%% Created : 7 Aug 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%% Copyright (C) 2002-2017 ProcessOne, SARL. All Rights Reserved.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
......
......@@ -5,7 +5,7 @@
%%% Created : 7 Aug 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% Copyright (C) 2002-2016 ProcessOne, SARL. All Rights Reserved.
%%% Copyright (C) 2002-2017 ProcessOne, SARL. All Rights Reserved.
%%%
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
......
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