OILS / deps / from-tar.sh View on Github | oils.pub

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