Skip to content

Commit

Permalink
Merge pull request #445 from smorimoto/setup-ocaml-v3
Browse files Browse the repository at this point in the history
Prepare for Better Windows Support
  • Loading branch information
gfngfn authored Jul 4, 2024
2 parents 98d8eb2 + b21c43c commit c712a75
Show file tree
Hide file tree
Showing 15 changed files with 328 additions and 151 deletions.
15 changes: 4 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
# See editorconfig.org for details

root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8

[*.{ml,mli,mll,mly}]
indent_style = space
indent_size = 2

[*.{saty,satyh}]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_style = tab
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
48 changes: 36 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
name: CI

on:
- push
- pull_request
push:
pull_request:
schedule:
# Prime the caches every Monday
- cron: 0 1 * * MON

jobs:
build:
name: Build

strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
# - windows-latest
ocaml-compiler:
- "4.12"
- "4.13"
- "4.14"

runs-on: ${{ matrix.os }}
Expand All @@ -24,25 +27,28 @@ jobs:
- name: Checkout tree
uses: actions/checkout@v4

- name: Cache dist fonts
# - name: Set SHELLOPTS=igncr on Windows
# if: runner.os == 'Windows'
# run: echo "SHELLOPTS=igncr" >>"$GITHUB_ENV"

- name: Restore fonts cache
uses: actions/cache@v4
id: fonts-cache
with:
path: lib-satysfi/dist/fonts
key: cache-dist-fonts-${{ hashFiles('download-fonts.sh') }}

- name: Set-up OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
dune-cache: true
allow-prerelease-opam: true
opam-repositories: |
satysfi-external: https://github.com/gfngfn/satysfi-external-repo.git
default: https://github.com/ocaml/opam-repository.git
satysfi-external: git+https://github.com/gfngfn/satysfi-external-repo.git
default: git+https://github.com/ocaml/opam-repository.git
- name: Install SATySFi dependencies
run: opam install . --deps-only --with-doc
run: opam install . --deps-only

- name: Build SATySFi
run: opam exec -- make all
Expand All @@ -56,11 +62,29 @@ jobs:

- name: Install SATySFi
run: |
opam install -y .
opam install .
./install-libs.sh ~/.satysfi
- name: Build demo docs
run: |
(cd demo; opam exec -- make)
(cd doc; opam exec -- make)
(cd tests; opam exec -- make)
lint-opam:
runs-on: ubuntu-latest
steps:
- name: Checkout tree
uses: actions/checkout@v4

- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "4.14"
dune-cache: true
opam-repositories: |
satysfi-external: git+https://github.com/gfngfn/satysfi-external-repo.git
default: git+https://github.com/ocaml/opam-repository.git
- name: Lint opam
uses: ocaml/setup-ocaml/lint-opam@v3
3 changes: 1 addition & 2 deletions bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
(name satysfi)
(public_name satysfi)
(libraries main)
(preprocess no_preprocessing)
)
(preprocess no_preprocessing))
34 changes: 17 additions & 17 deletions download-fonts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@ MESSAGE_PREFIX="[download-fonts.sh]"
cd "$(dirname "$0")"
mkdir -p "$CACHE"

