• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    Shell
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Builds simple esy native packages with minimal configuration.

pesy: Native Reason Project from Json.

Use package.json to automatically configure libraries and executables built with Dune.

screenshot

Commands:

  • pesy : Creates a new project in the current directory.
  • esy : Builds the current project (just like every other esy project).
  • esy pesy : Updates your build config from package.json (run this any time you change package.json).

pesy (Create New Project)

pesy global command creates esy projects instantly inside of any directory.

npm install -g pesy

cd my-project
pesy      # Hit enter to accept default name

This creates:

  • package.json with useful dependencies/compilers.
  • .gitignore and README.md with instructions for new contributors.
  • .circleci continuous integration with cache configured for ultra-fast pull requests.
  • library/, executable/ and test/ directory with starter modules.

esy (Build The Project)

Just like with any esy project, running esy from the project directory will build it and fetch/install any dependencies you might need.

esy

Your project's 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 let you know if you need to run esy pesy to update your build config from new changes to package.json.


esy pesy: (Update Build Config Based On package.json)

esy pesy

If you change your buildDirs config in package.json, run this command to update build configuration based on your latest package.json. If you forget to run this command and try to build (by running esy) without first running esy pesy, the build will remind you.


Configuring:

Configure your package.json's buildDirs field for multiple libraries and executables. buildDirs.DirectoryName means that a library or executable will be located at ./DirectoryName. The buildDirs.DirectoryName.name field determines the public name of the library or executable. a name ending in .exe is automatically configured as an executable, and a name of the form packageName.anything is automatically configured to be a library with the public name of packageName.anything.

