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

101 lines, 46 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 #set -x
68
69 # We need 'python' in $PATH to build Python, not just 'python2'
70 # TODO: Move this whole thing to a wedge
71 ln -s --relative --verbose ../oils.DEPS/wedge/python2/2.7.18/bin/python ../oils.DEPS/bin/
72
73 # like build/dev-shell.sh
74 PATH="$REPO_ROOT/../oils.DEPS/bin:$PATH"
75
76 which python
77
78 # TODO: can we do this with a wedge?
79 # $PREPARE_DIR is ../oil_DEPS/cpython-full, which we want to get rid of
80 configure-python
81 build-python
82}
83
84download-wild() {
85 ### Done outside the container
86
87 mkdir -p $REPO_ROOT/_cache
88 wget --directory-prefix $REPO_ROOT/_cache --no-clobber \
89 https://www.oilshell.org/blob/wild/wild-source.tar.gz
90}
91
92extract-wild() {
93 ### Done in the container build
94
95 mkdir -p $DEPS_DIR/wild/src
96 pushd $DEPS_DIR/wild/src
97 tar --extract -z < $REPO_ROOT/_cache/wild-source.tar.gz
98 popd
99}
100
101"$@"