You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2021/10/04 21:20:57 UTC

[couchdb-jiffy] branch rebar3 created (now bbb7fbb)

This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a change to branch rebar3
in repository https://gitbox.apache.org/repos/asf/couchdb-jiffy.git.


      at bbb7fbb  switch to rebar3

This branch includes the following new commits:

     new bbb7fbb  switch to rebar3

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[couchdb-jiffy] 01/01: switch to rebar3

Posted by rn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch rebar3
in repository https://gitbox.apache.org/repos/asf/couchdb-jiffy.git

commit bbb7fbbac7996926876a296a20155d3df40f05f1
Author: Robert Newson <rn...@apache.org>
AuthorDate: Mon Oct 4 22:17:44 2021 +0100

    switch to rebar3
---
 Makefile                     |   2 +-
 c_src/Makefile               |  74 +++++++++++++++++++++++++++++++++++++++++++
 enc                          | Bin 26053 -> 0 bytes
 plugins/rebar_gdb_plugin.erl |  13 --------
 rebar.config                 |  38 ++++------------------
 rebar.config.script          |  39 -----------------------
 6 files changed, 81 insertions(+), 85 deletions(-)

diff --git a/Makefile b/Makefile
index bce7e82..1ad82f4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-REBAR?=rebar
+REBAR?=rebar3
 
 
 all: build
diff --git a/c_src/Makefile b/c_src/Makefile
new file mode 100644
index 0000000..1e9b6cb
--- /dev/null
+++ b/c_src/Makefile
@@ -0,0 +1,74 @@
+# Based on c_src.mk from erlang.mk by Loic Hoguin <es...@ninenines.eu>
+
+CURDIR := $(shell pwd)
+BASEDIR := $(abspath $(CURDIR)/..)
+
+PROJECT ?= $(notdir $(BASEDIR))
+PROJECT := $(strip $(PROJECT))
+
+ERTS_INCLUDE_DIR ?= $(shell erl -noshell -eval "io:format(\"~ts/erts-~ts/include/\", [code:root_dir(), erlang:system_info(version)])." -s init stop)
+ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -eval "io:format(\"~ts\", [code:lib_dir(erl_interface, include)])." -s init stop)
+ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -eval "io:format(\"~ts\", [code:lib_dir(erl_interface, lib)])." -s init stop)
+
+C_SRC_DIR = $(CURDIR)
+C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so
+
+# System type and C compiler/flags.
+
+UNAME_SYS := $(shell uname -s)
+ifeq ($(UNAME_SYS), Darwin)
+	CC ?= cc
+	CFLAGS ?= -O3 -std=c99 -arch x86_64 -finline-functions -Wall -Wmissing-prototypes
+	CXXFLAGS ?= -O3 -arch x86_64 -finline-functions -Wall
+	LDFLAGS ?= -arch x86_64 -flat_namespace -undefined suppress
+else ifeq ($(UNAME_SYS), FreeBSD)
+	CC ?= cc
+	CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
+	CXXFLAGS ?= -O3 -finline-functions -Wall
+else ifeq ($(UNAME_SYS), Linux)
+	CC ?= gcc
+	CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
+	CXXFLAGS ?= -O3 -finline-functions -Wall
+endif
+
+CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
+CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
+
+LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lei
+LDFLAGS += -shared
+
+# Verbosity.
+
+c_verbose_0 = @echo " C     " $(?F);
+c_verbose = $(c_verbose_$(V))
+
+cpp_verbose_0 = @echo " CPP   " $(?F);
+cpp_verbose = $(cpp_verbose_$(V))
+
+link_verbose_0 = @echo " LD    " $(@F);
+link_verbose = $(link_verbose_$(V))
+
+SOURCES := $(shell find $(C_SRC_DIR) -type f \( -name "*.c" -o -name "*.C" -o -name "*.cc" -o -name "*.cpp" \))
+OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
+
+COMPILE_C = $(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c
+COMPILE_CPP = $(cpp_verbose) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
+
+$(C_SRC_OUTPUT): $(OBJECTS)
+	@mkdir -p $(BASEDIR)/priv/
+	$(link_verbose) $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT)
+
+%.o: %.c
+	$(COMPILE_C) $(OUTPUT_OPTION) $<
+
+%.o: %.cc
+	$(COMPILE_CPP) $(OUTPUT_OPTION) $<
+
+%.o: %.C
+	$(COMPILE_CPP) $(OUTPUT_OPTION) $<
+
+%.o: %.cpp
+	$(COMPILE_CPP) $(OUTPUT_OPTION) $<
+
+clean:
+	@rm -f $(C_SRC_OUTPUT) $(OBJECTS)
diff --git a/enc b/enc
deleted file mode 100755
index 5338498..0000000
Binary files a/enc and /dev/null differ
diff --git a/plugins/rebar_gdb_plugin.erl b/plugins/rebar_gdb_plugin.erl
deleted file mode 100644
index f27645d..0000000
--- a/plugins/rebar_gdb_plugin.erl
+++ /dev/null
@@ -1,13 +0,0 @@
--module(rebar_gdb_plugin).
--compile(export_all).
-
-pre_eunit(_Config, _AppFile) ->
-    case os:getenv("USE_GDB") of
-        false ->
-            ok;
-        _ ->
-            Prompt = io_lib:format("GDB Attach to: ~s~n", [os:getpid()]),
-            io:get_line(Prompt)
-    end,
-    ok.
-
diff --git a/rebar.config b/rebar.config
index b951b5e..140ebe7 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,33 +1,3 @@
-{port_specs, [
-    {"priv/jiffy.so", [
-        "c_src/*.c",
-        "c_src/*.cc",
-        "c_src/double-conversion/*.cc"
-    ]}
-]}.
-
-{port_env, [
-    {".*", "FLTO_FLAG", ""},
-
-    {"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
-        "CFLAGS", "$CFLAGS -Ic_src/ -g -Wall $FLTO_FLAG -Werror -O3"},
-    {"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
-        "CXXFLAGS", "$CXXFLAGS -Ic_src/ -g -Wall $FLTO_FLAG -Werror -O3"},
-
-    {"(linux|solaris|freebsd|netbsd|openbsd|dragonfly|darwin|gnu)",
-        "LDFLAGS", "$LDFLAGS $FLTO_FLAG -lstdc++"},
-
-    %% OS X Leopard flags for 64-bit
-    {"darwin9.*-64$", "CXXFLAGS", "-m64"},
-    {"darwin9.*-64$", "LDFLAGS", "-arch x86_64"},
-
-    %% OS X Snow Leopard flags for 32-bit
-    {"darwin10.*-32$", "CXXFLAGS", "-m32"},
-    {"darwin10.*-32$", "LDFLAGS", "-arch i386"},
-
-    {"win32", "CXXFLAGS", "$CXXFLAGS /O2 /DNDEBUG"}
-]}.
-
 {erl_opts, [
     {platform_define, "R1(1|2|3|4|5|6)", 'JIFFY_NO_MAPS'}
 ]}.
