Skip to content

Commit 09c4618

Browse files
authored
Build system updates (esp. target into BINDIR) (RedisJSON#547)
1 parent 45e96a7 commit 09c4618

File tree

10 files changed

+47
-38
lines changed

10 files changed

+47
-38
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ commands:
7272
name: System setup
7373
command: |
7474
python3 -m pip list -v
75-
./system-setup.py
75+
./sbin/system-setup.py
7676
python3 -m pip list -v
7777
source $HOME/.cargo/env
7878
rustc --version

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/bin/
22
/target/
33
/tests/pytest/logs/
4+
/1/
45

56
# Object files
67
*.o

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/bin/
22
/target/
33
/tests/pytest/logs/
4+
/1/
45

56
# These are backup files generated by rustfmt
67
**/*.rs.bk

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ADD . /build
3636

3737
RUN ./deps/readies/bin/getupdates
3838
RUN ./deps/readies/bin/getpy3
39-
RUN ./system-setup.py
39+
RUN ./sbin/system-setup.py
4040

4141
RUN bash -l -c make
4242

Makefile

+30-26
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ endif
2121

2222
#----------------------------------------------------------------------------------------------
2323

24-
define HELP
24+
define HELPTEXT
2525
make setup # install prerequisites
2626

2727
make build
@@ -83,22 +83,23 @@ CARGO_FLAGS=
8383

8484
ifeq ($(DEBUG),1)
8585
ifeq ($(SAN),)
86-
TARGET_DIR=target/debug
86+
TARGET_DIR=$(BINDIR)/target/debug
8787
else
88-
TARGET_DIR=target/$(RUST_TARGET)/debug
88+
TARGET_DIR=$(BINDIR)/target/$(RUST_TARGET)/debug
8989
CARGO_TOOLCHAIN = +nightly
9090
CARGO_FLAGS += -Zbuild-std
9191
endif
9292
else
9393
CARGO_FLAGS += --release
94-
TARGET_DIR=target/release
94+
TARGET_DIR=$(BINDIR)/target/release
9595
endif
9696

9797
ifeq ($(PROFILE),1)
9898
RUSTFLAGS += " -g -C force-frame-pointers=yes"
9999
endif
100100

101-
TARGET=$(TARGET_DIR)/$(MODULE_NAME)
101+
export CARGO_TARGET_DIR=$(BINDIR)/target
102+
TARGET=$(BINDIR)/$(MODULE_NAME)
102103

103104
#----------------------------------------------------------------------------------------------
104105

@@ -109,15 +110,15 @@ all: build
109110
#----------------------------------------------------------------------------------------------
110111

111112
setup:
112-
./deps/readies/bin/getpy3
113-
./system-setup.py
113+
$(SHOW)./deps/readies/bin/getpy3
114+
$(SHOW)./sbin/system-setup.py
114115

115116
.PHONY: setup
116117

117118
#----------------------------------------------------------------------------------------------
118119

119120
lint:
120-
cargo fmt -- --check
121+
$(SHOW)cargo fmt -- --check
121122

122123
.PHONY: lint
123124

@@ -135,25 +136,27 @@ RUST_SOEXT.macos=dylib
135136

136137
build:
137138
ifeq ($(SAN),)
139+
$(SHOW)set -e ;\
138140
export RUSTFLAGS=$(RUSTFLAGS) ;\
139141
cargo build --all --all-targets $(CARGO_FLAGS)
140142
else
143+
$(SHOW)set -e ;\
141144
export RUSTFLAGS=-Zsanitizer=$(SAN) ;\
142145
export RUSTDOCFLAGS=-Zsanitizer=$(SAN) ;\
143146
cargo $(CARGO_TOOLCHAIN) build --target $(RUST_TARGET) $(CARGO_FLAGS)
144147
endif
145-
cp $(TARGET_DIR)/librejson.$(RUST_SOEXT.$(OS)) $(TARGET)
148+
$(SHOW)cp $(TARGET_DIR)/librejson.$(RUST_SOEXT.$(OS)) $(TARGET)
146149
ifneq ($(DEBUG),1)
147150
ifneq ($(OS),macos)
148-
$(call extract_symbols,$(TARGET))
151+
$(SHOW)$(call extract_symbols,$(TARGET))
149152
endif
150153
endif
151154

152155
clean:
153156
ifneq ($(ALL),1)
154-
cargo clean
157+
$(SHOW)cargo clean
155158
else
156-
rm -rf target
159+
$(SHOW)rm -rf target
157160
endif
158161

159162
.PHONY: build clean
@@ -163,10 +166,10 @@ endif
163166
test: pytest
164167

165168
pytest:
166-
MODULE=$(abspath $(TARGET)) ./tests/pytest/tests.sh
169+
$(SHOW)MODULE=$(abspath $(TARGET)) ./tests/pytest/tests.sh
167170

168171
cargo_test:
169-
cargo $(CARGO_TOOLCHAIN) test --features test --all
172+
$(SHOW)cargo $(CARGO_TOOLCHAIN) test --features test --all
170173

171174
.PHONY: pytest cargo_test
172175

@@ -185,56 +188,57 @@ BENCHMARK_ARGS += --test $(BENCHMARK)
185188
endif
186189

187190
bench benchmark: $(TARGET)
188-
cd ./tests/benchmarks ;\
191+
$(SHOW)set -e ;\
192+
cd tests/benchmarks ;\
189193
redisbench-admin $(BENCHMARK_ARGS)
190194

191195
.PHONY: bench benchmark
192196

193197
#----------------------------------------------------------------------------------------------
194198

195199
pack:
196-
./sbin/pack.sh
200+
$(SHOW)./sbin/pack.sh
197201

198202
.PHONY: pack
199203

200204
#----------------------------------------------------------------------------------------------
201205

202206
docker:
203-
@make -C build/platforms build
207+
$(SHOW)make -C build/platforms build
204208

205209
docker_push:
206-
@make -C build/platforms publish
210+
$(SHOW)make -C build/platforms publish
207211

208212
.PHONY: docker docker_push
209213

210214
#----------------------------------------------------------------------------------------------
211215

212216
platform:
213-
@make -C build/platforms build
217+
$(SHOW)make -C build/platforms build
214218
ifeq ($(PUBLISH),1)
215-
@make -C build/platforms publish
219+
$(SHOW)make -C build/platforms publish
216220
endif
217221

218222
#----------------------------------------------------------------------------------------------
219223

220224
builddocs:
221-
mkdocs build
225+
$(SHOW)mkdocs build
222226

223227
localdocs: builddocs
224-
mkdocs serve
228+
$(SHOW)mkdocs serve
225229

226230
deploydocs: builddocs
227-
mkdocs gh-deploy
231+
$(SHOW)mkdocs gh-deploy
228232

229233
.PHONY: builddocs localdocs deploydocs
230234

231235
#----------------------------------------------------------------------------------------------
232236

233237
nightly:
234-
rustup default nightly
235-
rustup component add rust-src
238+
$(SHOW)rustup default nightly
239+
$(SHOW)rustup component add rust-src
236240

237241
stable:
238-
rustup default stable
242+
$(SHOW)rustup default stable
239243

240244
.PHONY: nightly stable

build/docker/Makefile

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2+
ROOT=../..
3+
MK.pyver:=3
4+
include $(ROOT)/deps/readies/mk/main
5+
16
REDIS_VERSION=6.2.5
27
PRODUCT=rejson
38

@@ -7,10 +12,7 @@ OSNICK_OFFICIAL=bullseye
712
# if there's a need to manually set the version, override.
813
# by default this uses ${VERSION} but in a private branch testing with
914
# VERSION=master, VERSION=2.0 is requireed.
10-
REDISEARCH_VERSION=${VERSION}
11-
export REDISEARCH_VERSION
15+
export REDISEARCH_VERSION=$(VERSION)
1216
export ART_INT_DIR=/usr/lib/redis/modules/
1317

14-
ROOT=../../
15-
READIES=${ROOT}/deps/readies
16-
include ${READIES}/mk/docker.rules
18+
include $(MK)/docker.rules

build/docker/dockerfile.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COPY --from=redis /usr/local/ /usr/local/
1010
ADD . /build
1111

1212
{% include 'setup_environment.yml' %}
13-
RUN ./system-setup.py
13+
RUN ./sbin/system-setup.py
1414

1515
RUN bash -l -c make
1616

build/platforms/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ADD . /build
3434

3535
RUN ./deps/readies/bin/getupdates
3636
RUN ./deps/readies/bin/getpy3
37-
RUN ./system-setup.py
37+
RUN ./sbin/system-setup.py
3838

3939
RUN bash -l -c make
4040

system-setup.py renamed to sbin/system-setup.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import os
55
import argparse
66

7-
ROOT = HERE = os.path.abspath(os.path.dirname(__file__))
8-
READIES = os.path.join(HERE, "deps/readies")
7+
HERE = os.path.abspath(os.path.dirname(__file__))
8+
ROOT = os.path.abspath(os.path.join(HERE, ".."))
9+
READIES = os.path.join(ROOT, "deps/readies")
910
sys.path.insert(0, READIES)
1011
import paella
1112

0 commit comments

Comments
 (0)