Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust dev scripts and removed util directory #1995

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/scripts/test-lfc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ bin/lfc-dev test/C/src/Minimal.lf

# Ensure that lfc can be invoked via symbolic links.
test_with_links "lfc-dev"

# Ensure that lfc can be invoked from outside the root directory.
cmnrd marked this conversation as resolved.
Show resolved Hide resolved
cd bin
./lfc-dev --help
cd ..
5 changes: 5 additions & 0 deletions .github/scripts/test-lfd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ bin/lfd-dev test/C/src/Minimal.lf

# Ensure that lfd can be invoked via symbolic links.
test_with_links "lfd-dev"

# Ensure that lfd can be invoked from outside the root directory.
cd bin
./lfd-dev --help
cd ..
5 changes: 5 additions & 0 deletions .github/scripts/test-lff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ bin/lff-dev --dry-run test/Cpp/src/Minimal.lf

# Ensure that lff can be invoked via symbolic links.
test_with_links "lff-dev"

# Ensure that lfc can be invoked from outside the root directory.
cd bin
./lff-dev --help
cd ..
1 change: 0 additions & 1 deletion bin/lfc-dev

This file was deleted.

59 changes: 59 additions & 0 deletions bin/lfc-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

#============================================================================
# Description: Build and run the Lingua Franca compiler (lfc).
# Authors: Marten Lohstroh
# Christian Menard
# Usage: Usage: lfc-dev [options] files...
#============================================================================

#============================================================================
# Preamble
#============================================================================

# Find the directory in which this script resides in a way that is compatible
# with MacOS, which has a `readlink` implementation that does not support the
# necessary `-f` flag to canonicalize by following every symlink in every
# component of the given name recursively.
# This solution, adapted from an example written by Geoff Nixon, is POSIX-
# compliant and robust to symbolic links. If a chain of more than 1000 links
# is encountered, we return.
set -euo pipefail

find_base_dir() (
start_dir=$PWD
cd "$(dirname "$1")"
link=$(readlink "$(basename "$1")")
count=0
while [ "${link}" ]; do
if [[ "${count}" -lt 1000 ]]; then
cd "$(dirname "${link}")"
link=$(readlink "$(basename "${link}")")
((count++))
else
return
fi
done
real_path="${PWD}"
cd "${start_dir}"
echo "$(dirname "${real_path}")"
)

# Report fatal error and exit.
function fatal_error() {
1>&2 echo -e "\e[31mfatal error: \e[0m$1"
exit 1
}

base="$(find_base_dir "$0")"

if [[ -z "${base}" ]]; then
fatal_error "Unable to determine base path of $0."
fi
#============================================================================

gradlew="${base}/gradlew"

# Launch the tool.
"${gradlew}" --quiet -p "${base}" assemble ":cli:lfc:assemble"
"${base}/build/install/lf-cli/bin/lfc" "$@"
20 changes: 13 additions & 7 deletions bin/lfc-dev.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#==========================================================
# Description: Run the lfc compiler.
#============================================================================
# Description: Build and run the Lingua Franca compiler (lfc).
# Authors: Ruomu Xu
# Usage: Usage: lfc [options] files...
#==========================================================
# Christian Menard
# Usage: Usage: lfc-dev [options] files...
#============================================================================

$launchScript="$PSScriptRoot\..\util\scripts\launch.ps1"
# PS requires spattling: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Splatting?view=powershell-7.2
. $launchScript @args

# This script is in $base\bin
$base="$PSScriptRoot\..\"
$gradlew="${base}/gradlew.bat"

# invoke script
& "${gradlew}" --quiet -p "${base}" assemble ":cli:lfc:assemble"
& "${base}/build/install/lf-cli/bin/lfc" @args
1 change: 0 additions & 1 deletion bin/lfd-dev

This file was deleted.

59 changes: 59 additions & 0 deletions bin/lfd-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

#============================================================================
# Description: Build and run the Lingua Franca diagram generator (lfd).
# Authors: Marten Lohstroh
# Christian Menard
# Usage: Usage: lfd-dev [options] files...
#============================================================================

#============================================================================
# Preamble
#============================================================================

# Find the directory in which this script resides in a way that is compatible
# with MacOS, which has a `readlink` implementation that does not support the
# necessary `-f` flag to canonicalize by following every symlink in every
# component of the given name recursively.
# This solution, adapted from an example written by Geoff Nixon, is POSIX-
# compliant and robust to symbolic links. If a chain of more than 1000 links
# is encountered, we return.
set -euo pipefail

