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
2 changes: 1 addition & 1 deletion .github/scripts/copy_exe_to_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RELEASE_DIR="${RELEASE_DIR:?Environment variable RELEASE_DIR is required}"

mkdir -p "$RELEASE_DIR"

EXE_PATH=$(find "$DIST_NEWSTYLE/build" -type f -name "*.exe" | head -n 1)
EXE_PATH=$(find "$DIST_NEWSTYLE/build" -type f -name "jbeam-edit.exe" | head -n 1)

if [ -z "$EXE_PATH" ]; then
echo "Error: No exe found in '$DIST_NEWSTYLE/build'. Make sure the build step succeeded."
Expand Down
3 changes: 3 additions & 0 deletions .github/scripts/replace_newlines.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

find examples/formatted_jbeam examples/transformed_jbeam -type f -exec sed -i 's/$/\r/' {} +
26 changes: 26 additions & 0 deletions .github/scripts/test_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

source ./.github/scripts/copy_example_files.sh
source ./.github/scripts/copy_exe_to_release.sh

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"

echo "fender.jbeam: $TMP_DIR/fender.${LABEL}.jbeam"
echo "suspension.jbeam: $TMP_DIR/suspension.${LABEL}.jbeam"

./dist/release/jbeam-edit -i "$TMP_DIR/fender.${LABEL}.jbeam"
./dist/release/jbeam-edit -i "$TMP_DIR/suspension.${LABEL}.jbeam"

custom_diff () {
diff --color=always --suppress-common-lines "$1" "$2"
}

