Skip to content

Commit

Permalink
Move the output of the generator to its own directory
Browse files Browse the repository at this point in the history
  • Loading branch information
moste00 committed Sep 7, 2024
1 parent 81a5c5e commit 7211618
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/end2end-smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,22 @@ jobs:
- name: Running the generator
run: |
cd generator && source ~/.bash_profile
mv riscv_ast.gen.inc old_riscv_ast.gen.inc
mv riscv_decode.gen.inc old_riscv_decode.gen.inc
mv riscv_diasm old_output
dune exec --profile release -- riscv_disasm_from_sail -f sail.filepaths.txt
- name: Checking the generated code compiles and is identical to the committed generated code
run: |
cd generator
cd generator/riscv_disasm
touch test_main.c
echo '#include "riscv_decode.gen.inc"' >> test_main.c
echo >> test_main.c
echo 'void main() {}' >> test_main.c
gcc test_main.c || { echo "Failure: Trying to compile the tool-generated C code failed."; exit 1; }
if diff -q riscv_ast.gen.inc old_riscv_ast.gen.inc > /dev/null 2>&1; then
if diff -q riscv_decode.gen.inc old_riscv_decode.gen.inc > /dev/null 2>&1; then
if diff -q riscv_ast.gen.inc ../old_output/riscv_ast.gen.inc > /dev/null 2>&1; then
if diff -q riscv_decode.gen.inc ../old_output/riscv_decode.gen.inc > /dev/null 2>&1; then
echo "Success: The tool generates compiling C code that is identical to the files committed."
else
echo "Failure: The tool-generated decoding logic differ from that committed in the repo."
Expand Down
9 changes: 8 additions & 1 deletion bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ open Riscv_disasm_from_sail
open Constants
open Printexc

let mkdir_if_none_exists dirname =
try Sys.mkdir dirname 0o777
with Sys_error _ -> ()

let write_c_file ?(additional_includes = []) name code =
let oc = open_out name in
mkdir_if_none_exists "riscv_disasm";

print_endline "\n ------------------------------- REACHED -----------------------------------\n";
let oc = open_out ("riscv_disasm/" ^ name) in
let mk_include_lines incs =
String.concat "\n" (List.map (fun i -> "#include " ^ i ^ "\n") incs)
in
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion tools/riscv-ls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ elif [ $# -eq 1 ]; then
echo "Path to sail model given as $1"
else
echo "Unrecognized arguments. Usage: riscv-ls [path to riscv sail model repo]"
echo "If no path to sail model was given, it's automatically searched for using find"
exit
fi

Expand Down

0 comments on commit 7211618

Please sign in to comment.