@@ -36,5 +6,9 @@
     verbose
 ]}.
 
-{pre_hooks, [{"", compile, "escript enc compile"}]}.
-{post_hooks, [{"", clean, "escript enc clean"}]}.
+{pre_hooks,
+  [{"(linux|darwin|solaris)", compile, "make -C c_src"},
+   {"(freebsd)", compile, "gmake -C c_src"}]}.
+{post_hooks,
+  [{"(linux|darwin|solaris)", clean, "make -C c_src clean"},
+   {"(freebsd)", clean, "gmake -C c_src clean"}]}.
diff --git a/rebar.config.script b/rebar.config.script
deleted file mode 100644
index a5da769..0000000
--- a/rebar.config.script
+++ /dev/null
@@ -1,39 +0,0 @@
-% This file is part of Jiffy released under the MIT license.
-% See the LICENSE file for more information.
-%
-% Only run the EQC checks when EQC is present.
-
-HaveEQC = code:which(eqc) =/= non_existing,
-
-ErlOpts = if not HaveEQC -> []; true ->
-    [{d, 'HAVE_EQC'}]
-end,
-
-Config1 = case lists:keyfind(erl_opts, 1, CONFIG) of
-    {erl_opts, Opts} ->
-        NewOpts = {erl_opts, Opts ++ ErlOpts},
-        lists:keyreplace(erl_opts, 1, CONFIG, NewOpts);
-    false ->
-        CONFIG ++ [{erl_opts, ErlOpts}]
-end,
-
-case os:type() of
-    {unix, _} ->
-        CC = case os:getenv("CC") of
-            false -> "cc";
-            Else -> Else
-        end,
-        FLTO_CHECK = "echo 'int main(int argc, char *argv[]) {return 0;}' | "
-                ++ CC ++ " -c -x c -o /dev/null -flto -",
-        case os:cmd(FLTO_CHECK) of
-            [] ->
-                {port_env, PortEnv} = lists:keyfind(port_env, 1, Config1),
-                NewFlag = {".*", "FLTO_FLAG", "-flto"},
-                NewPortEnv = lists:keyreplace("FLTO_FLAG", 2, PortEnv, NewFlag),
-                lists:keyreplace(port_env, 1, Config1, {port_env, NewPortEnv});
-            _ ->
-                Config1
-        end;
-    _ ->
-        Config1
-end.