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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and Test

on:
push:
branches: [master, dev]
pull_request:
branches: [master]

jobs:
build:
name: ${{ matrix.os }} / OCaml ${{ matrix.ocaml-compiler }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
ocaml-compiler: "5.4.x"
- os: ubuntu-latest
ocaml-compiler: "5.2.x"
- os: macos-latest
ocaml-compiler: "5.4.x"

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
dune-cache: true

- name: Install dependencies
run: opam install . --deps-only --with-test

- name: Build
run: opam exec -- dune build

- name: Run tests
run: opam exec -- dune test
112 changes: 112 additions & 0 deletions .github/workflows/warnings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Strict Warnings

on:
push:
branches: [master, dev]
pull_request:
branches: [master]

jobs:
warnings:
name: All warnings as errors / ${{ matrix.os }} / OCaml ${{ matrix.ocaml-compiler }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
ocaml-compiler: "5.4.x"
- os: ubuntu-latest
ocaml-compiler: "5.2.x"
- os: macos-latest
ocaml-compiler: "5.4.x"

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
dune-cache: true

- name: Install dependencies
run: opam install . --deps-only --with-test

- name: Enumerate all OCaml warnings
run: |
echo "=== OCaml compiler version ==="
opam exec -- ocaml --version
echo ""
echo "=== All available warnings ==="
opam exec -- ocaml -warn-help
echo ""

# Parse the max warning number from -warn-help output
MAX_WARN=$(opam exec -- ocaml -warn-help | grep -oP '^\s*\K[0-9]+' | sort -n | tail -1)
echo "Max warning number: $MAX_WARN"
echo "Total numbered warnings: $(opam exec -- ocaml -warn-help | grep -cP '^\s+[0-9]+')"

# Build the explicit warning list: @1@2@3...@N
WARN_FLAGS=""
for i in $(seq 1 "$MAX_WARN"); do
WARN_FLAGS="${WARN_FLAGS}@${i}"
done
echo "Generated warn-error flags: $WARN_FLAGS"
echo "WARN_FLAGS=$WARN_FLAGS" >> "$GITHUB_ENV"
echo "MAX_WARN=$MAX_WARN" >> "$GITHUB_ENV"

echo ""
echo "=== Excluded warnings (structural, not fixable) ==="
echo " 44 [open-shadow-identifier] - every file does 'open Basis' (SML compat layer)"
echo " 45 [open-shadow-label-constructor] - same reason as 44"
echo " 49 [no-cmi-file] - cascading from dune wrapper modules"
echo " 70 [missing-mli] - dune-generated .ml-gen wrappers have no .mli"

- name: Build basis library (excluded from strict warnings)
run: opam exec -- dune build basis

- name: Build with all warnings as errors
env:
# _, = append these flags AFTER all other compiler flags
# w=+a-44-45-49-70 = enable every warning except structural ones:
# 44: open-shadow-identifier (open Basis shadows stdlib types - by design)
# 45: open-shadow-label-constructor (same as 44)
# 49: no-cmi-file (cascading from dune wrapper modules)
# 70: missing-mli (dune-generated .ml-gen wrappers)
# warn-error=+a-44-45-49-70 = treat the enabled warnings as errors
OCAMLPARAM: "_,w=+a-44-45-49-70,warn-error=+a-44-45-49-70"
run: |
echo "Building with OCAMLPARAM=\"$OCAMLPARAM\""
echo "This enables warnings 1..$MAX_WARN (except 44,45,49,70) and treats all as errors."
echo ""
opam exec -- dune build 2>&1 | tee build-warnings.log
continue-on-error: true

- name: Summarize warning counts
if: always()
run: |
echo "=== Warning/Error Summary ==="
if [ -f build-warnings.log ]; then
# Count occurrences of each warning number
echo ""
echo "Warnings by number:"
grep -oiP 'warning \K[0-9]+' build-warnings.log | sort -n | uniq -c | sort -rn || echo " (no warnings found)"
echo ""
echo "Warnings by file:"
grep -oP 'File "[^"]+' build-warnings.log | sed 's/File "//' | sort | uniq -c | sort -rn | head -30 || echo " (no warnings found)"
echo ""
TOTAL=$(grep -ciP 'warning [0-9]+' build-warnings.log || echo 0)
echo "Total warnings: $TOTAL"
else
echo "No build log found."
fi

- name: Upload build log
if: always()
uses: actions/upload-artifact@v4
with:
name: build-warnings-${{ matrix.os }}-${{ matrix.ocaml-compiler }}
path: build-warnings.log
retention-days: 30
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,7 @@ bin/dune~
bin/main.ml~
bin_old
test.elf

.claude
build/
.remember
7 changes: 7 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[submodule "basis"]
path = basis
url = https://github.com/wizard7377/basis

[submodule "twelf"]
path = twelf
url = https://github.com/standardml/twelf
129 changes: 129 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Building STELF

This document describes how to set up dependencies and build STELF locally.

STELF is an in-progress OCaml port of Twelf. Some areas of the codebase are
still under active translation, so occasional compile failures in unfinished
subsystems can be expected.

## Prerequisites

- OCaml 5.0 or newer
- opam 2.1 or newer
- dune 3.20 or newer

Optional but useful:

- `ocamlformat` (for formatting)
- `odoc` (for docs)

## One-Time Setup

From the repository root:

```bash
opam switch create . ocaml-base-compiler.5.1.1
eval "$(opam env)"

# Pin local basis package used by this repository
opam pin add -y basis ./basis

# Install dependencies for stelf
opam install -y . --deps-only --with-test --with-doc
```

If you already have a switch for this repo, you can skip switch creation and
just run:

```bash
eval "$(opam env)"
opam pin add -y basis ./basis
opam install -y . --deps-only --with-test --with-doc
```

## Build Commands

### Standard Build

```bash
dune build
```

### Release Build

```bash
dune build --profile=release
```

### Check Profile Build

```bash
dune build --profile=check
```

## Run Tests

```bash
dune test
```

Or run the test alias explicitly:

```bash
dune build @runtest
```

## Format Code

```bash
dune fmt
```

## Build Documentation

```bash
dune build @doc
```

## Build Executable

The main executable is built via dune:

```bash
dune build bin/main.exe
```

After a successful build, the binary is available under `_build/default/bin/`.

## Using Makefile Targets

Common targets:

```bash
make build
make test
make fmt
make check
```

Note: the `install` target currently depends on `build-release`, which is not
defined in the current Makefile. Prefer dune commands directly for installation
flows until that target is updated.

## Troubleshooting

- If dune cannot find dependencies, ensure your opam switch is active:

```bash
eval "$(opam env)"
```

- If `basis` resolves incorrectly, re-pin local basis and reinstall deps:

```bash
opam pin add -y basis ./basis
opam install -y . --deps-only --with-test --with-doc
```

- If build failures appear in partially ported modules, verify whether the
failure is in actively translated code before treating it as a regression.
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Contributing to STELF

These are the guidelines for contributing to the STELF project

## Style Guidelines

See the [style file](STYLE.md)
80 changes: 0 additions & 80 deletions FUTURE.typ

This file was deleted.

Loading
Loading