Skip to content

Commit

Permalink
Change installed package file layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Augustsson authored and Lennart Augustsson committed Nov 16, 2024
1 parent 46c6609 commit 13fc8b8
Show file tree
Hide file tree
Showing 8 changed files with 6,311 additions and 6,275 deletions.
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ emscripten: bin/mhs targets.conf

######

VERSION=0.10.5.0
HVERSION=0,10,5,0
VERSION=0.10.6.0
HVERSION=0,10,6,0
MCABAL=$(HOME)/.mcabal
MCABALMHS=$(MCABAL)/mhs-$(VERSION)
MDATA=$(MCABALMHS)/data/mhs-$(VERSION)/data
MDATA=$(MCABALMHS)/packages/mhs-$(VERSION)/data
MRUNTIME=$(MDATA)/src/runtime
MCABALBIN=$(MCABAL)/bin
MDIST=dist-mcabal
Expand All @@ -226,12 +226,16 @@ $(MCABALBIN)/cpphs: bin/cpphs
@mkdir -p $(MCABALBIN)
cp bin/cpphs $(MCABALBIN)

$(MCABALBIN)/mcabal: bin/mcabal
@mkdir -p $(MCABALBIN)
cp bin/mcabal $(MCABALBIN)

$(MCABALMHS)/packages/$(BASE).pkg: bin/mhs lib/*.hs lib/*/*.hs lib/*/*/*.hs
bin/mhs -P$(BASE) -o$(BASE).pkg -ilib $(BASEMODULES)
bin/mhs -Q $(BASE).pkg $(MCABALMHS)
@rm $(BASE).pkg

install: $(MCABALBIN)/mhs $(MCABALBIN)/cpphs $(MCABALMHS)/packages/$(BASE).pkg
install: $(MCABALBIN)/mhs $(MCABALBIN)/cpphs $(MCABALBIN)/mcabal $(MCABALMHS)/packages/$(BASE).pkg
@echo $$PATH | tr ':' '\012' | grep -q $(MCABALBIN) || echo '***' Add $(MCABALBIN) to the PATH

# mkdir ~/.mcabal/packages/array-0.5.6.0
Expand All @@ -242,5 +246,5 @@ preparedist: newmhsz bootstrapcpphs

minstall: bin/cpphs bin/mcabal $(MCABALBIN)/mhs
cp bin/cpphs bin/mcabal $(MCABALBIN)
PATH=$(MCABALBIN):"$$PATH" mcabal install
cd lib; PATH=$(MCABALBIN):"$$PATH" mcabal install
PATH=$(MCABALBIN):"$$PATH" mcabal install
2 changes: 1 addition & 1 deletion MicroHs.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: MicroHs
version: 0.10.5.0
version: 0.10.6.0
-- *** When changing the version number, also
-- *** run 'sh updateversion.sh'
-- *** Yeah, it stinks.
Expand Down
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,53 @@ Packages can depend on already installed packages.

There is a search path for installed packages, controlled by the `-a` flag.

There is no need for any extra flags to `mhs` to use installed packages, they are all visible at all times.
When compiling to a binary only the used parts of a package will be included in the binary.

### Compiling a package
To compile a package use the command `mhs -Ppackage-name.pkg modules...` where `modules...`
are all the modules you wish to expose from the package. If other modules are needed they will
automatically be included in the package.
You typically also want to use the `-o` flag to give the package a sensible name.

### Installing a package
To install a package use the command `mhs -Q package-name.pkg [install-dir]`.
If the `install-dir` is left out the package is installed in the default place.

There is no need for any extra flags to `mhs` to use installed packages, they are all visible at all times.
When compiling to a binary only the used parts of a package will be included in the binary.
### MicroCabal (`mcabal`)
Normally a package is downloaded from hackage and it will have a `.cabal` file
that describes the package contents. To install a downloaded package simply
do `mcabal install`. The `mcabal` program is included in the MicroHs download.
You can also do `mcabal install PKG` to download an install a package.

### Installed package organization
The packages are typically installed in `~/.mcabal/` and it has the following
layout:
* `.mcabal/bin/` installed binaries, initially `mhs`, `cpphs`, and `mcabal`
* `.mcabal/mhs-VER/` installed files for the given `mhs` version
* `.mcabal/mhs-VER/packages/` for each library package a `PKG.pkg` file (the binary blob for the package)
and also (maybe) a directory `PKG/` that contains `data/`, `include/`, and `cbits/` for the package.
* `.mcabal/.../MODULE.txt` a file for each installed module, it contains the name of the package the contains that module.

For example, after installing `mhs` version 0.10.5.0 we will have something like this:
```
.mcabal/
bin/cpphs
mcabal
mhs
mhs-0.10.5.0/Control/Applicative.txt -- contains "base-0.10.5.0.pkg"
...
Monad/Fail.txt -- contains "base-0.10.5.0.pkg"
...
...
Data/
...
Prelude.txt -- contains "base-0.10.5.0.pkg"
packages/base-0.10.5.0.pkg
mhs-0.10.5.0/data/src/runtime/eval.c
...
```


A (maybe) short-coming of the package system is that there can only be one version of a
package installed at a time. If you need multiple version, you have to use different directories for them
Expand Down
Loading

0 comments on commit 13fc8b8

Please sign in to comment.