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

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