Skip to content
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
22 changes: 5 additions & 17 deletions .github/scripts/configure_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,20 @@

set -euo pipefail

IS_TAG=0
IS_EXPERIMENTAL=0

if [[ "$GITHUB_REF" == "" ]]; then
echo "GITHUB_REF must be set"
elif [[ "$GITHUB_REF" =~ ^refs/tags/ ]]; then
IS_TAG=1
cabal configure --project-file cabal.project.release -O2
else
cabal configure --project-file cabal.project.release
fi
cabal configure --project-file cabal.project.release -O1

if [[ "$LABEL" == "" ]]; then
echo "LABEL must be set"
elif [[ "$LABEL" == "experimental" ]]; then
IS_EXPERIMENTAL=1
fi

if [[ $IS_EXPERIMENTAL -eq 1 ]] || [[ $IS_TAG -eq 0 ]]; then
echo "package jbeam-edit" >>cabal.project.release.local
if [[ $IS_EXPERIMENTAL -eq 1 ]]; then
echo " flags: $MATRIX_FLAGS" >>cabal.project.release.local
fi
if [[ $IS_TAG -eq 0 ]]; then
echo " tests: True" >>cabal.project.release.local
fi
echo "package jbeam-edit" >>cabal.project.release.local
echo " tests: True" >>cabal.project.release.local
if [[ $IS_EXPERIMENTAL -eq 1 ]]; then
echo " flags: $MATRIX_FLAGS" >>cabal.project.release.local
fi

echo "contents of cabal.project.release.local"
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/freeze_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ set -euo pipefail

cabal freeze --project-file "${CABAL_PROJECT:?CABAL_PROJECT missing}"
PLAN_PATH=$(find dist-newstyle -name plan.json)
JQ_QUERY='."install-plan" | map (."pkg-name" | select (. != "jbeam-edit")) | unique'
JQ_QUERY='."install-plan" | map (select (."pkg-name" != "jbeam-edit") | ."pkg-name" + "=" + ."pkg-version") | unique'
jq -c "$JQ_QUERY" <"$PLAN_PATH"
printf "number of dependencies: %d" "$(jq "${JQ_QUERY} | length" <"$PLAN_PATH")"
9 changes: 9 additions & 0 deletions .github/scripts/prepare_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ fi
cp "$EXE_PATH" "$DEST_DIR_RELEASE/jbeam-edit.exe"
echo "Copied exe to /$DEST_DIR_RELEASE/jbeam-edit.exe"

LSP_EXE_PATH=$(find "$DIST_NEWSTYLE/build" -type f -name "jbeam-lsp-server.exe" | head -n 1)

if [ -z "$LSP_EXE_PATH" ]; then
echo "Error: No LSP exe found in '$DIST_NEWSTYLE/build', skipping."
else
cp "$LSP_EXE_PATH" "$DEST_DIR_RELEASE/jbeam-lsp-server.exe"
echo "Copied exe to /$DEST_DIR_RELEASE/jbeam-lsp-server.exe"
fi

TMP_DIR=$(mktemp -d)
git show HEAD:"./examples/jbeam/fender.jbeam" >"$TMP_DIR/fender.${LABEL}.jbeam"
git show HEAD:"./examples/jbeam/suspension.jbeam" >"$TMP_DIR/suspension.${LABEL}.jbeam"
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/prepare_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ZIP_FILE="${ZIP_FILE:-dist/jbeam-edit-${GITHUB_REF_NAME}.zip}"
mkdir -p "$ZIP_DIR"
mkdir -p "$(dirname "$ZIP_FILE")"

SETUP_EXE="installer/Output/setup.exe"
SETUP_EXE="installer/Output/jbeam-edit-setup.exe"
if [ ! -f "$SETUP_EXE" ]; then
echo "Error: setup.exe not found in release folder '$RELEASE_DIR'. Make sure Inno Setup ran successfully."
exit 1
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ jobs:
- name: Configure
run: bash ./.github/scripts/configure_project.sh
env:
GITHUB_REF: ${{ github.ref }}
LABEL: ${{ matrix.label }}
MATRIX_FLAGS: ${{ matrix.flags }}
- name: Freeze and check dependencies
Expand All @@ -63,7 +62,6 @@ jobs:
run: bash ./.github/scripts/freeze_dependencies.sh
- name: Cache GHC, Cabal store, and build artifacts
uses: actions/cache@v4.3.0
if: "!startsWith(github.ref, 'refs/tags/')"
with:
path: |
dist-newstyle
Expand All @@ -78,16 +76,17 @@ jobs:
}}
restore-keys: |
${{ runner.os }}-cabal-${{ matrix.ghc }}-${{ matrix.label }}
${{ runner.os }}-cabal-${{ matrix.ghc }}-
- name: Build dependencies, good to do separate for caching
run: cabal build --project-file cabal.project.release --only-dependencies
- name: Build executables
- name: Build LSP executable
run: |
cabal build exe:jbeam-lsp-server --project-file cabal.project.release || true
- name: Build main executable
run: cabal build exe:jbeam-edit --project-file cabal.project.release
- name: Build LSP test server
run: |
cabal install exe:jbeam-lsp-test-server --project-file cabal.project.release || true
- name: Run tests (GHC ${{ matrix.ghc }})
if: "!startsWith(github.ref, 'refs/tags/')"
run: cabal test --project-file cabal.project.release
- name: Enforce CRLF newlines on windows
run: bash ./.github/scripts/replace_newlines.sh
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/lint-and-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ jobs:
**/*.hs
!examples/ast/*/*.hs
version: latest
- uses: reviewdog/action-shfmt@v1.0.4
with:
level: warning
fail_on_error: true
workdir: .github/scripts
- name: Check bash formatting
run: |
sudo apt update > /dev/null 2>&1
sudo apt install -y shfmt > /dev/null 2>&1
shfmt -d .github/scripts
env:
FORCE_COLOR: true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 12 additions & 6 deletions installer/setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
[Setup]
AppName=jbeam-edit
AppVersion=0.0.3.0
DefaultDirName={pf}\jbeam-edit
DefaultGroupName=jbeam-edit
OutputBaseFilename=setup
DefaultDirName={commonpf}\jbeam-edit
OutputBaseFilename=jbeam-edit-setup
Compression=lzma
SolidCompression=yes
PrivilegesRequired=admin
UninstallDisplayName=jbeam-edit

