File tree 9 files changed +266
-0
lines changed
9 files changed +266
-0
lines changed Original file line number Diff line number Diff line change
1
+ LINUX_PACKAGES = "make \
2
+ autoconf \
3
+ automake \
4
+ build-essential \
5
+ cargo \
6
+ curl \
7
+ git \
8
+ libtool \
9
+ ninja-build \
10
+ pkg-config \
11
+ python3.12 \
12
+ python3.12-dev \
13
+ python3.12-venv \
14
+ python3-pip \
15
+ unzip \
16
+ zip \
17
+ nano"
18
+
19
+ MACOS_PACKAGES = "make \
20
+ autoconf \
21
+ automake \
22
+ rust \
23
+ curl \
24
+ git \
25
+ libtool \
26
+ ninja \
27
+ pkg-config \
28
+ python@3.12 \
29
+ unzip \
30
+ zip"
31
+
32
+ CMAKE_VERSION = 3.31.1
33
+ VCPKG_FORCE_SYSTEM_BINARIES = 1
34
+ DEBIAN_FRONTEND = noninteractive
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ set -euo pipefail
3
+ # set -x
4
+
5
+ detect_os () {
6
+ if [[ " $OSTYPE " == " linux-gnu" * ]]; then
7
+ if command -v apt > /dev/null 2>&1 ; then
8
+ echo " linux_deb"
9
+ else
10
+ echo " linux_other"
11
+ fi
12
+ elif [[ " $OSTYPE " == " darwin" * ]]; then
13
+ echo " macos"
14
+ else
15
+ echo " unknown"
16
+ fi
17
+ }
18
+
19
+ if [[ " ${BASH_SOURCE[0]} " == " ${0} " ]]; then
20
+ echo " This script is intended to be sourced or used as a library."
21
+ echo " Exported functions: detect_os"
22
+ exit 1
23
+ fi
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ set -euo pipefail
3
+ # set -x
4
+ trap ' echo "=== Error on line $LINENO"; exit 1' ERR
5
+
6
+ SCRIPT_DIR=" $( dirname " ${BASH_SOURCE[0]} " ) "
7
+ OS_SELECT=$( source ${SCRIPT_DIR} /detect_os.sh && detect_os)
8
+
9
+ set -o allexport && . ${SCRIPT_DIR} /../.env && set +o allexport
10
+
11
+ main () {
12
+ case " $OS_SELECT " in
13
+ linux_deb)
14
+ echo " === Detected Linux system with apt"
15
+ apt update && apt install -y $LINUX_PACKAGES
16
+ ;;
17
+ linux_other)
18
+ echo " === Detected Linux system without apt"
19
+ echo " === Support for other package managers is not added"
20
+ ;;
21
+ macos)
22
+ echo " === Detected macOS system"
23
+ if command -v brew > /dev/null 2>&1 ; then
24
+ echo " === Homebrew found. Installing packages..."
25
+ brew update && brew install $MACOS_PACKAGES
26
+ else
27
+ echo " === Homebrew is not installed. Install it before proceeding: https://brew.sh"
28
+ fi
29
+ ;;
30
+ * )
31
+ echo " === Unknown system"
32
+ ;;
33
+ esac
34
+ }
35
+
36
+ main
37
+
38
+ exit 0
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ set -euo pipefail
3
+ # set -x
4
+
5
+ init_py () {
6
+ echo " $VENV "
7
+ python3 -m venv " $VENV "
8
+ source $VENV /bin/activate
9
+ pip3 install cmake==${CMAKE_VERSION}
10
+ pip3 install --no-cache-dir -r ${PROJECT} /python/requirements.txt
11
+ }
12
+
13
+ if [[ " ${BASH_SOURCE[0]} " == " ${0} " ]]; then
14
+ echo " This script is intended to be sourced or used as a library."
15
+ echo " Exported functions: init_py"
16
+ exit 1
17
+ fi
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ set -euo pipefail
3
+ # set -x
4
+
5
+ init_vcpkg () {
6
+ if [[ ! -e $VCPKG ]]; then
7
+ git clone https://github.com/microsoft/vcpkg.git $VCPKG
8
+ fi
9
+ if [[ ! -e $VCPKG /vcpkg ]]; then
10
+ $VCPKG /bootstrap-vcpkg.sh -disableMetrics
11
+ fi
12
+ }
13
+
14
+ if [[ " ${BASH_SOURCE[0]} " == " ${0} " ]]; then
15
+ echo " This script is intended to be sourced or used as a library."
16
+ echo " Exported functions: init_vcpkg"
17
+ exit 1
18
+ fi
Original file line number Diff line number Diff line change 35
35
.idea
36
36
37
37
/build
38
+ /.build
39
+ /.venv
40
+ /.vcpkg
Original file line number Diff line number Diff line change
1
+ SHELL := /bin/bash
2
+ PROJECT := $(shell pwd)
3
+ CI_DIR := $(PROJECT ) /.ci
4
+
5
+ VENV =$(PROJECT ) /.venv
6
+ BUILD =$(PROJECT ) /.build
7
+ VCPKG =$(PROJECT ) /.vcpkg
8
+ PATH =$(VENV ) /bin:$(shell echo $$PATH)
9
+
10
+ ifneq (,$(wildcard $(CI_DIR ) /.env) )
11
+ include $(CI_DIR ) /.env
12
+ export
13
+ endif
14
+
15
+ OS_TYPE := $(shell bash -c 'source $(CI_DIR ) /scripts/detect_os.sh && detect_os')
16
+
17
+
18
+ all : init_all configure build test
19
+
20
+ init_all : init init_py init_vcpkg
21
+
22
+ os :
23
+ @echo " === Detected OS: $( OS_TYPE) "
24
+
25
+ init :
26
+ @echo " === Initializing..."
27
+ $(CI_DIR ) /scripts/init.sh
28
+
29
+ init_py :
30
+ @echo " === Initializing Python..."
31
+ source $(CI_DIR ) /scripts/init_py.sh && init_py
32
+
33
+ init_vcpkg :
34
+ @echo " === Initializing Vcpkg..."
35
+ source $(CI_DIR ) /scripts/init_vcpkg.sh && init_vcpkg
36
+
37
+ configure :
38
+ @echo " === Configuring..."
39
+ VCPKG_ROOT=$(VCPKG ) cmake --preset=default -DPython3_EXECUTABLE=" $( VENV) /bin/python3" -B $(BUILD ) $(PROJECT )
40
+
41
+ build :
42
+ @echo " === Building..."
43
+ cmake --build $(BUILD )
44
+
45
+ test :
46
+ @echo " === Testing..."
47
+ ctest --test-dir $(BUILD )
48
+
49
+ clean_all :
50
+ @echo " === Cleaning..."
51
+ rm -rf $(VENV ) $(BUILD ) $(VCPKG )
52
+
53
+ .PHONY : all init_all os init init_py init_vcpkg configure build test clean_all
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env -S bash -e
2
+
3
+
4
+
5
+ # TODO(docker-volume): /root/.cache/pip
6
+ # TODO(docker-volume): /root/.cache/vcpkg
7
+ # TODO(docker-volume): /root/.cargo
8
+
9
+
10
+
11
+ # paths
12
+ PROJECT=/cpp-jam
13
+ VENV=$PROJECT .venv
14
+ BUILD=$PROJECT .build
15
+ VCPKG=/vcpkg
16
+
17
+
18
+
19
+ # DOCKER: FROM ubuntu:24.04 AS base
20
+
21
+ # apt install
22
+ apt update
23
+ DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \
24
+ autoconf \
25
+ automake \
26
+ build-essential \
27
+ cargo \
28
+ curl \
29
+ git \
30
+ libtool \
31
+ ninja-build \
32
+ pkg-config \
33
+ python3 \
34
+ python3-dev \
35
+ python3-pip \
36
+ python3-venv \
37
+ unzip \
38
+ zip \
39
+
40
+ # create python venv
41
+ python3 -m venv $VENV
42
+ PATH=$VENV /bin:$PATH
43
+
44
+ # install cmake
45
+ pip3 install cmake
46
+
47
+ # install vcpkg
48
+ export VCPKG_FORCE_SYSTEM_BINARIES=1
49
+ if [[ ! -e $VCPKG ]]; then
50
+ git clone https://github.com/microsoft/vcpkg.git $VCPKG
51
+ fi
52
+ if [[ ! -e $VCPKG /vcpkg ]]; then
53
+ $VCPKG /bootstrap-vcpkg.sh -disableMetrics
54
+ fi
55
+
56
+
57
+
58
+ # DOCKER: FROM base AS ci
59
+
60
+ # install project requirements
61
+ pip3 install -r $PROJECT /python/requirements.txt
62
+
63
+ # configure
64
+ rm -rf $BUILD
65
+ VCPKG_ROOT=$VCPKG cmake --preset=default -B $BUILD $PROJECT
66
+
67
+ # build
68
+ cmake --build $BUILD
69
+
70
+ # run tests
71
+ ctest --test-dir $BUILD
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env -S bash -e
2
+
3
+ LOCAL=$PWD
4
+
5
+ [[ -d $LOCAL /docker ]]
6
+
7
+ docker run --rm -it \
8
+ -v $LOCAL :/cpp-jam \
9
+ ubuntu:24.04 /cpp-jam/docker/ci-docker
You can’t perform that action at this time.
0 commit comments