Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Dune + CI #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on: [push, pull_request]

jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
ocaml-version:
- 4.09.1

runs-on: ${{ matrix.os }}

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

- name: Set-up OCaml ${{ matrix.ocaml-version }}
uses: avsm/setup-ocaml@v1
with:
ocaml-version: ${{ matrix.ocaml-version }}

- run: opam pin add ocamlclean.dev . --no-action
- run: opam install . --deps-only
- run: opam exec -- make
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
src/_build/
src/config.ml
etc/Makefile.conf
etc/config.ml
_build/
49 changes: 9 additions & 40 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -1,49 +1,22 @@
Installing OCamlClean on a Unix machine
---------------------------------------
Installing OCamlClean on a machine
----------------------------------

PREREQUISITES

* The OCaml standard distribution
* Dune


INSTALLATION INSTRUCTIONS

1- Configure the system. From the top directory, do:

./configure

This generates the two configuration files "Makefile.conf" and "config.ml"
in the ./etc/ subdirectory.

The "configure" script accepts the following options:

-bindir <dir> (default: /usr/local/bin)
Directory where the binaries will be installed.

-mandir <dir> (default: /usr/local/man/man1)
Directory where the manual pages will be installed.

-prefix <dir> (default: /usr/local)
Set bindir and mandir to <dir>/bin, <dir>/man/man1 respectively.


Examples:

Standard installation in /usr/{bin,man} instead of /usr/local:
./configure -prefix /usr

Installation in /usr, man pages in section "l":
./configure -bindir /usr/bin -mandir /usr/man/manl


2- From the top directory, do:
1- From the top directory, do:

make

This builds the ocamlclean program in directory: ./bin/.
This builds the ocamlclean program in directory: _build/install/default/bin/


3- You can now install the OCamlClean system. This will create the
2- You can now install the OCamlClean system. This will create the
following command (in the binary directory selected during
autoconfiguration):

Expand All @@ -52,20 +25,16 @@ autoconfiguration):
From the top directory, become superuser and do:

umask 022 # make sure to give read & execute permission to all
make install
dune install

4- Installation is complete. Time to clean up. From the toplevel
3- Installation is complete. Time to clean up. From the toplevel
directory, do:

make clean


UNINSTALLATION INSTRUCTIONS

1- If configuration files (./etc/Makefile.conf and ./etc/config.ml)
have been lost, run again ./configure from the top directory with the
same options as at step 1 of installation.

2- From the top directory, become superuser and do:
1- From the top directory, become superuser and do:

make uninstall
31 changes: 7 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,21 @@
## ##
###########################################################################

include etc/Makefile.conf
DUNE=dune

all: config
$(call compile, src)

config:
@if [ $(ETC)/Makefile.conf -ot VERSION -o \
$(ETC)/Makefile.conf -ot configure ]; then \
echo 'Configuration files are not up to date.' 1>&2; \
echo 'Please run `./configure` (with right options).' 1>&2; \
exit 1; \
fi
all:
$(DUNE) build @install

install: all
mkdir -p "$(BINDIR)"
mkdir -p "$(MAN1DIR)"
cp bin/ocamlclean "$(BINDIR)/ocamlclean"
cp man/ocamlclean.1.gz "$(MAN1DIR)/ocamlclean.1.gz"
$(DUNE) install

uninstall:
-rm -f "$(BINDIR)/ocamlclean"
-rm -f "$(MAN1DIR)/ocamlclean.1.gz"

etc/Makefile.conf:
@echo "You must run ./configure before" 1>&2
@exit 1
$(DUNE) uninstall

dist: clean
dist/distgen

clean:
@rm -f *~ */*~ */*/*~
$(call clean, src)
$(DUNE) clean

.PHONY: all config install uninstall dist clean
.PHONY: all install uninstall dist clean
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

2 changes: 0 additions & 2 deletions bin/.gitignore

This file was deleted.

106 changes: 0 additions & 106 deletions configure

This file was deleted.

7 changes: 4 additions & 3 deletions dist/distgen
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@

cd $(dirname "$0")

VERSION=$(cat ../VERSION)
VERSION=$(sed -ne 's/.*(version \+\(.*\) *).*/\1/p' ../dune-project)
DEST=ocamlclean-"$VERSION"

for d in "$DEST" "$DEST/dist" "$DEST/etc"; do
for d in "$DEST" "$DEST/dist"; do
mkdir "$d"
done

for d in \
bin configure INSTALL LICENSE-fr LICENSE-en Makefile man src VERSION;
INSTALL LICENSE-fr LICENSE-en Makefile man src \
dune-project ocamlclean.opam;
do
cp -R ../"$d" "$DEST/"
done
Expand Down
3 changes: 3 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 1.0)
(name ocamlclean)
(version 2.2)
2 changes: 0 additions & 2 deletions etc/.gitignore

This file was deleted.

3 changes: 3 additions & 0 deletions man/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(install
(files ocamlclean.1.gz)
(section man))
15 changes: 15 additions & 0 deletions ocamlclean.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
opam-version: "2.0"
authors: ["Benoît Vaugon"]
homepage: "http://www.algo-prog.info/ocapic/web/index.php?id=OCAPIC:OCamlClean"
bug-reports: "https://github.com/bvaugon/ocamlclean/issues"
dev-repo: "git+https://github.com/bvaugon/ocamlclean.git"
maintainer: "[email protected]"
build: [
["dune" "subst"] {dev}
["dune" "build" "-p" name "-j" jobs "@install"]
]
depends: [
"ocaml" {>= "4.09" & < "4.10.0"}
"dune"
]
synopsis: "Reduce size of OCaml bytecode files by dead-code removing"
33 changes: 0 additions & 33 deletions src/Makefile

This file was deleted.

7 changes: 7 additions & 0 deletions src/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(executable
(name main)
(public_name ocamlclean))

(rule
(with-stdout-to config.ml
(echo "let version = \"%{version:ocamlclean}\"")))
2 changes: 1 addition & 1 deletion src/index.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type section = Code | Dlpt | Dlls | Prim | Data | Symb | Crcs | Dbug

type t = (section * int * int) list

let magic_str = "Caml1999X023"
let magic_str = "Caml1999X026"

let parse ic =
let magic_size = String.length magic_str in
Expand Down
2 changes: 1 addition & 1 deletion src/step1.ml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ let prepare_code old_code cleanables ignore_fulls =
f (succ indg) adds cleans
| None -> f (succ indg) adds cleans
else
(List.sort Pervasives.compare adds, cleans)
(List.sort Stdlib.compare adds, cleans)
in
let adds, cleans = f 0 [] [] in
let old_code_size = Array.length old_code in
Expand Down