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

120 lines, 70 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
16OIL_VERSION=$(head -n 1 oil-version.txt)
17readonly OIL_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}-${OIL_VERSION}/,"
42 tarball-manifest | xargs -- tar --create --transform "$sed_expr" --file $tar
43
44 local tar_gz=_release/${app_name}-${OIL_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-$OIL_VERSION
60 build/native.sh tarball-demo
61
62 if test -n "$install"; then
63 sudo ./install
64 fi
65
66 popd
67}
68
69extract-for-benchmarks() {
70 local install=${1:-}
71
72 local tar=$PWD/_release/oils-for-unix.tar
73 local dest='../benchmark-data/src'
74 mkdir -p $dest
75
76 pushd $dest
77 git pull
78 tar -x < $tar
79
80 # For benchmarks
81 pushd oils-for-unix-$OIL_VERSION
82
83 # Remove binaries left over from old attempts
84 rm -v _bin/cxx-{dbg,opt}-sh/* || true
85
86 ./configure
87 _build/oils.sh '' dbg
88 _build/oils.sh '' opt
89
90 build/native.sh tarball-demo
91
92 if test -n "$install"; then
93 sudo ./install
94 fi
95 popd
96
97 git add oils-for-unix-$OIL_VERSION
98
99 git status
100 echo "Now run git commit"
101
102 popd
103}
104
105#
106# Repro bug #1731 -- passing duplicate files to tar results in weird hard
107# links!
108#
109
110install-bsdtar() {
111 sudo apt-get install libarchive-tools
112}
113
114test-with-bsdtar() {
115 pushd _release
116 bsdtar -x < oils-for-unix.tar
117 popd
118}
119
120"$@"