forked from IntelligentSoftwareSystems/Galois
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
131 lines (112 loc) · 3.59 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
SHELL := /bin/bash
UNAME ?= $(shell whoami)
UID ?= $(shell id -u)
GID ?= $(shell id -g)
BASE_IMAGE_NAME ?= pando-galois
IMAGE_NAME ?= ${UNAME}-${BASE_IMAGE_NAME}
SRC_DIR ?= $(shell pwd)
VERSION ?= $(shell git log --pretty="%h" -1 Dockerfile)
CONTAINER_SRC_DIR ?= /pando-galois
CONTAINER_BUILD_DIR ?= /pando-galois/build
CONTAINER_WORKDIR ?= ${CONTAINER_SRC_DIR}
CONTAINER_CONTEXT ?= default
CONTAINER_OPTS ?=
CONTAINER_CPUSET ?=
CONTAINER_CMD ?= bash -l
INTERACTIVE ?= i
BUILD_TYPE ?= RelWithDebInfo
# CMake variables
GALOIS_EXTRA_CMAKE_FLAGS ?= ""
GALOIS_EXTRA_CXX_FLAGS ?= ""
# Developer variables that should be set as env vars in startup files like .profile
GALOIS_CONTAINER_MOUNTS ?=
GALOIS_CONTAINER_ENV ?=
GALOIS_CONTAINER_FLAGS ?=
GALOIS_BUILD_TOOL ?= 'Unix Makefiles'
GALOIS_CCACHE_DIR ?= ${SRC_DIR}/.ccache
dependencies: dependencies-asdf
dependencies-asdf:
@echo "Updating asdf plugins..."
@asdf plugin update --all >/dev/null 2>&1 || true
@echo "Adding new asdf plugins..."
@cut -d" " -f1 ./.tool-versions | xargs -I % asdf plugin-add % >/dev/null 2>&1 || true
@echo "Installing asdf tools..."
@cat ./.tool-versions | xargs -I{} bash -c 'asdf install {}'
@echo "Updating local environment to use proper tool versions..."
@cat ./.tool-versions | xargs -I{} bash -c 'asdf local {}'
@asdf reshim
@echo "Done!"
hooks:
@pre-commit install --hook-type pre-commit
@pre-commit install-hooks
pre-commit:
@pre-commit run -a
ci-image:
@${MAKE} docker-image-dependencies
@docker image inspect galois:${VERSION} >/dev/null 2>&1 || \
docker --context ${CONTAINER_CONTEXT} build \
--build-arg SRC_DIR=${CONTAINER_SRC_DIR} \
--build-arg BUILD_DIR=${CONTAINER_BUILD_DIR} \
--build-arg UNAME=runner \
--build-arg UID=1078 \
--build-arg GID=504 \
-t galois:${VERSION} \
--file Dockerfile \
--target dev .
docker-image:
@${MAKE} docker-image-dependencies
@docker image inspect ${IMAGE_NAME}:${VERSION} >/dev/null 2>&1 || \
docker --context ${CONTAINER_CONTEXT} build \
--build-arg SRC_DIR=${CONTAINER_SRC_DIR} \
--build-arg BUILD_DIR=${CONTAINER_BUILD_DIR} \
--build-arg UNAME=${UNAME} \
--build-arg IS_CI=false \
--build-arg UID=${UID} \
--build-arg GID=${GID} \
-t ${IMAGE_NAME}:${VERSION} \
--file Dockerfile \
--target dev .
docker-image-dependencies:
@mkdir -p build
@mkdir -p data
@mkdir -p .ccache
.PHONY: docker
docker:
@docker --context ${CONTAINER_CONTEXT} run --rm \
-v ${SRC_DIR}/:${CONTAINER_SRC_DIR} \
-v ${GALOIS_CCACHE_DIR}/:/home/${UNAME}/.ccache \
${GALOIS_CONTAINER_MOUNTS} \
${GALOIS_CONTAINER_ENV} \
${GALOIS_CONTAINER_FLAGS} \
${CONTAINER_CPUSET} \
--privileged \
--workdir=${CONTAINER_WORKDIR} \
${CONTAINER_OPTS} \
-${INTERACTIVE}t \
${IMAGE_NAME}:${VERSION} \
${CONTAINER_CMD}
run-cmake:
@cmake \
-S ${SRC_DIR} \
-B ${BUILD_DIR} \
-G ${GALOIS_BUILD_TOOL} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DUSE_MKL_BLAS=ON \
-DGALOIS_ENABLE_DIST=ON \
${GALOIS_EXTRA_CMAKE_FLAGS}
setup: run-cmake
setup-ci: run-cmake
run-tests:
@ctest --test-dir build -R wmd --verbose
@ctest --test-dir build -R large-vec --verbose
@ctest --test-dir build -R compile-lscsr --verbose
@ctest --test-dir build -R prefixsum --verbose
@ctest --test-dir build -R wfl --verbose
# this command is slow since hooks are not stored in the container image
# this is mostly for CI use
docker-pre-commit:
@docker --context ${CONTAINER_CONTEXT} run --rm \
-v ${SRC_DIR}/:${CONTAINER_SRC_DIR} --privileged \
--workdir=${CONTAINER_WORKDIR} -t \
${IMAGE_NAME}:${VERSION} bash -lc "git config --global --add safe.directory /pando-galois && make hooks && make pre-commit"