OILS / devtools / release-native.sh View on Github | oilshell.org

128 lines, 73 significant
1#!/usr/bin/env bash
2#
3# Make a tarball containing native (C++) code.
4#
5# Usage:
6# devtools/release-native.sh <function name>
7
8set -o nounset
9set -o pipefail
10set -o errexit
11shopt -s strict:all 2>/dev/null || true # dogfood for OSH
12
13# adapted from build/ovm-compile.sh
14# and devtools/release.sh
15
16OILS_VERSION=$(head -n 1 oil-version.txt)
17readonly OILS_VERSION
18
19gen-oils-sh() {
20 PYTHONPATH=. build/ninja_main.py shell
21 chmod +x _build/oils.sh
22}
23
24tarball-manifest() {
25 # 100 files
26 PYTHONPATH=. build/ninja_main.py tarball-manifest
27}
28
29make-tar() {
30 local app_name='oils-for-unix'
31
32 local tar=_release/${app_name}.tar
33
34 # NOTE: Could move this to the Makefile, which will make it
35 mkdir -p _release
36
37 gen-oils-sh
38 # Build default target to generate code
39 ninja
40
41 local sed_expr="s,^,${app_name}-${OILS_VERSION}/,"
42 tarball-manifest | xargs -- tar --create --transform "$sed_expr" --file $tar
43
44 local tar_gz=_release/${app_name}-${OILS_VERSION}.tar.gz
45 gzip -c $tar > $tar_gz
46
47 ls -l _release
48}
49
50test-tar() {
51 local install=${1:-}
52
53 local tmp=_tmp/native-tar-test # like oil-tar-test
54 rm -r -f $tmp
55 mkdir -p $tmp
56 cd $tmp
57 tar -x < ../../_release/oils-for-unix.tar
58
59 pushd oils-for-unix-$OILS_VERSION
60 build/native.sh tarball-demo
61
62 if test -n "$install"; then
63 sudo ./install
64 fi
65
66 popd
67}
68
69test-install-tar() {
70 ### test that sudo ./install works
71
72 # This is run in the raw-vm soil task
73
74 test-tar T
75}
76
77extract-for-benchmarks() {
78 local install=${1:-}
79
80 local tar=$PWD/_release/oils-for-unix.tar
81 local dest='../benchmark-data/src'
82 mkdir -p $dest
83
84 pushd $dest
85 git pull
86 tar -x < $tar
87
88 # For benchmarks
89 pushd oils-for-unix-$OILS_VERSION
90
91 # Remove binaries left over from old attempts
92 rm -v _bin/cxx-{dbg,opt}-sh/* || true
93
94 ./configure
95 _build/oils.sh '' dbg
96 _build/oils.sh '' opt
97
98 build/native.sh tarball-demo
99
100 if test -n "$install"; then
101 sudo ./install
102 fi
103 popd
104
105 git add oils-for-unix-$OILS_VERSION
106
107 git status
108 echo "Now run git commit"
109
110 popd
111}
112
113#
114# Repro bug #1731 -- passing duplicate files to tar results in weird hard
115# links!
116#
117
118install-bsdtar() {
119 sudo apt-get install libarchive-tools
120}
121
122test-with-bsdtar() {
123 pushd _release
124 bsdtar -x < oils-for-unix.tar
125 popd
126}
127
128"$@"