"buildDirs": {
  "MyLibrary": {
    "name": "packageNameMyLibrary",
    "namespace": "MyLibrary",
    "require": ["console.lib"]
  },
  "Tests": {
    "name": "Tests.exe",
    "description": "Runs all the tests natively",
    "flags": ["-linkall"],
    "require": ["console.lib", "packageNameMyLibrary""]
  }
}

Supported Config

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

Field Type Description
name string The name of the binary that must end with .exe.
main string The name of the module that serves as the main entrypoint of the binary.
modes list(string) Advanced linking modes. Each string should be of the form "(<compilation-mode> <binary-kind>)" where <compilation-mode> is one byte, native or best and <binary-kind> is one of c, exe, object, shared_object.

Libraries

Field Type Description
name string The name of the library
modes list("byte"|"native"|"best") Mode which should be built by default. Useful for disabling native compilation for some libraries.
cNames list(string) List of strings to use as C stubs (filenames without the .c extension).
virtualModules list(string) List of modules within the library that will have interfaces but no implementation, causing this library to be considered "virtual". Another library can then claim to "implement" this library by including "implements": "yourLibName". See Virtual Libraries
implements list(string) List of virtual library names that this library implements.
wrapped `true false`

Both Libraries And Binaries

Field Type Description
require list(string) Public library names you want to be able to use.
flags list(string) List of strings to pass to both native and bytecode compilers.
ocamlcFlags list(string) List of flags to pass to ocamlc
ocamloptFlags list(string) List of flags to pass to ocamlopt
jsooFlags list(string) List of flags passed to jsoo
preprocess list(string) List of preprocess options to enable. Primarily used to enable PPX
ignoredSubdirs list(string) Subdirectory names to ignore (This feature is soon to be deprecated).
includeSubdirs "no"|"unqualified" Default is "no", and changing to "unqualified" will compile modules at deeper directories than the place where the dune file is generated. See Dune docs
rawBuildConfig list(string) Raw build config to be injected into the build config for this target.
rawBuildConfigFooter list(string) Raw build config to be injected into the footer of the build config.

Consuming New Package And Library Dependencies:

  • Add dependencies to dependencies in package.json.

  • Add the name of that new dependencies library to package.json's buildDirs section that you want to use the library within. For example, if your project builds a library in the exampleLib/ directory, and you want it to depend on a library named bos.top from an opam package named bos, change the package.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.

Tradeoffs:

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.

Adding pesy to an existing project.

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

Future Development:

The next major version of pesy is getting even simpler and better, and has undergone a full native rewrite.

Follow the work in its new repo: https://github.com/esy/pesy.

Changes:

version 0.4.3 (6/20/2019) Moved pesy to a devDependency of all newly created projects. Also did the same for refmterr. This causes fewer package conflicts.

version 0.4.2 (6/16/2019)

Make new projects pin to ocaml 4.7.1004 so that it compiles with Reason, since we're still waiting on Reason to work with 4.8.

version 0.4.0 (12/21/2018)

  • Allow buildDirs to contain deeper directories such as "path/to/my-lib": {...}".
  • Added support for wrapped property on libraries.
  • Added support for virtualModules and implements - properties for Dune virtual libraries. (This will only be supported if you mark your project as Dune 1.7 - not yet released).
  • Stopped using ignore_subdirs in new projects, instead using (dirs (:standard \ _esy)) which only works in Dune 1.6.0+, so made new projects have a lower bound of Dune 1.6.0.
  • Support new properties rawBuildConfig which will be inserted at the bottom of the target being configured (library/executable).
    • It expects an array of strings, each string being a separate line in the generated config.
  • Support new properties rawBuildConfigFooter which will be inserted at the bottom of the entire Dune file for the target being configured.
    • It expects an array of strings, each string being a separate line in the generated config.
  • Support new properties modes for binaries and libraries list(string).

More Repositories

1

VimBox

Simple, Modern MacVim Configuration
Vim Script
915
star
2

flex

Reason CSS Flexbox implementation
Reason
389
star
3

FaxJs

Fax Javascript Ui Framework
JavaScript
375
star
4

one-click.js

One Click, Offline, CommonJS Modules in the browser
JavaScript
332
star
5

rehp

ReHp
OCaml
222
star
6

paradoc

One Click Docs
JavaScript
179
star
7

flatlandia

Vim colorscheme based on flatland with Airline integration.
Vim Script
113
star
8

vim-reasonml

esy + vim + reason +the latest Merlin
Vim Script
108
star
9

CommonML

Simple OCaml Development Workflow on CommonJS
CSS
96
star
10

reason-project-ideas

ReasonML Projects That People Have Expressed Demand For.
86
star
11

navigating-reason

Overview of Reason tooling options for the curious.
70
star
12

reactapp

Starter App For React and CommonJS
JavaScript
51
star
13

esy-issues

Easy ISSUES
JavaScript
49
star
14

vim-taste

Colors based on elementaryOS
Vim Script
34
star
15

reasonml-manual

ReasonML Manual
HTML
33
star
16

native-reason-react-roadmap

Public design discussion about various approaches to building Native Reason React.
24
star
17

PackageJsonForCompilers

Proposal for allowing compiled languages to use the package.json sandbox model
24
star
18

VimCompleteLikeAModernEditor

Make Vim complete like a modern editor - does the right thing. Works with Ultisnips and neocomplete.
Vim Script
23
star
19

reason-wall-demo

Wall (NanoVG port) demo converted to Reason.
OCaml
15
star
20

VimSplitBalancer

Vim Script
14
star
21

common-native-reason-issues

Common Issues When Developing Native Reason Projects
13
star
22

effective-esy-packaging

Effective Esy Packaging Guide
12
star
23

VimCleanColors

Collection of Clean Vim ColorSchemes With Airline Themes
Vim Script
11
star
24

moodules

OO style Libraries for Dune
Reason
8
star
25

file-driven-development

Utilities for a stateless, serverless development environment.
8
star
26

VimJSXHint

Inline JSHint error highlighting with support for JSX
JavaScript
7
star
27

moodules-demo

Demo of virtual libraries implemented in user space.
JavaScript
5
star
28

esy-pesy-starter

Starter example using pesy
C++
3
star
29

refmt-as-ocp-indent

A quick workaround for Nuclide LSP bridge
Shell
3
star
30

VimAutoMakeDirectory

Asks to create directories in Vim when needed
Vim Script
3
star
31

VimJSDocSnippets

Automatically create JSDoc comments for functions using UltiSnips for Vim
Vim Script
3
star
32

create-reason

Esy template for Reason Projects.
3
star
33

VimCloser

Make Vim close tabs the way every other editor does - by switching to the next tab to the left.
Vim Script
2
star
34

atom-reason

CoffeeScript
2
star
35

npm-react-core

NPM build of Facebook's React JavaScript framework.
JavaScript
2
star
36

crayon

Vim Colorscheme Generator
1
star
37

CommonMLAnotherExampleDependency

Another example dependency for https://github.com/jordwalke/CommonML
OCaml
1
star
38

MacVimSmartGUITabs

Shows GUI tabs only when not in fullscreen mode.
Vim Script
1
star
39

VimLastTab

Switch to the most recently used Tab
Vim Script
1
star
40

EditorsWithVimMode

List and summaries of editors that support vim mode. Brief evaluations of completeness.
1
star
41

CommonMLExampleDependency

Example dependency for https://github.com/jordwalke/CommonML
OCaml
1
star