if [[ -n $LABEL ]] && [[ "$LABEL" == "experimental" ]]; then
custom_diff "$TMP_DIR/fender.experimental.jbeam" ./examples/transformed_jbeam/fender-cfg-default.jbeam
custom_diff "$TMP_DIR/suspension.experimental.jbeam" ./examples/transformed_jbeam/suspension-cfg-default.jbeam
else
custom_diff "$TMP_DIR/fender.stable.jbeam" ./examples/formatted_jbeam/fender-minimal-jbfl.jbeam
custom_diff "$TMP_DIR/suspension.stable.jbeam" ./examples/formatted_jbeam/suspension-minimal-jbfl.jbeam
fi
15 changes: 15 additions & 0 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
if: "!startsWith(github.ref, 'refs/tags/')"
run: cabal configure --project-file cabal.project.release --enable-tests
- name: Configure Cabal with flags from matrix
if: matrix.label == 'experimental'
shell: bash
run: |
printf 'package jbeam-edit\n flags: %s' $MATRIX_FLAGS >> cabal.project.release.local
Expand All @@ -82,11 +83,25 @@ 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
run: cabal build exe:jbeam-edit --project-file cabal.project.release
- 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
shell: bash
- name: Test executable
shell: bash
run: bash ./.github/scripts/test_release.sh
env:
RELEASE_DIR: dist/release
ZIP_DIR: dist/zip_temp
DIST_NEWSTYLE: dist-newstyle
CABAL_FILE: jbeam-edit.cabal
LABEL: ${{ matrix.label}}
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
--ghc-options="-Werror"
- name: Check that .cabal file has not changed except hpack comment
shell: bash
run: bash .github/scripts/check_cabal_file.sh
run: bash ./.github/scripts/check_cabal_file.sh
- run: cabal check --ignore=missing-upper-bounds
shell: bash
- name: Run tests
Expand Down
4 changes: 2 additions & 2 deletions app/.dir-locals.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(haskell-mode
((haskell-mode
. ((haskell-process-type . cabal-repl)
(eval . (setq-local haskell-process-args-cabal-repl
(append '("jbeam-edit:exe:jbeam-edit" "--project-file" "cabal.project.dev") haskell-process-args-cabal-repl))))))
(append '("jbeam-edit:exe:jbeam-edit" "--project-file" "cabal.project.dev") haskell-process-args-cabal-repl))))))
13 changes: 13 additions & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import IOUtils
import Parsing.Jbeam (parseNodes)
import System.Directory (copyFile)

#ifdef ENABLE_WINDOWS_NEWLINES
import Data.Text qualified as T
#endif

#ifdef ENABLE_TRANSFORMATION
import Transformation (transform)
import Config (loadTransformationConfig)
Expand Down Expand Up @@ -50,10 +54,19 @@ processNodes opts outFile nodes formattingConfig = do
writeFileLBS outFile
. encodeUtf8
. toLText
. replaceNewlines
. formatNode formattingConfig
$ transformedNode'
Left err -> putTextLn err

#ifdef ENABLE_WINDOWS_NEWLINES
replaceNewlines :: Text -> Text
replaceNewlines = T.replace "\n" "\r\n"
#else
replaceNewlines :: Text -> Text
replaceNewlines = id
#endif

applyTransform :: Options -> Node -> IO (Either Text Node)
#ifdef ENABLE_TRANSFORMATION
applyTransform opts node = do
Expand Down
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
packages: .
tests: True
optimization: False

package jbeam-edit
flags: +dump-ast +transformation -windows-example-paths
tests: True
flags: -dump-ast -transformation -windows-example-paths
3 changes: 3 additions & 0 deletions cabal.project.ci
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ test-show-details: direct

program-options
ghc-options: -Werror

package jbeam-edit
flags: +dump-ast +transformation -windows-example-paths
2 changes: 1 addition & 1 deletion cabal.project.dev
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ package *
package jbeam-edit
haddock-executables: True
haddock-internal: True
haddock-tests: True
flags: +dump-ast +transformation -windows-example-paths
2 changes: 1 addition & 1 deletion examples/formatted_jbeam/fender-complex-jbfl.jbeam
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,4 @@
["impala_fender_inter_r", ["cot_fender_r"]]
]
}
}
}
2 changes: 1 addition & 1 deletion examples/formatted_jbeam/fender-minimal-jbfl.jbeam
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,4 @@
["impala_fender_inter_r", ["cot_fender_r"]]
]
}
}
}
2 changes: 1 addition & 1 deletion examples/formatted_jbeam/suspension-complex-jbfl.jbeam
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,4 @@
["rails", ["chassis_rails"]]
]
}
}
}
2 changes: 1 addition & 1 deletion examples/formatted_jbeam/suspension-minimal-jbfl.jbeam
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,4 @@
["rails", ["chassis_rails"]]
]
}
}
}
72 changes: 30 additions & 42 deletions examples/transformed_jbeam/fender-cfg-default.jbeam
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"information" : {"authors" : "gittarrgy01", "name" : "Fenders"},
"slotType" : "cot_fender",
"nodes" : [
["id", "posX", "posY", "posZ"],
[ "id", "posX", "posY", "posZ"],
{"frictionCoef" : 0.7},
{"nodeMaterial" : "|NM_METAL"},

Expand All @@ -12,39 +12,39 @@
{"group" : "cot_fender_l"},
{"nodeWeight" : 0.65},
{"selfCollision" : true},
["bfl0", 0.739, -1.845, 0.716],
["bfl1", 0.959, -1.762, 0.576],
["bfl2", 0.855, -1.788, 0.707],
["bfl3", 0.948, -1.435, 0.73],
["bfl4", 0.756, -1.413, 0.843],
["bfl5", 0.963, -1.024, 0.112],
["bfl6", 0.964, -1.072, 0.507],
["bfl7", 0.778, -1.008, 0.873],
["bfl8", 0.987, -0.743, 0.109],
["bfl9", 0.987, -0.744, 0.494],
["bfl10", 0.812, -0.759, 0.896],
[ "bfl0", 0.739, -1.845, 0.716],
[ "bfl1", 0.959, -1.762, 0.576],
[ "bfl2", 0.855, -1.788, 0.707],
[ "bfl3", 0.948, -1.435, 0.730],
[ "bfl4", 0.756, -1.413, 0.843],
[ "bfl5", 0.963, -1.024, 0.112],
[ "bfl6", 0.964, -1.072, 0.507],
[ "bfl7", 0.778, -1.008, 0.873],
[ "bfl8", 0.987, -0.743, 0.109],
[ "bfl9", 0.987, -0.744, 0.494],
[ "bfl10", 0.812, -0.759, 0.896],

// Right side
{"group" : "cot_fender_r"},
["bfr0", -0.691, -1.829, 0.716],
["bfr1", -0.906, -1.737, 0.578],
["bfr2", -0.807, -1.769, 0.707],
["bfr3", -0.89, -1.409, 0.729],
["bfr4", -0.7, -1.397, 0.843],
["bfr5", -0.899, -1.005, 0.112],
["bfr6", -0.9, -1.053, 0.508],
["bfr7", -0.715, -0.991, 0.873],
["bfr8", -0.916, -0.742, 0.112],
["bfr9", -0.917, -0.746, 0.494],
["bfr10", -0.734, -0.746, 0.888],
[ "bfr0", -0.691, -1.829, 0.716],
[ "bfr1", -0.906, -1.737, 0.578],
[ "bfr2", -0.807, -1.769, 0.707],
[ "bfr3", -0.890, -1.409, 0.729],
[ "bfr4", -0.700, -1.397, 0.843],
[ "bfr5", -0.899, -1.005, 0.112],
[ "bfr6", -0.900, -1.053, 0.508],
[ "bfr7", -0.715, -0.991, 0.873],
[ "bfr8", -0.916, -0.742, 0.112],
[ "bfr9", -0.917, -0.746, 0.494],
[ "bfr10", -0.734, -0.746, 0.888],

// Support nodes
{"collision" : false},
{"group" : ""},
{"nodeWeight" : 1.2},
{"selfCollision" : false},
["bfsl", 0.684, -1.079, 0.507],
["bfsr", -0.623, -1.064, 0.507]
[ "bfsl", 0.684, -1.079, 0.507],
[ "bfsr", -0.623, -1.064, 0.507]
],
"beams" : [
["id1:", "id2:"],
Expand Down Expand Up @@ -271,22 +271,10 @@
],
"flexbodies" : [
["mesh", "[group]:", "nonFlexMaterials"],
[
"impala_fender_l",
["cot_fender_l"]
],
[
"impala_fender_inter_l",
["cot_fender_l"]
],
[
"impala_fender_r",
["cot_fender_r"]
],
[
"impala_fender_inter_r",
["cot_fender_r"]
]
["impala_fender_l", ["cot_fender_l"]],
["impala_fender_inter_l", ["cot_fender_l"]],
["impala_fender_r", ["cot_fender_r"]],
["impala_fender_inter_r", ["cot_fender_r"]]
]
}
}
}
72 changes: 30 additions & 42 deletions examples/transformed_jbeam/fender-cfg-example.jbeam
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"information" : {"authors" : "gittarrgy01", "name" : "Fenders"},
"slotType" : "cot_fender",
"nodes" : [
["id", "posX", "posY", "posZ"],
[ "id", "posX", "posY", "posZ"],
{"frictionCoef" : 0.7},
{"nodeMaterial" : "|NM_METAL"},

Expand All @@ -12,44 +12,44 @@
{"group" : "cot_fender_l"},
{"nodeWeight" : 0.65},
{"selfCollision" : true},
["bfl0", 0.739, -1.845, 0.716],
["bfl1", 0.959, -1.762, 0.576],
["bfl2", 0.855, -1.788, 0.707],
["bfl3", 0.948, -1.435, 0.73],
["bfl4", 0.963, -1.024, 0.112],
["bfl5", 0.778, -1.008, 0.873],
["bfl6", 0.987, -0.743, 0.109],
["bfl7", 0.812, -0.759, 0.896],
[ "bfl0", 0.739, -1.845, 0.716],
[ "bfl1", 0.959, -1.762, 0.576],
[ "bfl2", 0.855, -1.788, 0.707],
[ "bfl3", 0.948, -1.435, 0.730],
[ "bfl4", 0.963, -1.024, 0.112],
[ "bfl5", 0.778, -1.008, 0.873],
[ "bfl6", 0.987, -0.743, 0.109],
[ "bfl7", 0.812, -0.759, 0.896],

// Right side
{"group" : "cot_fender_r"},
["bfr0", -0.691, -1.829, 0.716],
["bfr1", -0.906, -1.737, 0.578],
["bfr2", -0.807, -1.769, 0.707],
["bfr3", -0.89, -1.409, 0.729],
["bfr4", -0.899, -1.005, 0.112],
["bfr5", -0.715, -0.991, 0.873],
["bfr6", -0.916, -0.742, 0.112],
["bfr7", -0.734, -0.746, 0.888],
[ "bfr0", -0.691, -1.829, 0.716],
[ "bfr1", -0.906, -1.737, 0.578],
[ "bfr2", -0.807, -1.769, 0.707],
[ "bfr3", -0.890, -1.409, 0.729],
[ "bfr4", -0.899, -1.005, 0.112],
[ "bfr5", -0.715, -0.991, 0.873],
[ "bfr6", -0.916, -0.742, 0.112],
[ "bfr7", -0.734, -0.746, 0.888],

// Support nodes
{"collision" : false},
{"group" : ""},
{"nodeWeight" : 1.2},
{"selfCollision" : false},
["bfsl", 0.684, -1.079, 0.507],
["bfsr", -0.623, -1.064, 0.507],
[ "bfsl", 0.684, -1.079, 0.507],
[ "bfsr", -0.623, -1.064, 0.507],
{"collision" : true},
{"group" : "cot_fender_l"},
{"nodeWeight" : 0.65},
{"selfCollision" : true},
["bfsl1", 0.756, -1.413, 0.843],
["bfsl2", 0.964, -1.072, 0.507],
["bfsl3", 0.987, -0.744, 0.494],
[ "bfsl1", 0.756, -1.413, 0.843],
[ "bfsl2", 0.964, -1.072, 0.507],
[ "bfsl3", 0.987, -0.744, 0.494],
{"group" : "cot_fender_r"},
["bfsr1", -0.7, -1.397, 0.843],
["bfsr2", -0.9, -1.053, 0.508],
["bfsr3", -0.917, -0.746, 0.494]
[ "bfsr1", -0.700, -1.397, 0.843],
[ "bfsr2", -0.900, -1.053, 0.508],
[ "bfsr3", -0.917, -0.746, 0.494]
],
"beams" : [
["id1:", "id2:"],
Expand Down Expand Up @@ -276,22 +276,10 @@
],
"flexbodies" : [
["mesh", "[group]:", "nonFlexMaterials"],
[
"impala_fender_l",
["cot_fender_l"]
],
[
"impala_fender_inter_l",
["cot_fender_l"]
],
[
"impala_fender_r",
["cot_fender_r"]
],
[
"impala_fender_inter_r",
["cot_fender_r"]
]
["impala_fender_l", ["cot_fender_l"]],
["impala_fender_inter_l", ["cot_fender_l"]],
["impala_fender_r", ["cot_fender_r"]],
["impala_fender_inter_r", ["cot_fender_r"]]
]
}
}
}
Loading