11
22ROOT =../../..
33
4- VERSION ?= 1.5.0
5- OSNICK ?= buster
4+ VERSION ?= 1.7.0
5+ OSNICK ?= bionic
6+
7+ REDIS_VER =6.0.9
68
79# ----------------------------------------------------------------------------------------------
810
911S3_URL =redismodules/pytorch
1012
1113OS: =$(shell $(ROOT ) /opt/readies/bin/platform --os)
12- ifeq ($(OS ) ,macosx)
13- OS: =macos
14- endif
15- STEM =libtorch-cpu-$(OS )
14+ OSNICK: =$(shell $(ROOT ) /opt/readies/bin/platform --osnick)
15+ ARCH: =$(shell $(ROOT ) /opt/readies/bin/platform --arch)
16+ DEVICE ?= cpu
17+
18+ STEM =libtorch
1619
1720DOCKER_OS.bionic =ubuntu:bionic
1821DOCKER_OS.stretch =debian:stretch-slim
1922DOCKER_OS.buster =debian:buster-slim
2023DOCKER_OS =$(DOCKER_OS.$(OSNICK ) )
2124
25+ TAR_ARCH.x64 =x86_64
26+ TAR_ARCH.arm64v8 =arm64
27+ TAR_ARCH.arm32v7 =arm
28+
2229# ----------------------------------------------------------------------------------------------
2330
2431define targets # (1=OP, 2=op)
2532$(1 ) _TARGETS :=
26- $(1 ) _TARGETS += $(if $(findstring $(X64 ) ,1) ,$(2 ) _x64)
33+ $(1 ) _TARGETS += $(if $(findstring $(X64 ) ,1) ,$(2 ) _native)
34+ ifeq ($$(CROSS ) ,1)
2735$(1)_TARGETS += $(if $(findstring $(ARM7 ) ,1) ,$(2 ) _arm32v7)
2836$(1)_TARGETS += $(if $(findstring $(ARM8 ) ,1) ,$(2 ) _arm64v8)
37+ endif
2938
30- $(1 ) _TARGETS += $$(if $$(strip $$($(1 ) _TARGETS) ) ,,$(2 ) _x64 $(2 ) _arm32v7 $(2 ) _arm64v8)
39+ ifeq ($$(CROSS ) ,1)
40+ $(1)_TARGETS += $$(if $$(strip $$($(1 ) _TARGETS) ) ,,$(2 ) _native $(2 ) _arm32v7 $(2 ) _arm64v8)
41+ else
42+ $(1)_TARGETS += $$(if $$(strip $$($(1 ) _TARGETS) ) ,,$(2 ) _native)
43+ endif
3144endef
3245
3346$(eval $(call targets,BUILD,build))
3447$(eval $(call targets,PUBLISH,publish))
3548
3649# ----------------------------------------------------------------------------------------------
3750
38- define build_x64 # (1=arch, 2=tar-arch)
51+ DOCKER_BUILD_ARGS += \
52+ PT_VER=$(VERSION ) \
53+ OSNICK=$(OSNICK ) \
54+ OS=$(DOCKER_OS ) \
55+ ARCH=$(ARCH )
56+
57+ define build_native # (1=arch, 2=tar-arch)
3958IID_$(1 ) =$(1 ) _$(VERSION ) .iid
4059CID_$(1 ) =$(1 ) _$(VERSION ) .cid
4160
42- build_x64 :
43- @docker build --iidfile $$(IID_$(1 ) ) -t redisfab/$(STEM ) -$(1 ) : $( VERSION ) -f Dockerfile.x64 \
44- --build-arg OS= $( DOCKER_OS ) $( ROOT )
61+ build_native :
62+ @docker build --iidfile $$(IID_$(1 ) ) -t redisfab/$(STEM ) : $( VERSION ) -$(DEVICE ) - $( 1 ) -f Dockerfile.$( VARIANT ) \
63+ $( foreach A, $( DOCKER_BUILD_ARGS ) , --build-arg $( A ) ) .
4564 @docker create --cidfile $$(CID_$(1 ) ) `cat $$(IID_$(1 ) ) `
46- @docker cp `cat $$(CID_$(1 ) ) `:/build/dest/$(STEM ) -$(2 ) -$(VERSION ) .tar.gz .
65+ @docker cp `cat $$(CID_$(1 ) ) `:/build/dest/$(STEM ) -$(DEVICE ) - $( OS ) - $( 2 ) -$(VERSION ) .tar.gz .
4766
48- .PHONY: build_x64
67+ .PHONY: build_native
4968endef
5069
70+ ifeq ($(CROSS ) ,1)
71+
5172define build_arm # (1=arch, 2=tar-arch)
5273IID_$(1 ) =$(1 ) _$(VERSION ) .iid
5374CID_$(1 ) =$(1 ) _$(VERSION ) .cid
5475
5576build_$(1 ) :
56- @docker build --iidfile $$(IID_$(1 ) ) -t redisfab/$(STEM ) -$(1 ) : $( VERSION ) -f Dockerfile.arm \
57- --build-arg ARCH= $( 1 ) $( ROOT )
77+ @docker build --iidfile $$(IID_$(1 ) ) -t redisfab/$(STEM ) : $( VERSION ) -$(DEVICE ) - $( 1 ) -f Dockerfile.$( VARIANT ) \
78+ $( foreach A, $( DOCKER_BUILD_ARGS ) , --build-arg $( A ) ) .
5879 @docker create --cidfile $$(CID_$(1 ) ) `cat $$(IID_$(1 ) ) `
5980 @docker cp `cat $$(CID_$(1 ) ) `:/build/$(STEM ) -$(2 ) -$(VERSION ) .tar.gz .
6081
6182.PHONY: build_$(1 )
6283endef
6384
85+ endif # CROSS
86+
6487# ----------------------------------------------------------------------------------------------
6588
66- define publish_x64 # (1=arch, 2=tar-arch)
67- publish_x64 :
89+ define publish_native # (1=arch, 2=tar-arch)
90+ publish_native :
6891 @aws s3 cp $(STEM ) -$(2 ) -$(VERSION ) .tar.gz s3://$(S3_URL ) / --acl public-read
6992
70- .PHONY: publish_x64
93+ .PHONY: publish_native
7194endef
7295
96+ ifeq ($(CROSS ) ,1)
97+
7398define publish_arm # (1=arch, 2=tar-arch)
7499publish_$(1 ) :
75100 @aws s3 cp $(STEM ) -$(2 ) -$(VERSION ) .tar.gz s3://$(S3_URL ) / --acl public-read
76101
77102.PHONY: publish_$(1 )
78103endef
79104
105+ endif # CROSS
106+
80107# ----------------------------------------------------------------------------------------------
81108
82109all : build publish
83110
84111build : $(BUILD_TARGETS )
85112
86- $(eval $(call build_x64,x64,x86_64))
113+ $(eval $(call build_native,$(ARCH),$(TAR_ARCH.$(ARCH))))
114+ ifeq ($(CROSS ) ,1)
87115$(eval $(call build_arm,arm64v8,arm64))
88116$(eval $(call build_arm,arm32v7,arm))
117+ endif
89118
90119ifneq ($(filter publish,$(MAKECMDGOALS ) ) ,)
91120ifeq ($(wildcard $(HOME ) /.aws/credentials) ,)
@@ -96,13 +125,16 @@ endif
96125publish : $(PUBLISH_TARGETS )
97126
98127$(eval $(call publish_x64,x64,x86_64))
128+ ifeq ($(CROSS ) ,1)
99129$(eval $(call publish_arm,arm64v8,arm64))
100130$(eval $(call publish_arm,arm32v7,arm))
131+ endif
101132
102133repack :
103134 @PT_VERSION=$(VERSION ) GPU=$(GPU ) ./repack.sh
104135
105136help :
106- @echo " make [build|repack|publish] [X64=1|ARM7=1|ARM8=1]"
137+ @echo " make [build|repack|publish] [X64=1|ARM7=1|ARM8=1] [CROSS=1] "
107138
108139.PHONY : all build repack publish help
140+
0 commit comments