Skip to content

Commit

Permalink
Option to specify alternate directory to output build to (apache#6016)
Browse files Browse the repository at this point in the history
This is useful when you would like to manage 2 separate builds in the same tvm tree. You can specify a build directory when using make by adding OUTDIR=alternate-build-dir.

Change-Id: I3efed1135343f3903007115ce5dd683ef7bd9e8c
  • Loading branch information
lhutton1 authored and Trevor Morris committed Jul 14, 2020
1 parent 2a86542 commit 7ecb3b5
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# under the License.

ROOTDIR = $(CURDIR)
# Specify an alternate output directory relative to ROOTDIR. Default build
OUTPUTDIR = $(if $(OUTDIR), $(OUTDIR), build)

.PHONY: clean all test doc pylint cpplint scalalint lint\
cython cython2 cython3 web runtime vta
Expand All @@ -38,16 +40,16 @@ PKG_LDFLAGS =


all:
@mkdir -p build && cd build && cmake .. && $(MAKE)
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE)

runtime:
@mkdir -p build && cd build && cmake .. && $(MAKE) runtime
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE) runtime

vta:
@mkdir -p build && cd build && cmake .. && $(MAKE) vta
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE) vta

cpptest:
@mkdir -p build && cd build && cmake .. && $(MAKE) cpptest
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE) cpptest

# EMCC; Web related scripts
EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\
Expand All @@ -57,17 +59,17 @@ EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\
-s USE_GLFW=3 -s USE_WEBGL2=1 -lglfw\
$(INCLUDE_FLAGS)

web: build/libtvm_web_runtime.js build/libtvm_web_runtime.bc
web: $(OUTPUTDIR)/libtvm_web_runtime.js $(OUTPUTDIR)/libtvm_web_runtime.bc

build/libtvm_web_runtime.bc: web/web_runtime.cc
@mkdir -p build/web
$(OUTPUTDIR)/libtvm_web_runtime.bc: web/web_runtime.cc
@mkdir -p $(OUTPUTDIR)/web
@mkdir -p $(@D)
emcc $(EMCC_FLAGS) -MM -MT build/libtvm_web_runtime.bc $< >build/web/web_runtime.d
emcc $(EMCC_FLAGS) -MM -MT $(OUTPUTDIR)/libtvm_web_runtime.bc $< >$(OUTPUTDIR)/web/web_runtime.d
emcc $(EMCC_FLAGS) -o $@ web/web_runtime.cc

build/libtvm_web_runtime.js: build/libtvm_web_runtime.bc
$(OUTPUTDIR)/libtvm_web_runtime.js: $(OUTPUTDIR)/libtvm_web_runtime.bc
@mkdir -p $(@D)
emcc $(EMCC_FLAGS) -o $@ build/libtvm_web_runtime.bc
emcc $(EMCC_FLAGS) -o $@ $(OUTPUTDIR)/libtvm_web_runtime.bc

# Lint scripts
cpplint:
Expand Down Expand Up @@ -128,13 +130,13 @@ jvmpkg:
(cd $(ROOTDIR)/jvm; \
mvn clean package -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \
-Dcflags="$(PKG_CFLAGS)" -Dldflags="$(PKG_LDFLAGS)" \
-Dcurrent_libdir="$(ROOTDIR)/build" $(JVM_TEST_ARGS))
-Dcurrent_libdir="$(ROOTDIR)/$(OUTPUTDIR)" $(JVM_TEST_ARGS))
jvminstall:
(cd $(ROOTDIR)/jvm; \
mvn install -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \
-Dcflags="$(PKG_CFLAGS)" -Dldflags="$(PKG_LDFLAGS)" \
-Dcurrent_libdir="$(ROOTDIR)/build" $(JVM_TEST_ARGS))
-Dcurrent_libdir="$(ROOTDIR)/$(OUTPUTDIR)" $(JVM_TEST_ARGS))

# clean rule
clean:
@mkdir -p build && cd build && cmake .. && $(MAKE) clean
@mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR) && cmake .. && $(MAKE) clean

0 comments on commit 7ecb3b5

Please sign in to comment.