Skip to content

Commit

Permalink
chore(build): switch to regular git submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
keynslug committed Jun 20, 2024
1 parent 2d22228 commit b80e178
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 38 deletions.
1 change: 1 addition & 0 deletions .github/workflows/eunit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
38 changes: 3 additions & 35 deletions c_src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)" && \
Expand All @@ -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)

Empty file removed c_src/libs/.git_keep
Empty file.
1 change: 1 addition & 0 deletions c_src/libs/c_reusable_data_structures
1 change: 1 addition & 0 deletions c_src/libs/jqc
Submodule jqc added at 2425cc

0 comments on commit b80e178

Please sign in to comment.