Skip to content

Commit a1da396

Browse files
committed
pf
1 parent 4b715d6 commit a1da396

5 files changed

Lines changed: 22 additions & 35 deletions

File tree

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

pkgs/roc/platforms/go/dynhost

0 Bytes
Binary file not shown.

pkgs/roc/platforms/go/linux-x64.rh

0 Bytes
Binary file not shown.

pkgs/roc/scripts/build.sh

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ usage() {
66
echo "usage: $0 [--platform p] [--app a] [--static] [--skip-run]"
77
exit 1
88
}
9-
9+
trap 'echo aborted; exit 1' INT ERR
1010
platform=${PLATFORM:-go}
1111
application=${APPLICATION:-hello}
1212
static=0
1313
skip_run=0
14-
1514
eval set -- "$(getopt -o "" --long platform:,app:,static,skip-run,help -- "$@")"
1615
if [[ $# -gt 1 ]]; then
1716
while true; do
@@ -60,47 +59,35 @@ if [[ $# -gt 1 ]]; then
6059
fi
6160
platform=${platform:-go}
6261
application=${application:-hello}
63-
6462
platform_path=${PLATFORM_PATH:-platforms/${platform}}
6563
app_path=${APPLICATION_PATH:-applications/${application}/${platform}}
66-
67-
[[ -d $platform_path && -d $app_path ]] ||
68-
{
69-
echo "missing dirs: $platform_path or $app_path"
70-
exit 1
71-
}
72-
if [ ! -d "$platform_path/Lib" ]; then
73-
ln -s ../../lib "$platform_path/Lib"
64+
if [[ ! -d $app_path ]]; then
65+
echo "missing dir: $app_path"
66+
exit 1
7467
fi
7568
if [ ! -d "$app_path/Lib" ]; then
7669
ln -s ../../../lib "$app_path/Lib"
7770
fi
7871
app_main=$app_path/main.roc
7972
app_lib=$app_path/libapp.so
8073
rm -f "$app_lib" 2>/dev/null || true
81-
host_main=$platform_path/main.roc
82-
host_bin=$platform_path/dynhost
83-
rm -f "$host_bin" 2>/dev/null || true
84-
85-
trap 'echo aborted; exit 1' INT ERR
86-
8774
roc build --lib "$app_main" --output "$app_lib"
88-
89-
# ------------ key fixes -----------------
90-
abs_app_dir=$(realpath "$app_path") # compute BEFORE pushd
91-
rel_app_dir="../applications/${application}/${platform}" # runtime rpath
92-
# ----------------------------------------
93-
94-
pushd "$platform_path" >/dev/null
95-
96-
export CGO_LDFLAGS="-L${abs_app_dir} -Wl,-rpath,'\$ORIGIN/${rel_app_dir}'"
97-
98-
ldflags=()
99-
((static)) && ldflags=(-ldflags "-extldflags=-static")
100-
101-
go build -buildmode=pie "${ldflags[@]}" -o "$(basename "$host_bin")"
102-
popd >/dev/null
103-
unset CGO_LDFLAGS
104-
105-
roc preprocess-host "$host_bin" "$host_main" "$app_lib"
75+
abs_app_dir=$(realpath "$app_path")
76+
rel_app_dir="../applications/${application}/${platform}"
77+
if [[ -d "$platform_path" ]]; then
78+
if [ ! -d "$platform_path/Lib" ]; then
79+
ln -s ../../lib "$platform_path/Lib"
80+
fi
81+
host_main=$platform_path/main.roc
82+
host_bin=$platform_path/dynhost
83+
rm -f "$host_bin" 2>/dev/null || true
84+
pushd "$platform_path" >/dev/null
85+
export CGO_LDFLAGS="-L${abs_app_dir} -Wl,-rpath,'\$ORIGIN/${rel_app_dir}'"
86+
ldflags=()
87+
((static)) && ldflags=(-ldflags "-extldflags=-static")
88+
go build -buildmode=pie "${ldflags[@]}" -o "$(basename "$host_bin")"
89+
popd >/dev/null
90+
unset CGO_LDFLAGS
91+
roc preprocess-host "$host_bin" "$host_main" "$app_lib"
92+
fi
10693
((skip_run)) || roc "$app_main"

0 commit comments

Comments
 (0)