[Files]
Source: "..\dist\release\jbeam-edit.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\dist\release\jbeam-lsp-server.exe"; DestDir: "{app}"; Flags: ignoreversion skipifsourcedoesntexist
Source: "..\dist\release\examples\jbfl\*"; DestDir: "{app}\examples\jbfl"; Flags: recursesubdirs createallsubdirs ignoreversion

[Registry]
Root: HKCU; Subkey: "Environment"; ValueType: string; ValueName: "Path"; \
ValueData: "{olddata};{app}"; Flags: preservestringtype uninsdeletevalue
[UninstallDelete]
Name: "{app}\*"; Type: files
Name: "{app}"; Type: dirifempty


[Code]
#include "source_path.inc"
85 changes: 85 additions & 0 deletions installer/source_path.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
(* -*- mode: pascal -*- *)

function SendMessageTimeoutA(hWnd: Integer; Msg: Integer;
wParam: Longint; lParam: Longint; fuFlags: Longint;
uTimeout: Longint; var lpdwResult: Longint): Longint;
external 'SendMessageTimeoutA@user32.dll stdcall';

procedure BroadcastEnvChange;
var
resultValue: Longint;
begin
SendMessageTimeoutA($FFFF, $1A, 0, 0, $0002, 5000, resultValue);
end;

