From b80e1788796d7669681ccfe4da4d1018c2d43f98 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Thu, 20 Jun 2024 20:58:59 +0200 Subject: [PATCH] chore(build): switch to regular git submodules --- .github/workflows/eunit.yaml | 1 + .github/workflows/release.yaml | 1 + .gitignore | 3 --- .gitmodules | 8 ++++++ c_src/Makefile | 38 +++------------------------ c_src/libs/.git_keep | 0 c_src/libs/c_reusable_data_structures | 1 + c_src/libs/jqc | 1 + 8 files changed, 15 insertions(+), 38 deletions(-) create mode 100644 .gitmodules delete mode 100644 c_src/libs/.git_keep create mode 160000 c_src/libs/c_reusable_data_structures create mode 160000 c_src/libs/jqc diff --git a/.github/workflows/eunit.yaml b/.github/workflows/eunit.yaml index f5dcedc..646bd19 100644 --- a/.github/workflows/eunit.yaml +++ b/.github/workflows/eunit.yaml @@ -47,5 +47,6 @@ jobs: steps: - uses: actions/checkout@v3 + - run: git config --global --add safe.directory $GITHUB_WORKSPACE - run: ./build.sh - run: rebar3 eunit diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1aad73a..9811b72 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -77,6 +77,7 @@ jobs: steps: - uses: actions/checkout@v3 with: + submodules: recursive fetch-depth: 0 ref: ${{ github.event.inputs.branch_or_tag }} # when input is not given, the event tag is used diff --git a/.gitignore b/.gitignore index 774730b..f20bca1 100644 --- a/.gitignore +++ b/.gitignore @@ -20,12 +20,9 @@ rebar3.crashdump *~ c_src/ext_libs c_src/jqc -c_src/libs priv/*.dylib a.out c_src/ext_libs/ -c_src/libs/c_reusable_data_structures/ -c_src/libs/jqc/ priv/erlang_jq_port test/port_program_stderr.txt test/port_program_stdout.bin diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ddb5b6d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,8 @@ +[submodule "c_src/libs/c_reusable_data_structures"] + path = c_src/libs/c_reusable_data_structures + url = https://github.com/emqx/c_reusable_data_structures.git + branch = master +[submodule "c_src/libs/jqc"] + path = c_src/libs/jqc + url = https://github.com/emqx/jqc.git + branch = jq-1.6-emqx diff --git a/c_src/Makefile b/c_src/Makefile index 225d234..2365e84 100644 --- a/c_src/Makefile +++ b/c_src/Makefile @@ -10,25 +10,8 @@ JQERLMODSRC := $(BASEDIR)/src/jq_nif.erl PROJECT ?= $(notdir $(BASEDIR)) PROJECT := $(strip $(PROJECT)) NIF_MODULE := jq_nif - JQSRC_DIR := libs/jqc -JQSRC := $(JQSRC_DIR)/src/jv.c -JQSRC_URL := https://github.com/emqx/jqc.git -JQSRC_VERSION := 2425ccaaf1e85f63cac694f783ad3753219e2132 - RDSSRC_DIR := libs/c_reusable_data_structures -RDSSRC := $(RDSSRC_DIR)/Makefile -RDSSRC_URL := https://github.com/emqx/c_reusable_data_structures.git -RDSSRC_VERSION := 77c7a96416065a839417e5078fce9ba9a14982dc - -define fetch_source -git -C "$($(1)_DIR)" fetch "$($(1)_URL)" $($(1)_VERSION) -git -C "$($(1)_DIR)" checkout $($(1)_VERSION) || ( \ - echo "Failed to check out $($(1)_DIR) commit" && \ - rm -r "$($(1)_DIR)" && \ - false ) -endef - LIBJQ_DIR ?= $(JQSRC_DIR)/.libs LIBJQ_PREFIX := /usr/local EXT_LIBS := ext_libs @@ -125,7 +108,7 @@ all: $(C_SRC_OUTPUT) ifeq ($(JQ_MEMSAN_DEBUG), 1) $(C_SRC_OUTPUT): $(OBJECTS) port_nif_common.h else -$(C_SRC_OUTPUT): $(RDSSRC) $(OBJECTS) $(ERL_PORT_PROGRAM) port_nif_common.h +$(C_SRC_OUTPUT): $(OBJECTS) $(ERL_PORT_PROGRAM) port_nif_common.h endif @mkdir -p $(BASEDIR)/priv/ $(link_verbose) $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT) @@ -144,22 +127,10 @@ $(ERL_PORT_PROGRAM): $(PORT_OBJECTS) @mkdir -p $(BASEDIR)/priv/ $(CC) $(PORT_OBJECTS) -L $(EXT_LIBS) $(LD_JQLIBS) -lm -pthread -o $(ERL_PORT_PROGRAM) -%.o: %.c $(LIBJQ_NAME) $(JQERLMODSRC) $(RDSSRC) $(PORT_SOURCES) +%.o: %.c $(LIBJQ_NAME) $(JQERLMODSRC) $(PORT_SOURCES) $(COMPILE_C) $(OUTPUT_OPTION) $< -%/.git: - git init "$*" - -$(JQSRC): $(JQSRC_DIR)/.git - $(call fetch_source,JQSRC) - touch "$@" - -$(RDSSRC): $(RDSSRC_DIR)/.git - $(call fetch_source,RDSSRC) - touch "$@" - -$(LIBJQ_NAME): $(JQSRC) - #ls -lart .libs/ modules/oniguruma/src/.libs/ +$(LIBJQ_NAME): (cd $(JQSRC_DIR) && \ git submodule update --init && \ export CC="$(CC)" && \ @@ -179,7 +150,4 @@ clean: @rm -f $(PORT_OBJECTS) @rm -f $(PRIV_DIR)/* @rm -rf $(EXT_LIBS) - @rm -rf $(JQSRC_DIR) - @rm -rf $(RDSSRC_DIR) @rm -f $(ERL_PORT_PROGRAM) - diff --git a/c_src/libs/.git_keep b/c_src/libs/.git_keep deleted file mode 100644 index e69de29..0000000 diff --git a/c_src/libs/c_reusable_data_structures b/c_src/libs/c_reusable_data_structures new file mode 160000 index 0000000..77c7a96 --- /dev/null +++ b/c_src/libs/c_reusable_data_structures @@ -0,0 +1 @@ +Subproject commit 77c7a96416065a839417e5078fce9ba9a14982dc diff --git a/c_src/libs/jqc b/c_src/libs/jqc new file mode 160000 index 0000000..2425cca --- /dev/null +++ b/c_src/libs/jqc @@ -0,0 +1 @@ +Subproject commit 2425ccaaf1e85f63cac694f783ad3753219e2132