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

134 lines, 76 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 # Generate code with the mycpp-souffle translator
41 ninja _gen/bin/oils_for_unix.mycpp-souffle.cc
42
43 local sed_expr="s,^,${app_name}-${OILS_VERSION}/,"
44 tarball-manifest | xargs -- tar --create --transform "$sed_expr" --file $tar
45
46 local tar_gz=_release/${app_name}-${OILS_VERSION}.tar.gz
47 gzip -c $tar > $tar_gz
48
49 ls -l _release
50}
51
52test-tar() {
53 local install=${1:-}
54 local translator=${2:-mycpp}
55
56 local tmp=_tmp/native-tar-test # like oil-tar-test
57 rm -r -f $tmp
58 mkdir -p $tmp
59 cd $tmp
60 tar -x < ../../_release/oils-for-unix.tar
61
62 pushd oils-for-unix-$OILS_VERSION
63 build/native.sh tarball-demo $translator
64
65 if test -n "$install"; then
66 sudo ./install
67 fi
68
69 popd
70}
71
72test-install-tar() {
73 ### test that sudo ./install works
74
75 # This is run in the raw-vm soil task
76
77 test-tar T
78}
79
80extract-for-benchmarks() {
81 local install=${1:-}
82
83 local tar=$PWD/_release/oils-for-unix.tar
84 local dest='../benchmark-data/src'
85 mkdir -p $dest
86
87 pushd $dest
88 git pull
89 tar -x < $tar
90
91 # For benchmarks
92 pushd oils-for-unix-$OILS_VERSION
93
94 # Remove binaries left over from old attempts
95 rm -v _bin/cxx-{dbg,opt}-sh/* || true
96
97 ./configure
98
99 # devtools/release.sh also has this DWARF 4 hack, for bloaty
100 for variant in dbg opt; do
101 CXXFLAGS=-gdwarf-4 _build/oils.sh '' $variant
102 done
103
104 build/native.sh tarball-demo
105
106 if test -n "$install"; then
107 sudo ./install
108 fi
109 popd
110
111 git add oils-for-unix-$OILS_VERSION
112
113 git status
114 echo "Now run git commit"
115
116 popd
117}
118
119#
120# Repro bug #1731 -- passing duplicate files to tar results in weird hard
121# links!
122#
123
124install-bsdtar() {
125 sudo apt-get install libarchive-tools
126}
127
128test-with-bsdtar() {
129 pushd _release
130 bsdtar -x < oils-for-unix.tar
131 popd
132}
133
134"$@"