function ExcludeTrailingPathDelimiter(const S: string): string;
begin
Result := S;
if (Length(Result) > 0) and (Result[Length(Result)] = '\') then
Delete(Result, Length(Result), 1);
end;

procedure AddPathEntry(const Entry: string);
var
Key, PathValue, UpperPath, NormalizedEntry: string;
begin
Key := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
if not RegQueryStringValue(HKLM, Key, 'Path', PathValue) then
PathValue := '';
NormalizedEntry := UpperCase(ExcludeTrailingPathDelimiter(Entry));
UpperPath := UpperCase(';' + PathValue + ';');
if (Pos(';' + NormalizedEntry + ';', UpperPath) = 0) and
(Pos(';' + NormalizedEntry + '\;', UpperPath) = 0) then
begin
if PathValue = '' then
PathValue := Entry
else
PathValue := PathValue + ';' + Entry;
RegWriteExpandStringValue(HKLM, Key, 'Path', PathValue);
BroadcastEnvChange;
end;
end;

function ReplaceText(const S, OldPattern, NewPattern: string): string;
var
P: Integer;
Temp: string;
begin
Temp := S;
P := Pos(OldPattern, Temp);
while P > 0 do
begin
Delete(Temp, P, Length(OldPattern));
Insert(NewPattern, Temp, P);
P := Pos(OldPattern, Temp);
end;
Result := Temp;
end;

procedure RemovePathEntry(const Entry: string);
var
Key, PathValue, Cleaned, NormalizedEntry, UpperPath: string;
begin
Key := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
if not RegQueryStringValue(HKLM, Key, 'Path', PathValue) then Exit;
NormalizedEntry := UpperCase(ExcludeTrailingPathDelimiter(Entry));
UpperPath := UpperCase(';' + PathValue + ';');
Cleaned := ReplaceText(UpperPath, ';' + NormalizedEntry + ';', ';');
Cleaned := ReplaceText(Cleaned, ';' + NormalizedEntry + '\;', ';');
if (Length(Cleaned) > 0) and (Cleaned[1] = ';') then Delete(Cleaned, 1, 1);
if (Length(Cleaned) > 0) and (Cleaned[Length(Cleaned)] = ';') then Delete(Cleaned, Length(Cleaned), 1);
RegWriteExpandStringValue(HKLM, Key, 'Path', Cleaned);
BroadcastEnvChange;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
AddPathEntry(ExpandConstant('{app}'));
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usPostUninstall then
RemovePathEntry(ExpandConstant('{app}'));
end;
56 changes: 49 additions & 7 deletions jbeam-edit.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ library jbeam-language-server

executable jbeam-edit
main-is: Main.hs
hs-source-dirs: app
hs-source-dirs: exe/jbeam-edit
other-modules:
CommandLineOptions
Paths_jbeam_edit
Expand Down Expand Up @@ -279,7 +279,7 @@ executable jbeam-edit-dump-ast

executable jbeam-lsp-server
main-is: Main.hs
hs-source-dirs: app-extra/jbeam-lsp-server
hs-source-dirs: exe/jbeam-lsp-server
other-modules: Paths_jbeam_edit
autogen-modules: Paths_jbeam_edit
default-language: Haskell2010
Expand Down Expand Up @@ -366,6 +366,50 @@ test-suite jbeam-edit-test
Parsing.JbeamSpec
SpecHelper
TransformationSpec
Paths_jbeam_edit

autogen-modules: Paths_jbeam_edit
default-language: Haskell2010
default-extensions: OverloadedStrings ImportQualifiedPost
ghc-options:
-Wall -Wcompat -Widentities -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wmissing-export-lists
-Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
-threaded -rtsopts -with-rtsopts=-N

build-depends:
base >=4.17 && <5,
bytestring >=0.12,
containers >=0.6,
directory >=1.3,
filepath >=1.4,
hspec >=2.11,
jbeam-edit,
megaparsec >=9.6,
relude >=1.2,
scientific >=0.3,
text >=2.1,
vector >=0.13

mixins:
base hiding (Prelude),
relude (Relude as Prelude),
relude

if True
build-depends: hspec-megaparsec >=2.2

if flag(transformation)
cpp-options: -DENABLE_TRANSFORMATION_TESTS
build-depends: jbeam-edit-transformation

test-suite jbeam-language-server-test
type: exitcode-stdio-1.0
main-is: Spec.hs
build-tool-depends: hspec-discover:hspec-discover
hs-source-dirs: test-extra/language-server
other-modules:
DocumentStoreSpec
WorkspaceLspSpec
Paths_jbeam_edit

Expand All @@ -385,7 +429,6 @@ test-suite jbeam-edit-test
directory >=1.3,
filepath >=1.4,
hspec >=2.11,
hspec-megaparsec >=2.2,
jbeam-edit,
megaparsec >=9.6,
relude >=1.2,
Expand All @@ -399,11 +442,10 @@ test-suite jbeam-edit-test
relude

if (flag(lsp-server) && impl(ghc >=9.6.6))
cpp-options: -DENABLE_LSP_TESTS
build-depends:
jbeam-language-server,
lsp >=2.7,
lsp-test

if flag(transformation)
cpp-options: -DENABLE_TRANSFORMATION_TESTS
build-depends: jbeam-edit-transformation
else
buildable: False
29 changes: 20 additions & 9 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ _jbeam-lsp-common: &jbeam-lsp-common
executables:
jbeam-edit:
main: Main.hs
source-dirs: app
source-dirs: exe/jbeam-edit
ghc-options: [-threaded, -rtsopts, -with-rtsopts=-N]
dependencies: [jbeam-edit]
when:
Expand All @@ -126,7 +126,7 @@ executables:
- condition: os(windows)
cpp-options: -DENABLE_WINDOWS_NEWLINES
jbeam-lsp-server:
source-dirs: app-extra/jbeam-lsp-server
source-dirs: exe/jbeam-lsp-server
<<: *jbeam-lsp-common
jbeam-lsp-test-server:
source-dirs: tools/lsp-test-server
Expand All @@ -143,17 +143,28 @@ executables:
ghc-options: [-threaded, -rtsopts, -with-rtsopts=-N]
dependencies: [jbeam-edit]

_jbeam-test-common: &jbeam-test-common
main: Spec.hs
ghc-options: [-threaded, -rtsopts, -with-rtsopts=-N]
build-tools: [hspec-discover]
dependencies: [jbeam-edit, hspec>=2.11]

tests:
jbeam-edit-test:
main: Spec.hs
<<: *jbeam-test-common
source-dirs: test
ghc-options: [-threaded, -rtsopts, -with-rtsopts=-N]
dependencies: [jbeam-edit, hspec>=2.11, hspec-megaparsec>=2.2]
build-tools: [hspec-discover]
when:
- condition: flag(lsp-server) && impl(ghc >= 9.6.6)
dependencies: [lsp-test, lsp>=2.7]
cpp-options: -DENABLE_LSP_TESTS
- condition: true
dependencies: [hspec-megaparsec>=2.2]
- condition: flag(transformation)
dependencies: [jbeam-edit-transformation]
cpp-options: -DENABLE_TRANSFORMATION_TESTS
jbeam-language-server-test:
<<: *jbeam-test-common
source-dirs: test-extra/language-server
when:
- condition: flag(lsp-server) && impl(ghc >= 9.6.6)
then:
dependencies: [jbeam-language-server, lsp-test, lsp>=2.7]
else:
buildable: false
Loading