[ install ] Check if 'realpath' exists for Chez and Racket backends (#1210)

This commit is contained in:
Kamiλ Shakirov 2021-04-06 20:42:04 +06:00 committed by GitHub
parent 178f26ec17
commit 2ac4bea220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 148 additions and 106 deletions

View File

@ -9,12 +9,12 @@ trim_trailing_whitespace = true
charset = utf-8 charset = utf-8
# Idris source files # Idris source files
[{*.idr,*.ipkg,*.tex,*.yaff,*.lidr}] [*.{idr,ipkg,tex,yaff,lidr}]
indent_style = space indent_style = space
indent_size = 2 indent_size = 2
# Various configuration files # Various configuration files
[*.yml,.ecrc] [{*.yml,.ecrc}]
indent_style = space indent_style = space
indent_size = 2 indent_size = 2
@ -22,7 +22,7 @@ indent_size = 2
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
[{*.c,*.h}] [*.{c,h}]
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
@ -30,7 +30,13 @@ indent_size = 4
indent_style = space indent_style = space
indent_size = 2 indent_size = 2
[{*.sh,*.bat}] [*.sh]
indent_style = space
indent_size = 4
shell_variant = posix
switch_case_indent = true
[*.bat]
indent_style = space indent_style = space
indent_size = 4 indent_size = 4

31
.gitignore vendored
View File

@ -1,6 +1,3 @@
idris2docs_venv
result
*~
*.ibc *.ibc
*.ttc *.ttc
*.ttm *.ttm
@ -10,14 +7,9 @@ result
*.dll *.dll
*.dylib *.dylib
# Editor/IDE Related
.\#* # Emacs swap file
*~ # Vim swap file
# VS Code
.vscode/*
/build /build
idris2docs_venv
/docs/build /docs/build
/libs/**/build /libs/**/build
@ -27,22 +19,27 @@ result
/tests/**/*.so /tests/**/*.so
/tests/**/*.dylib /tests/**/*.dylib
/tests/**/*.dll /tests/**/*.dll
/tests/build/exec
/benchmark/**/build /benchmark/**/build
/benchmark/*.csv /benchmark/*.csv
/src/IdrisPaths.idr
/bootstrap/bin/ /bootstrap/bin/
/bootstrap/lib/ /bootstrap/lib/
/bootstrap/idris2-0*/ /bootstrap/idris2-[0-9]*/
/bootstrap/idris2_app/idris2-boot* /bootstrap/idris2_app/idris2-boot.*
/bootstrap/idris2_app/libidris2_support.* /bootstrap/idris2_app/libidris2_support.*
/bootstrap/idris2-boot
/bootstrap/idris2-boot.rkt /src/IdrisPaths.idr
/custom.mk /custom.mk
#Mac OS # NixOS
/result
# Editor/IDE Related
*~ # Vim swap file
.\#* # Emacs swap file
.vscode/* # VS Code
# macOS
.DS_Store .DS_Store

8
bootstrap-stage1-chez.sh Normal file → Executable file
View File

@ -1,15 +1,15 @@
#!/bin/sh #!/bin/sh
set -e # Exit on any error set -e # exit on any error
echo "bootstrapping SCHEME=$SCHEME IDRIS2_VERSION=$IDRIS2_VERSION"
if [ -z "$SCHEME" ] || [ -z "$IDRIS2_VERSION" ]; then if [ -z "$SCHEME" ] || [ -z "$IDRIS2_VERSION" ]; then
echo "Required ENV not set." echo "Required SCHEME or IDRIS2_VERSION env is not set."
if [ -z "$SCHEME" ]; then if [ -z "$SCHEME" ]; then
echo "Invoke with SCHEME=[name of chez scheme executable]" echo "Invoke with SCHEME=[name of chez scheme executable]"
fi fi
exit 1 exit 1
fi fi
echo "Bootstrapping SCHEME=$SCHEME IDRIS2_VERSION=$IDRIS2_VERSION"
# Compile the bootstrap scheme # Compile the bootstrap scheme
# TODO: Move boot-build to Makefile in bootstrap/Makefile # TODO: Move boot-build to Makefile in bootstrap/Makefile
@ -20,5 +20,5 @@ ${SCHEME} --script compile.ss
# Put the result in the usual place where the target goes # Put the result in the usual place where the target goes
mkdir -p ../build/exec mkdir -p ../build/exec
mkdir -p ../build/exec/idris2_app mkdir -p ../build/exec/idris2_app
install idris2-boot ../build/exec/idris2 install idris2-boot.sh ../build/exec/idris2
install idris2_app/* ../build/exec/idris2_app install idris2_app/* ../build/exec/idris2_app

8
bootstrap-stage1-racket.sh Normal file → Executable file
View File

@ -1,12 +1,12 @@
#!/bin/sh #!/bin/sh
set -e # Exit on any error set -e # exit on any error
echo "bootstrapping IDRIS2_VERSION=$IDRIS2_VERSION"
if [ -z "$IDRIS2_VERSION" ]; then if [ -z "$IDRIS2_VERSION" ]; then
echo "Required ENV not set." echo "Required IDRIS2_VERSION env is not set."
exit 1 exit 1
fi fi
echo "Bootstrapping IDRIS2_VERSION=$IDRIS2_VERSION"
# Compile the bootstrap scheme # Compile the bootstrap scheme
cd bootstrap cd bootstrap
@ -16,5 +16,5 @@ raco exe idris2_app/idris2-boot.rkt
# Put the result in the usual place where the target goes # Put the result in the usual place where the target goes
mkdir -p ../build/exec mkdir -p ../build/exec
mkdir -p ../build/exec/idris2_app mkdir -p ../build/exec/idris2_app
install idris2-rktboot ../build/exec/idris2 install idris2-rktboot.sh ../build/exec/idris2
install idris2_app/* ../build/exec/idris2_app install idris2_app/* ../build/exec/idris2_app

2
bootstrap-stage2.sh Normal file → Executable file
View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
set -e # Exit on any error set -e # exit on any error
PREFIX=$PWD/bootstrap PREFIX=$PWD/bootstrap

20
bootstrap/idris2-boot vendored
View File

@ -1,20 +0,0 @@
#!/bin/sh
case `uname -s` in
OpenBSD|FreeBSD|NetBSD)
DIR="`grealpath $0`"
;;
*)
DIR="`realpath $0`"
;;
esac
if test -z "${SCHEME}"; then
echo "SCHEME env var is not set" >&2
exit 1
fi
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:`dirname "$DIR"`/"idris2_app""
export PATH="`dirname "$DIR"`/"idris2_app":$PATH"
${SCHEME} --script "`dirname $DIR`"/"idris2_app/idris2-boot.so" "$@"

30
bootstrap/idris2-boot.sh vendored Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
set -e # exit on any error
if [ -z "$SCHEME" ]; then
echo "Required SCHEME env is not set."
exit 1
fi
case $(uname -s) in
OpenBSD | FreeBSD | NetBSD)
REALPATH="grealpath"
;;
*)
REALPATH="realpath"
;;
esac
if ! command -v "$REALPATH" >/dev/null; then
echo "$REALPATH is required for Chez code generator."
exit 1
fi
DIR=$(dirname "$($REALPATH "$0")")
LD_LIBRARY_PATH="$DIR/idris2_app":$LD_LIBRARY_PATH
PATH="$DIR/idris2_app":$PATH
export LD_LIBRARY_PATH PATH
${SCHEME} --script "$DIR/idris2_app/idris2-boot.so" "$@"

View File

@ -1,15 +0,0 @@
#!/bin/sh
case `uname -s` in
OpenBSD|FreeBSD|NetBSD)
DIR="`grealpath $0`"
;;
*)
DIR="`realpath $0`"
;;
esac
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:`dirname "$DIR"`/"idris2_app""
export PATH="`dirname "$DIR"`/"idris2_app":$PATH"
"`dirname $DIR`"/"idris2_app/idris2-boot" "$@"

31
bootstrap/idris2-rktboot.sh vendored Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
set -e # exit on any error
if [ -z "$IDRIS2_VERSION" ]; then
echo "Required IDRIS2_VERSION env is not set."
exit 1
fi
echo "Bootstrapping IDRIS2_VERSION=$IDRIS2_VERSION"
case $(uname -s) in
OpenBSD | FreeBSD | NetBSD)
REALPATH="grealpath"
;;
*)
REALPATH="realpath"
;;
esac
if ! command -v "$REALPATH" >/dev/null; then
echo "$REALPATH is required for Racket code generator."
exit 1
fi
DIR=$(dirname "$($REALPATH "$0")")
LD_LIBRARY_PATH="$DIR/idris2_app":$LD_LIBRARY_PATH
PATH="$DIR/idris2_app":$PATH
export LD_LIBRARY_PATH PATH
"$DIR/idris2_app/idris2-boot" "$@"

View File

@ -342,18 +342,26 @@ startChez : String -> String -> String
startChez appdir target = unlines startChez appdir target = unlines
[ "#!/bin/sh" [ "#!/bin/sh"
, "" , ""
, "case `uname -s` in " , "set -e # exit on any error"
, " OpenBSD|FreeBSD|NetBSD) "
, " DIR=\"`grealpath $0`\""
, " ;; "
, " "
, " *) "
, " DIR=\"`realpath $0`\" "
, " ;; "
, "esac "
, "" , ""
, "export LD_LIBRARY_PATH=\"`dirname \"$DIR\"`/\"" ++ appdir ++ "\":$LD_LIBRARY_PATH\"" , "case $(uname -s) in "
, "\"`dirname \"$DIR\"`\"/\"" ++ target ++ "\" \"$@\"" , " OpenBSD | FreeBSD | NetBSD)"
, " REALPATH=\"grealpath\" "
, " ;; "
, " "
, " *) "
, " REALPATH=\"realpath\" "
, " ;; "
, "esac "
, ""
, "if ! command -v \"$REALPATH\" >/dev/null; then "
, " echo \"$REALPATH is required for Chez code generator.\""
, " exit 1 "
, "fi "
, ""
, "DIR=$(dirname \"$($REALPATH \"$0\")\")"
, "export LD_LIBRARY_PATH=\"$DIR/" ++ appdir ++ "\":$LD_LIBRARY_PATH"
, "\"$DIR/" ++ target ++ "\" \"$@\""
] ]
startChezCmd : String -> String -> String -> String startChezCmd : String -> String -> String -> String
@ -367,10 +375,13 @@ startChezCmd chez appdir target = unlines
startChezWinSh : String -> String -> String -> String startChezWinSh : String -> String -> String -> String
startChezWinSh chez appdir target = unlines startChezWinSh chez appdir target = unlines
[ "#!/bin/sh" [ "#!/bin/sh"
, "DIR=\"`realpath \"$0\"`\"" , ""
, "set -e # exit on any error"
, ""
, "DIR=$(dirname \"$(realpath \"$0\")\")"
, "CHEZ=$(cygpath \"" ++ chez ++"\")" , "CHEZ=$(cygpath \"" ++ chez ++"\")"
, "export PATH=\"`dirname \"$DIR\"`/\"" ++ appdir ++ "\":$PATH\"" , "export PATH=\"$DIR/" ++ appdir ++ "\":$PATH"
, "\"$CHEZ\" --script \"$(dirname \"$DIR\")/" ++ target ++ "\" \"$@\"" , "\"$CHEZ\" --script \"$DIR/" ++ target ++ "\" \"$@\""
] ]
||| Compile a TT expression to Chez Scheme ||| Compile a TT expression to Chez Scheme

View File

@ -327,18 +327,26 @@ startRacket : String -> String -> String -> String
startRacket racket appdir target = unlines startRacket racket appdir target = unlines
[ "#!/bin/sh" [ "#!/bin/sh"
, "" , ""
, "case `uname -s` in " , "set -e # exit on any error"
, " OpenBSD|FreeBSD|NetBSD) "
, " DIR=\"`grealpath $0`\""
, " ;; "
, " "
, " *) "
, " DIR=\"`realpath $0`\" "
, " ;; "
, "esac "
, "" , ""
, "export LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:`dirname \"$DIR\"`/\"" ++ appdir ++ "\"\"" , "case $(uname -s) in "
, racket ++ "\"`dirname \"$DIR\"`\"/\"" ++ target ++ "\" \"$@\"" , " OpenBSD | FreeBSD | NetBSD)"
, " REALPATH=\"grealpath\" "
, " ;; "
, " "
, " *) "
, " REALPATH=\"realpath\" "
, " ;; "
, "esac "
, ""
, "if ! command -v \"$REALPATH\" >/dev/null; then "
, " echo \"$REALPATH is required for Racket code generator.\""
, " exit 1 "
, "fi "
, ""
, "DIR=$(dirname \"$($REALPATH \"$0\")\")"
, "export LD_LIBRARY_PATH=\"$DIR/" ++ appdir ++ "\":$LD_LIBRARY_PATH"
, racket ++ "\"$DIR/" ++ target ++ "\" \"$@\""
] ]
startRacketCmd : String -> String -> String -> String startRacketCmd : String -> String -> String -> String
@ -353,17 +361,10 @@ startRacketWinSh : String -> String -> String -> String
startRacketWinSh racket appdir target = unlines startRacketWinSh racket appdir target = unlines
[ "#!/bin/sh" [ "#!/bin/sh"
, "" , ""
, "case `uname -s` in " , "set -e # exit on any error"
, " OpenBSD|FreeBSD|NetBSD) "
, " DIR=\"`grealpath $0`\""
, " ;; "
, " "
, " *) "
, " DIR=\"`realpath $0`\" "
, " ;; "
, "esac "
, "" , ""
, "export PATH=\"`dirname \"$DIR\"`/\"" ++ appdir ++ "\":$PATH\"" , "DIR=$(dirname \"$(realpath \"$0\")\")"
, "export PATH=\"$DIR/" ++ appdir ++ "\":$PATH"
, racket ++ "\"" ++ target ++ "\" \"$@\"" , racket ++ "\"" ++ target ++ "\" \"$@\""
] ]

View File

@ -11,6 +11,7 @@ testbin:
clean: clean:
$(RM) -r build $(RM) -r build
$(RM) -r **/**/build
@find . -type f -name 'output' -exec rm -rf {} \; @find . -type f -name 'output' -exec rm -rf {} \;
@find . -type f -name '*.ttc' -exec rm -f {} \; @find . -type f -name '*.ttc' -exec rm -f {} \;
@find . -type f -name '*.ttm' -exec rm -f {} \; @find . -type f -name '*.ttm' -exec rm -f {} \;

View File

@ -1,5 +1,5 @@
case `uname -s` in case $(uname -s) in
OpenBSD|FreeBSD|NetBSD) OpenBSD | FreeBSD | NetBSD)
MAKE=gmake MAKE=gmake
;; ;;

View File

@ -1,5 +1,5 @@
case `uname -s` in case $(uname -s) in
OpenBSD|FreeBSD|NetBSD) OpenBSD | FreeBSD | NetBSD)
MAKE=gmake MAKE=gmake
;; ;;

View File

@ -1,5 +1,5 @@
case `uname -s` in case $(uname -s) in
OpenBSD|FreeBSD|NetBSD) OpenBSD | FreeBSD | NetBSD)
MAKE=gmake MAKE=gmake
;; ;;