2024-04-16 16:16:32 +03:00
|
|
|
# set to non-empty string to disable parallel builds and tests
|
2024-02-02 14:48:14 +03:00
|
|
|
#
|
|
|
|
# e.g:
|
|
|
|
# just disableParallel=yes test
|
|
|
|
disableParallel := ''
|
|
|
|
|
2024-05-15 13:54:50 +03:00
|
|
|
# set to non-empty string to disable optimized build
|
2024-02-02 14:48:14 +03:00
|
|
|
#
|
|
|
|
# e.g:
|
2024-05-15 13:54:50 +03:00
|
|
|
# just disableOptimized=yes install
|
|
|
|
disableOptimized := ''
|
2024-02-02 14:48:14 +03:00
|
|
|
|
|
|
|
# set to non-empty string to enable command debugging
|
|
|
|
enableDebug := ''
|
|
|
|
|
2024-06-08 10:44:43 +03:00
|
|
|
# set to non-empty string to enable pedantic mode
|
|
|
|
pedantic := ''
|
|
|
|
|
2024-04-16 16:16:32 +03:00
|
|
|
# set to number of parallel jobs
|
|
|
|
numParallelJobs := ''
|
|
|
|
|
2024-02-02 14:48:14 +03:00
|
|
|
# the command used to run stack
|
|
|
|
stack := "stack"
|
|
|
|
|
|
|
|
# the command used to run ormolu
|
|
|
|
ormolu := "ormolu"
|
|
|
|
|
2024-04-18 13:52:37 +03:00
|
|
|
# The CC argument to the runtime Makefile
|
|
|
|
runtimeCcArg := ''
|
|
|
|
|
|
|
|
# The LIBTOOL argument to the runtime Makefile
|
|
|
|
runtimeLibtoolArg := ''
|
|
|
|
|
|
|
|
# The flags used in the runtime make commands
|
|
|
|
runtimeCcFlag := if runtimeCcArg == '' { '' } else { "CC=" + runtimeCcArg }
|
|
|
|
runtimeLibtoolFlag := if runtimeLibtoolArg == '' { '' } else { "LIBTOOL=" + runtimeLibtoolArg }
|
|
|
|
runtimeArgs := trim(runtimeCcFlag + ' ' + runtimeLibtoolFlag)
|
|
|
|
|
2024-02-02 14:48:14 +03:00
|
|
|
# flags used in the stack command
|
2024-06-08 10:44:43 +03:00
|
|
|
stackOptFlag := (if disableOptimized == '' { '' } else { '--fast' }) + ' ' + (if pedantic == '' { '' } else { '--pedantic' })
|
2024-04-16 16:16:32 +03:00
|
|
|
# The ghc `-j` flag defaults to number of cpus when no argument is passed
|
|
|
|
stackGhcParallelFlag := if disableParallel == '' { "--ghc-options=-j" + numParallelJobs } else { '' }
|
|
|
|
# The stack `-j` options requires an argument
|
|
|
|
stackParallelFlagJobs := if numParallelJobs == '' { num_cpus() } else { numParallelJobs }
|
|
|
|
stackParallelFlag := if disableParallel == '' { '-j' + stackParallelFlagJobs } else { '' }
|
|
|
|
stackArgs := stackOptFlag + ' ' + stackParallelFlag + ' ' + stackGhcParallelFlag
|
2024-02-02 14:48:14 +03:00
|
|
|
|
|
|
|
# flags used in the stack test command
|
|
|
|
testArgs := "--hide-successes"
|
2024-05-03 12:05:06 +03:00
|
|
|
rtsFlag := if disableParallel == '' { '+RTS -N' + numParallelJobs + ' -RTS' } else { '' }
|
2024-02-02 14:48:14 +03:00
|
|
|
|
|
|
|
# flag used to enable tracing of bash commands
|
|
|
|
bashDebugArg := if enableDebug == '' { '' } else { 'x' }
|
|
|
|
|
|
|
|
[private]
|
|
|
|
default:
|
|
|
|
@just --list
|
|
|
|
|
|
|
|
@_ormoluCmd filesCmd:
|
|
|
|
{{ trim(filesCmd) }} \
|
2024-06-20 12:30:04 +03:00
|
|
|
| xargs -r {{ ormolu }} --mode inplace
|
2024-02-02 14:48:14 +03:00
|
|
|
|
|
|
|
# Formats all Haskell files in the project. `format changed` formats only changed files. `format FILES` formats individual files.
|
|
|
|
format *opts:
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo{{ bashDebugArg }} pipefail
|
|
|
|
|
2024-06-20 12:30:04 +03:00
|
|
|
if [ ! -e "juvix.cabal" ]; then
|
|
|
|
echo "Error: juvix.cabal does not exist. Please, run 'just install' or 'stack setup' first"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-02-02 14:48:14 +03:00
|
|
|
opts='{{ trim(opts) }}'
|
|
|
|
|
|
|
|
case $opts in
|
|
|
|
"")
|
|
|
|
just _ormoluCmd "git ls-files '*.hs'"
|
|
|
|
;;
|
|
|
|
changed)
|
|
|
|
just _ormoluCmd \
|
|
|
|
"(git --no-pager diff --name-only --diff-filter=AM && git --no-pager diff --cached --name-only --diff-filter=AM) | grep '\\.hs\$'"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
just _ormoluCmd "echo {{ opts }}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Run the tests in the project. Use the filter arg to set a Tasty pattern.
|
|
|
|
[no-exit-message]
|
|
|
|
test *filter:
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo{{ bashDebugArg }} pipefail
|
|
|
|
filter='{{ trim(filter) }}'
|
|
|
|
if [ -n "$filter" ]; then
|
|
|
|
filter="-p \"$filter\""
|
|
|
|
fi
|
2024-04-16 16:16:32 +03:00
|
|
|
set -x
|
2024-02-02 14:48:14 +03:00
|
|
|
{{ stack }} test {{ stackArgs }} --ta "{{ testArgs }} {{ rtsFlag }} $filter"
|
|
|
|
|
|
|
|
# Run a juvix command and profile it
|
|
|
|
run-profile +cmd:
|
|
|
|
cabal run --enable-profiling juvix -- {{ cmd }} +RTS -p
|
|
|
|
|
|
|
|
# Build the juvix runtime
|
|
|
|
_buildRuntime:
|
2024-05-22 13:26:51 +03:00
|
|
|
cd runtime && make {{ runtimeArgs }}
|
2024-02-02 14:48:14 +03:00
|
|
|
|
|
|
|
# Build the project. `build runtime` builds only the runtime.
|
|
|
|
[no-exit-message]
|
|
|
|
build *opts:
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo{{ bashDebugArg }} pipefail
|
|
|
|
opts='{{ trim(opts) }}'
|
|
|
|
|
|
|
|
case $opts in
|
|
|
|
runtime)
|
2024-04-18 13:52:37 +03:00
|
|
|
just runtimeArgs="{{ runtimeArgs }}" _buildRuntime
|
2024-02-02 14:48:14 +03:00
|
|
|
;;
|
|
|
|
*)
|
2024-04-18 13:52:37 +03:00
|
|
|
just runtimeArgs="{{ runtimeArgs }}" _buildRuntime
|
2024-04-16 16:16:32 +03:00
|
|
|
set -x
|
2024-02-02 14:48:14 +03:00
|
|
|
{{ stack }} build {{ stackArgs }}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Install juvix
|
|
|
|
[no-exit-message]
|
|
|
|
install: _buildRuntime
|
|
|
|
{{ stack }} install {{ stackArgs }}
|
|
|
|
|
|
|
|
# Clean all .juvix-build directories in the project
|
|
|
|
_cleanJuvixBuild:
|
|
|
|
@find . -type d -name '.juvix-build' | xargs rm -rf
|
|
|
|
|
|
|
|
# Clean the juvix runtime build directory
|
|
|
|
_cleanRuntime:
|
|
|
|
@cd runtime && make clean
|
|
|
|
|
|
|
|
# Clean the project. `clean runtime` cleans only the runtime. `clean juvix-build` cleans only juvix-build dirs.
|
|
|
|
clean *opts:
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo{{ bashDebugArg }} pipefail
|
|
|
|
opts='{{ trim(opts) }}'
|
|
|
|
|
|
|
|
case $opts in
|
|
|
|
runtime)
|
|
|
|
just _cleanRuntime
|
|
|
|
;;
|
|
|
|
juvix-build)
|
|
|
|
just _cleanJuvixBuild
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
just _cleanRuntime
|
|
|
|
just _cleanJuvixBuild
|
|
|
|
{{ stack }} clean --full
|
|
|
|
;;
|
|
|
|
esac
|