Skip to content

Commit

Permalink
Juvix C runtime (#1580)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz authored Nov 3, 2022
1 parent 23c2b9e commit 74bfe59
Show file tree
Hide file tree
Showing 184 changed files with 10,022 additions and 12 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ BasedOnStyle: Google, IndentWidth: 4 }
30 changes: 27 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ jobs:
--ghc-opt -XTemplateHaskell
--ghc-opt -XUnicodeSyntax
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jidicula/[email protected]
with:
clang-format-version: '15'
check-path: 'runtime/src'

hlint:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -86,7 +95,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest , macOS-latest]
os: [ubuntu-latest]
ghc: ["9.2.4"]
steps:
- name: Checkout our repository
Expand Down Expand Up @@ -118,7 +127,22 @@ jobs:
enable-stack: true
stack-version: 'latest'

- name: Build Haskell Project
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v3
with:
path: |
C:/Program Files/LLVM
./llvm
key: ${{ runner.os }}-llvm-13

- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "13.0"
cached: ${{ steps.cache-llvm.outputs.cache-hit }}

- name: Build Project
run: |
cd main
make build
Expand All @@ -128,7 +152,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest , macOS-latest]
os: [ubuntu-latest]
ghc: ["9.2.4"]
steps:
- name: Checkout the main repository
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ TAGS
# other
.DS_Store

/runtime/include
_build/
_build.*/
*.agdai
.agda/
agda2hs/
Expand All @@ -68,10 +70,17 @@ UPDATES-FOR-CHANGELOG.org
.juvix-build

# C Code generation
*.out.c
*.s
*.wasm
*.exe
docs/md/
_docs
docs/**/*.md
**/html/*

*.cmi
*.cmx
*.cmo

docs/org/README.org
41 changes: 35 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ endif

all: install

clean:
clean: clean-runtime
@stack clean --full
@rm -rf .hie
@rm -rf _docs
@rm -rf docs/md

.PHONY: clean-runtime
clean-runtime:
@cd runtime && make clean

repl:
@stack ghci Juvix:lib

Expand Down Expand Up @@ -111,7 +115,8 @@ ORMOLUFILES = $(shell git ls-files '*.hs' '*.hs-boot' | grep -v '^contrib/')
ORMOLUFLAGS?=--no-cabal
ORMOLUMODE?=inplace

format:
.PHONY: format
format: clang-format
@stack exec -- ormolu ${ORMOLUFLAGS} \
--ghc-opt -XStandaloneDeriving \
--ghc-opt -XUnicodeSyntax \
Expand All @@ -122,6 +127,10 @@ format:
--mode ${ORMOLUMODE} \
$(ORMOLUFILES)

.PHONY: clang-format
clang-format:
@cd runtime && make format

.PHONY: check-ormolu
check-ormolu: export ORMOLUMODE = check
check-ormolu:
Expand All @@ -145,7 +154,7 @@ pre-commit :
# -- Build-Install-Test-Release
# ------------------------------------------------------------------------------

STACKFLAGS?=--fast --jobs $(THREADS)
STACKFLAGS?=--jobs $(THREADS)

.PHONY: check
check:
Expand All @@ -163,26 +172,46 @@ submodules:
@git submodule sync
@git submodule update --init --recursive

.PHONY : build
build: submodules
.PHONY: build
build: submodules runtime
stack build ${STACKFLAGS}

.PHONY: fast-build
fast-build: submodules runtime
stack build --fast ${STACKFLAGS}

.PHONY: runtime
runtime:
cd runtime && make -j 4

# -- Install

.PHONY : install
install: submodules
install: runtime submodules
@stack install ${STACKFLAGS}

.PHONY : fast-install
fast-install: runtime submodules
@stack install --fast ${STACKFLAGS}

# -- Testing

.PHONY : test
test: build
@stack test ${STACKFLAGS}

.PHONY : fast-test
fast-test: fast-build
@stack test --fast ${STACKFLAGS}

.PHONY : test-skip-slow
test-skip-slow:
@stack test ${STACKFLAGS} --ta '-p "! /slow tests/"'

.PHONY : fast-test-skip-slow
fast-test-skip-slow:
@stack test --fast ${STACKFLAGS} --ta '-p "! /slow tests/"'

SHELLTEST := $(shell command -v shelltest 2> /dev/null)

.PHONY : test-shell
Expand Down
2 changes: 2 additions & 0 deletions app/Commands/Dev.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Commands.Dev.Internal qualified as Internal
import Commands.Dev.MiniC qualified as MiniC
import Commands.Dev.Options
import Commands.Dev.Parse qualified as Parse
import Commands.Dev.Runtime qualified as Runtime
import Commands.Dev.Scope qualified as Scope
import Commands.Dev.Termination qualified as Termination

Expand All @@ -28,4 +29,5 @@ runCommand = \case
Termination opts -> Termination.runCommand opts
Core opts -> Core.runCommand opts
Asm opts -> Asm.runCommand opts
Runtime opts -> Runtime.runCommand opts
DisplayRoot -> DisplayRoot.runCommand
10 changes: 10 additions & 0 deletions app/Commands/Dev/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Commands.Dev.Highlight.Options
import Commands.Dev.Internal.Options
import Commands.Dev.MiniC.Options
import Commands.Dev.Parse.Options
import Commands.Dev.Runtime.Options
import Commands.Dev.Scope.Options
import Commands.Dev.Termination.Options
import CommonOptions
Expand All @@ -28,6 +29,7 @@ data DevCommand
| Internal InternalCommand
| Core CoreCommand
| Asm AsmCommand
| Runtime RuntimeCommand
| MiniC MiniCOptions
| Parse ParseOptions
| Scope ScopeOptions
Expand All @@ -43,6 +45,7 @@ parseDevCommand =
commandInternal,
commandCore,
commandAsm,
commandRuntime,
commandMiniC,
commandParse,
commandDoc,
Expand Down Expand Up @@ -94,6 +97,13 @@ commandAsm =
(Asm <$> parseAsmCommand)
(progDesc "Subcommands related to JuvixAsm")

commandRuntime :: Mod CommandFields DevCommand
commandRuntime =
command "runtime" $
info
(Runtime <$> parseRuntimeCommand)
(progDesc "Subcommands related to the Juvix runtime")

commandParse :: Mod CommandFields DevCommand
commandParse =
command "parse" $
Expand Down
9 changes: 9 additions & 0 deletions app/Commands/Dev/Runtime.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Commands.Dev.Runtime where

import Commands.Base
import Commands.Dev.Runtime.Compile as Compile
import Commands.Dev.Runtime.Options

runCommand :: forall r. Members '[Embed IO, App] r => RuntimeCommand -> Sem r ()
runCommand = \case
Compile opts -> Compile.runCommand opts
Loading

0 comments on commit 74bfe59

Please sign in to comment.