find_base_dir() (
start_dir=$PWD
cd "$(dirname "$1")"
link=$(readlink "$(basename "$1")")
count=0
while [ "${link}" ]; do
if [[ "${count}" -lt 1000 ]]; then
cd "$(dirname "${link}")"
link=$(readlink "$(basename "${link}")")
((count++))
else
return
fi
done
real_path="${PWD}"
cd "${start_dir}"
echo "$(dirname "${real_path}")"
)

# Report fatal error and exit.
function fatal_error() {
1>&2 echo -e "\e[31mfatal error: \e[0m$1"
exit 1
}

base="$(find_base_dir "$0")"

if [[ -z "${base}" ]]; then
fatal_error "Unable to determine base path of $0."
fi
#============================================================================

gradlew="${base}/gradlew"

# Launch the tool.
"${gradlew}" --quiet -p "${base}" assemble ":cli:lfd:assemble"
"${base}/build/install/lf-cli/bin/lfd" "$@"
20 changes: 13 additions & 7 deletions bin/lfd-dev.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#==========================================================
# Description: Run the lff compiler.
#============================================================================
# Description: Build and run the Lingua Franca diagram generator (lfd).
# Authors: Ruomu Xu
# Usage: Usage: lff [options] files...
#==========================================================
# Christian Menard
# Usage: Usage: lfd-dev [options] files...
#============================================================================

$launchScript="$PSScriptRoot\..\util\scripts\launch.ps1"
# PS requires spattling: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Splatting?view=powershell-7.2
. $launchScript @args

# This script is in $base\bin
$base="$PSScriptRoot\..\"
$gradlew="${base}/gradlew.bat"

# invoke script
& "${gradlew}" --quiet -p "${base}" assemble ":cli:lfd:assemble"
& "${base}/build/install/lf-cli/bin/lfd" @args
1 change: 0 additions & 1 deletion bin/lff-dev

This file was deleted.

59 changes: 59 additions & 0 deletions bin/lff-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

#============================================================================
# Description: Build and run the Lingua Franca code formatter (lff).
# Authors: Marten Lohstroh
# Christian Menard
# Usage: Usage: lff-dev [options] files...
#============================================================================

#============================================================================
# Preamble
#============================================================================

# Find the directory in which this script resides in a way that is compatible
# with MacOS, which has a `readlink` implementation that does not support the
# necessary `-f` flag to canonicalize by following every symlink in every
# component of the given name recursively.
# This solution, adapted from an example written by Geoff Nixon, is POSIX-
# compliant and robust to symbolic links. If a chain of more than 1000 links
# is encountered, we return.
set -euo pipefail

find_base_dir() (
start_dir=$PWD
cd "$(dirname "$1")"
link=$(readlink "$(basename "$1")")
count=0
while [ "${link}" ]; do
if [[ "${count}" -lt 1000 ]]; then
cd "$(dirname "${link}")"
link=$(readlink "$(basename "${link}")")
((count++))
else
return
fi
done
real_path="${PWD}"
cd "${start_dir}"
echo "$(dirname "${real_path}")"
)

# Report fatal error and exit.
function fatal_error() {
1>&2 echo -e "\e[31mfatal error: \e[0m$1"
exit 1
}

base="$(find_base_dir "$0")"

if [[ -z "${base}" ]]; then
fatal_error "Unable to determine base path of $0."
fi
#============================================================================

gradlew="${base}/gradlew"

# Launch the tool.
"${gradlew}" --quiet -p "${base}" assemble ":cli:lff:assemble"
"${base}/build/install/lf-cli/bin/lff" "$@"
20 changes: 13 additions & 7 deletions bin/lff-dev.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#==========================================================
# Description: Run the lff compiler.
#============================================================================
# Description: Build and run the Lingua Franca code formatter (lff).
# Authors: Ruomu Xu
# Usage: Usage: lff [options] files...
#==========================================================
# Christian Menard
# Usage: Usage: lff-dev [options] files...
#============================================================================

$launchScript="$PSScriptRoot\..\util\scripts\launch.ps1"
# PS requires spattling: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Splatting?view=powershell-7.2
. $launchScript @args

# This script is in $base\bin
$base="$PSScriptRoot\..\"
$gradlew="${base}/gradlew.bat"

# invoke script
& "${gradlew}" --quiet -p "${base}" assemble ":cli:lff:assemble"
& "${base}/build/install/lf-cli/bin/lff" @args
4 changes: 0 additions & 4 deletions util/README.md

This file was deleted.

34 changes: 0 additions & 34 deletions util/scripts/launch.ps1

This file was deleted.

Loading