OILS / deps / from-tar.sh View on Github | oilshell.org

90 lines, 43 significant
1#!/usr/bin/env bash
2#
3# Handle build dependencies that are in tarballs.
4#
5# Usage:
6# deps/from-tar.sh <function name>
7#
8# Examples:
9# deps/from-tar.sh download-re2c
10# deps/from-tar.sh build-re2c
11#
12# The executable will be in ../oil_DEPS/re2c/re2c.
13
14set -o nounset
15set -o pipefail
16set -o errexit
17
18REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
19readonly REPO_ROOT
20
21readonly DEPS_DIR=$REPO_ROOT/../oil_DEPS
22
23source build/common.sh # $PREPARE_DIR, $PY27
24
25clean-temp() {
26 ### Works for layer-bloaty now. TODO: re2c, cmark, Python 3, spec-bin
27 rm -r -f -v _cache/
28}
29
30configure-python() {
31 ### for both 2.7 OVM slice and 3.10 mycpp
32
33 local dir=${1:-$PREPARE_DIR}
34 local conf=${2:-$PWD/$PY27/configure}
35
36 rm -r -f $dir
37 mkdir -p $dir
38
39 pushd $dir
40 time $conf
41 popd
42}
43
44# Clang makes this faster. We have to build all modules so that we can
45# dynamically discover them with py-deps.
46#
47# Takes about 27 seconds on a fast i7 machine.
48# Ubuntu under VirtualBox on MacBook Air with 4 cores (3 jobs): 1m 25s with
49# -O2, 30 s with -O0. The Make part of the build is parallelized, but the
50# setup.py part is not!
51
52readonly NPROC=$(nproc)
53readonly JOBS=$(( NPROC == 1 ? NPROC : NPROC-1 ))
54
55build-python() {
56 local dir=${1:-$PREPARE_DIR}
57
58 pushd $dir
59 make clean
60 time make -j $JOBS
61 popd
62}
63
64layer-cpython() {
65 ### For bootstrapping OVM build
66
67 # TODO: can we do this with a wedge?
68 # $PREPARE_DIR is ../oil_DEPS/cpython-full, which we want to get rid of
69 configure-python
70 build-python
71}
72
73download-wild() {
74 ### Done outside the container
75
76 mkdir -p $REPO_ROOT/_cache
77 wget --directory $REPO_ROOT/_cache --no-clobber \
78 https://www.oilshell.org/blob/wild/wild-source.tar.gz
79}
80
81extract-wild() {
82 ### Done in the container build
83
84 mkdir -p $DEPS_DIR/wild/src
85 pushd $DEPS_DIR/wild/src
86 tar --extract -z < $REPO_ROOT/_cache/wild-source.tar.gz
87 popd
88}
89
90"$@"