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

131 lines, 74 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
96 # devtools/release.sh also has this DWARF 4 hack, for bloaty
97 for variant in dbg opt; do
98 CXXFLAGS=-gdwarf-4 _build/oils.sh '' $variant
99 done
100
101 build/native.sh tarball-demo
102
103 if test -n "$install"; then
104 sudo ./install
105 fi
106 popd
107
108 git add oils-for-unix-$OILS_VERSION
109
110 git status
111 echo "Now run git commit"
112
113 popd
114}
115
116#
117# Repro bug #1731 -- passing duplicate files to tar results in weird hard
118# links!
119#
120
121install-bsdtar() {
122 sudo apt-get install libarchive-tools
123}
124
125test-with-bsdtar() {
126 pushd _release
127 bsdtar -x < oils-for-unix.tar
128 popd
129}
130
131"$@"