show_message () {
show_message() {
echo "$MESSAGE_PREFIX $1."
}

if command shasum --version >/dev/null 2>&1 ; then
if command shasum --version >/dev/null 2>&1; then
show_message "Using shasum"
SHA1SUM=shasum
elif command sha1sum --version >/dev/null 2>&1 ; then
elif command sha1sum --version >/dev/null 2>&1; then
show_message "Using sha1sum"
SHA1SUM=sha1sum
else
echo "No SHA checksum checkers found. Please install shasum or sha1sum" >&2
exit 1
fi

validate_file () {
validate_file() {
(
NAME="$1"
cd "$CACHE"
$SHA1SUM --check "$NAME.sha1"
NAME="$1"
cd "$CACHE"
$SHA1SUM --check "$NAME.sha1"
)
}

download_file () {
download_file() {
(
NAME="$1"
URL="$2"
if [ -f "$CACHE/$NAME" ] && validate_file "$NAME" ; then
show_message "'$NAME' found in '$CACHE/'."
else
show_message "downloading '$NAME' ..."
wget -O "$CACHE/$NAME" "$URL"
show_message "finished downloading '$NAME'."
fi
NAME="$1"
URL="$2"
if [ -f "$CACHE/$NAME" ] && validate_file "$NAME"; then
show_message "'$NAME' found in '$CACHE/'."
else
show_message "downloading '$NAME' ..."
wget -O "$CACHE/$NAME" "$URL"
show_message "finished downloading '$NAME'."
fi
)
}

Expand Down
79 changes: 77 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,3 +1,78 @@
(lang dune 1.0)
(lang dune 3.16)

(using menhir 2.1)

(name satysfi)
(using menhir 1.0)

(version 0.0.11)

(license LGPL-3.0-only)

(authors "Takashi Suwa")

(maintainers "Takashi Suwa")

(source
(github gfngfn/SATySFi))

(generate_opam_files true)

(package
(name satysfi)
(synopsis "A statically-typed, functional typesetting system")
(description
"SATySFi is a typesetting system equipped with a statically-typed, functional programming language. It consists mainly of two “layers” ― the text layer and the program layer. The former is for writing documents in LaTeX-like syntax. The latter, which has OCaml-like syntax, is for defining functions and commands. SATySFi enables you to write documents markuped with flexible commands of your own making. In addition, its informative type error reporting will be a good help to your writing.")
(depends
(ocaml
(and
(>= 4.12.0)
(< 5.0.0)))
(batteries
(and
(>= 3.6.0)
(< 4.0)))
(camlimages
(and
(>= 5.0.1)
(< 5.0.5)))
(camlpdf
(= 2.3.1+satysfi))
(core_kernel
(and
(>= v0.15)
(< v0.17)))
(cppo
(and
:build
(>= 1.6.4)
(< 1.7.0)))
(menhir
(and
:build
(>= 20231231)))
(menhirLib
(>= 20231231))
(ocamlfind :build)
(omd
(and
(>= 1.3.2)
(< 2.0)))
(otfed
(and
(>= 0.3.1)
(< 0.4)))
(ppx_deriving
(and
(>= 5.2.1)
(< 6.0)))
(re
(and
:build
(>= 1.10.4)
(< 2.0)))
(uutf
(and
(>= 1.0.3)
(< 2.0)))
(yojson-with-position
(= 1.4.2+satysfi))))
28 changes: 14 additions & 14 deletions install-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

LIBDIR=${1:-/usr/local/share/satysfi}

install -d ${LIBDIR}
install -d ${LIBDIR}/dist
install -d ${LIBDIR}/dist/unidata
install -m 644 lib-satysfi/dist/unidata/*.txt ${LIBDIR}/dist/unidata
install -d ${LIBDIR}/dist/fonts
install -m 644 lib-satysfi/dist/fonts/* ${LIBDIR}/dist/fonts
install -d ${LIBDIR}/dist/hash
install -m 644 lib-satysfi/dist/hash/* ${LIBDIR}/dist/hash
install -d ${LIBDIR}/dist/hyph
install -m 644 lib-satysfi/dist/hyph/* ${LIBDIR}/dist/hyph
install -d ${LIBDIR}/dist/packages
install -m 644 lib-satysfi/dist/packages/* ${LIBDIR}/dist/packages
install -d ${LIBDIR}/dist/md
install -m 644 lib-satysfi/dist/md/* ${LIBDIR}/dist/md
install -d "${LIBDIR}"
install -d "${LIBDIR}/dist"
install -d "${LIBDIR}/dist/unidata"
install -m 644 lib-satysfi/dist/unidata/*.txt "${LIBDIR}/dist/unidata"
install -d "${LIBDIR}/dist/fonts"
install -m 644 lib-satysfi/dist/fonts/* "${LIBDIR}/dist/fonts"
install -d "${LIBDIR}"/dist/hash
install -m 644 lib-satysfi/dist/hash/* "${LIBDIR}/dist/hash"
install -d "${LIBDIR}/dist/hyph"
install -m 644 lib-satysfi/dist/hyph/* "${LIBDIR}/dist/hyph"
install -d "${LIBDIR}"/dist/packages
install -m 644 lib-satysfi/dist/packages/* "${LIBDIR}/dist/packages"
install -d "${LIBDIR}"/dist/md
install -m 644 lib-satysfi/dist/md/* "${LIBDIR}/dist/md"
54 changes: 27 additions & 27 deletions satysfi.opam
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
name: "satysfi"
version: "0.0.11"
maintainer: "Takashi Suwa"
authors: [
"Takashi Suwa"
]
synopsis: "A statically-typed, functional typesetting system"
description:
"SATySFi is a typesetting system equipped with a statically-typed, functional programming language. It consists mainly of two “layers” ― the text layer and the program layer. The former is for writing documents in LaTeX-like syntax. The latter, which has OCaml-like syntax, is for defining functions and commands. SATySFi enables you to write documents markuped with flexible commands of your own making. In addition, its informative type error reporting will be a good help to your writing."
maintainer: ["Takashi Suwa"]
authors: ["Takashi Suwa"]
license: "LGPL-3.0-only"
homepage: "https://github.com/gfngfn/SATySFi"
dev-repo: "git+https://github.com/gfngfn/SATySFi.git"
bug-reports: "https://github.com/gfngfn/SATySFi/issues"
depends: [
"dune" {>= "3.16"}
"ocaml" {>= "4.12.0" & < "5.0.0"}
"batteries" {>= "3.6.0" & < "4.0"}
"camlimages" {>= "5.0.1" & < "5.0.5"}
"camlpdf" {= "2.3.1+satysfi"}
"core_kernel" {>= "v0.15" & < "v0.17"}
"cppo" {build & >= "1.6.4" & < "1.7.0"}
"menhir" {build & >= "20231231"}
"menhirLib" {>= "20231231"}
"ocamlfind" {build}
"omd" {>= "1.3.2" & < "2.0"}
"otfed" {>= "0.3.1" & < "0.4"}
"ppx_deriving" {>= "5.2.1" & < "6.0"}
"re" {build & >= "1.10.4" & < "2.0"}
"uutf" {>= "1.0.3" & < "2.0"}
"yojson-with-position" {= "1.4.2+satysfi"}
"odoc" {with-doc}
]
dev-repo: "git+https://github.com/gfngfn/SATySFi.git"
build: [
["mkdir" "-p" "temp"]
[make "-f" "Makefile" "PREFIX=%{prefix}%"]
Expand All @@ -18,24 +39,3 @@ install: [
remove: [
[make "-f" "Makefile" "uninstall" "PREFIX=%{prefix}%"]
]
# Packages whose version suffix is "+satysfi" are distributed on satysfi-external-repo.
depends: [
"ocaml" {>= "4.12.0" & < "5.0.0"}
"batteries" {>= "3.6.0" & < "4.0.0"}
"camlimages" {>= "5.0.1" & < "5.0.5"}
"camlpdf" {= "2.3.1+satysfi"}
"core_kernel" {>= "v0.15" & < "v0.16"}
"cppo" {build & >= "1.6.4" & < "1.7.0"}
"dune" {build}
"menhir"
"ocamlfind" {build}
"otfed" {>= "0.3.1" & < "0.4"}
"ppx_deriving" {>= "5.2.1" & < "6.0.0"}
"re" {build & >= "1.10.4" & < "2.0.0"}
"uutf" {>= "1.0.3" & < "2.0.0"}
"yojson-with-position" {= "1.4.2+satysfi"}
"omd" {>= "1.3.2" & < "2.0.0~"}
]
synopsis: "A statically-typed, functional typesetting system"
description: """
SATySFi is a typesetting system equipped with a statically-typed, functional programming language. It consists mainly of two “layers” ― the text layer and the program layer. The former is for writing documents in LaTeX-like syntax. The latter, which has OCaml-like syntax, is for defining functions and commands. SATySFi enables you to write documents markuped with flexible commands of your own making. In addition, its informative type error reporting will be a good help to your writing."""
10 changes: 10 additions & 0 deletions satysfi.opam.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
build: [
["mkdir" "-p" "temp"]
[make "-f" "Makefile" "PREFIX=%{prefix}%"]
]
install: [
[make "-f" "Makefile" "install" "PREFIX=%{prefix}%"]
]
remove: [
[make "-f" "Makefile" "uninstall" "PREFIX=%{prefix}%"]
]
2 changes: 1 addition & 1 deletion src/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let resolve_lib_file_scheme (relpath : lib_path) : string option * string list =

let resolve_lib_file_opt (relpath : lib_path) : abs_path option =
let (opt, _) = resolve_lib_file_scheme relpath in
opt |> BatOption.map make_abs_path
opt |> Option.map make_abs_path


let resolve_lib_file_exn (relpath : lib_path) : abs_path =
Expand Down
Loading

0 comments on commit c712a75

Please sign in to comment.