- Use
package.json
to declare libraries and executables. - Generates
dune
config per directory.
- Create New Project: Running
pesy
globally creates a new project. - Update
pesy
project: Runningesy pesy
in an existingpesy
project will update build config according topackage.json
contents. - Build
pesy
project: Setting yourpackage.json
build
command topesy
will verify build config is up to date before building your project.
If installed globally, pesy
can be used to create esy
projects instantly
inside of any directory. The project name is determined by the current
directory, and the generated projects will use invoke each build with pesy
to
keep the dune
build config in sync.
npm install -g pesy
mkdir my-project
cd my-project
pesy # Hit enter to accept default name
This creates:
package.json
with useful dependencies/compilers..gitignore
andREADME.md
with instructions for new contributors..circleci
continuous integration with cache configured for ultra-fast pull requests.library/
,executable/
andtest/
directory with starter modules.
The created project uses pesy
in its build step. As always, run esy pesy
any time you update the build config in the package.json
.
Once you've created a project, you normally only ever run esy build
on the
command line. If you update your package.json
buildDirs
field, you will
need to run esy pesy
which will update all the project build config based on
your package.json
file changes. Then, you just run esy build
as usual. You
only need to run esy pesy
if you change your package.json
file.
(Hopefully, this could be automatically done in the future so you only ever run
esy build
as usual).
If you created your project by invoking the globally installed pesy
, then
your project is already setup to use pesy
at build time. Its esy.build
field is set to pesy
, which will run pesy
to verify that all your build
config is up to date before invoking the Dune build. It will help walk you
through updating the Dune build config from your package.json
if anything is
out of date.
You probably don't need pesy
if you have an existing project that is working
well, but to add pesy
to an existing project, follow these steps:
1. Add a dependency on pesy
, and configure buildDirs
:
{
"name": "my-package",
"dependencies": {
"pesy": "*"
},
"buildDirs": {
"exampleLib": {
"namespace": "Examples",
"name": "my-package.example-lib",
"require": [ "bos.top" ]
},
"bin": {
"name": "my-package.exe",
"require": [
"my-package.lib"
]
}
}
}
2.Install and Build:
esy install
esy pesy # Generate the project build config from json
esy build
The following example project already has an example config. You can base your project off of this one.
npm install -g esy@next
git clone git@github.com:jordwalke/esy-peasy-starter.git
esy install
esy pesy # Use pesy to configure build from package.json
esy build
- Change the
name
of the package, and names of libraries inbuildDirs
accordingly. - Then rerun:
esy pesy
esy build
Use the standard esy x any-command-here
command to run any-command-here
as
if you had installed the package. For example esy x YourPackage.exe --args
builds and runs your built YourPackage.exe
executable with arguments.
-
Add dependencies to
dependencies
inpackage.json
. -
Add the name of that new dependencies library to
package.json
'sbuildDirs
section that you want to use the library within. For example, if your project builds a library in theexampleLib/
directory, and you want it to depend on a library namedbos.top
from an opam package namedbos
, change thepackage.json
to look like this:{ "name": "my-package", "dependencies": { "@opam/bos": "*" }, "buildDirs": { "exampleLib": { "namespace": "Examples", "name": "my-package.example-lib", "require": [ "bos.top" ] } } }
-
Then run:
esy install # Fetch dependency sources esy pesy # Configure the build based on package.json esy build # Do the build
Note: After adding/building a new dependency you can use
esy ls-libs
to see which named libraries become available to you by adding the package dependency.
Note: You can also use
esy ls-modules
to see which named modules become available to you from those libraries.
esy-pesy
is good for rapidly making new small executables/libraries. Once they
grow, you'll want to "eject out" of esy-pesy
and begin customizing using a more
advanced build system.
Not all config is supported. This is just a proof of concept. If you'd like to add support for more config fields, PRs are welcomed.
Binaries
name
: The name of the binary
Libraries
name
: The name of the librarynamespace
: The name that other modules will see your module as, within their source code, if theyrequire
your library.cNames
: Array of strings to use as C stubs (filenames without the.c
extension).
Both
require
: Array of strings (public library names).flags
: Array of strings to pass to bothocamlc
andocamlopt
.ocamlcFlags
: Array of flags to pass toocamlc
.ocamloptFlags
: Array of flags to pass toocamlopt
.jsooFlags
: Array of flags passed tojsoo
.preprocess
: Array of preprocess options to enable. Primarily used to enable PPX.ignoredSubdirs
: Array of subdirectory names to ignore.includeSubdirs
: (string) either "no" or "unqualified".