Skip to content

Conversation

@ulrikstrid
Copy link
Contributor

@ulrikstrid ulrikstrid commented Sep 17, 2019

This PR adds a esy.json to allow a workflow that is just, clone the repo and run 2 esy commands (can be shortened to just 1 if you run esy) and then you build the whole project.

git clone bucklescript esy install esy build 

It depends on this PR to the ocaml fork which adds a package.json into the repo so that we can depend on the ocaml version via esy: rescript-lang/ocaml#35

The changes in ninja.js where needed since I couldn't get it to work with the -env flag otherwise, if someone can point me to what I'm doing wrong please let me know and I'll revert those changes. I think the "normal" workflow should still work.

@ulrikstrid ulrikstrid force-pushed the build-with-esy branch 3 times, most recently from ba4b176 to aa84dd6 Compare September 17, 2019 15:00
@bobzhang
Copy link
Member

hi @ulrikstrid we are happy to make it build with esy.
A couple of questions

  • Which part is built with esy? Is it the vendored compiler or bsc itself
  • Can you add some explanations why you need change ninja.js
  • Can we disable it for CI since it may slow down the CI IIUC
@cristianoc
Copy link
Collaborator

Looks like CI is timing out.

@ulrikstrid
Copy link
Contributor Author

@bobzhang I have updated the description of the PR, I forgot to add it when I opened the PR.

There is something wrong with the CI setup that I can't explain, do you want me to just remove it for now?

If this gets merged I would be happy to open a PR for Azure Pipelines setup where we can do corssplatform builds like we do in many other esy projects.

@jordwalke
Copy link

We can just disable the CI for esy stuff, and enable azure pipelines (or github actions) since they have great esy caching integration anyways. Maybe we should move everything to Azure/Actions since you can have all three platforms CI in one place?

@bobzhang
Copy link
Member

If -env is not relied on, let’s remove it, it was introduced to allow switching compilers instantly , but in practice, it’s not used that much

@ulrikstrid
Copy link
Contributor Author

ulrikstrid commented Sep 19, 2019

@bobzhang I'm using -env so that it picks up the OCaml version I'm dependending on via esy. It seems like it has not been updated/tested properly because it was missing some stuff and it seems like ninja never looked for the env.ninja file so I just changed it everywhere. I can simplify the code if you want me to but I wanted to keep the structure if someone found something obvious that I was missing.

If we only had the esy workflow we wouldn't need to have the git submodule since it's modeled as a dependency instead. As soon as the OCaml changes are applied on the 4.06.1+BS branch I should in theory be apple to just add a package.json there and add a resolution to that branch.

@cristianoc
Copy link
Collaborator

@ulrikstrid I'm following along the developments here. As the same learning can then be applied here: rescript-association/genType#100.

@bobzhang
Copy link
Member

bobzhang commented Sep 19, 2019

@ulrikstrid so you do rely on -env flag to pick the compiler from esy instead of vendored, right?

Edit: what's your goal here? are you trying to make people install bs-platform using esy (I guess it is) or trying to make people develop bucklescript using esy?
If it is the former, I guess you need change scripts/install.js instead of scripts/ninja.js

Btw, how do we know the script is running under esy, by some env variable, and env will inject some PATHs to make ocaml available?

Copy link
Member

@bobzhang bobzhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work on windows?

@@ -0,0 +1,80 @@
{
"name": "bs-platform",
"version": "5.2.0-dev.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need maintain this, if so, which other fields do we need watch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for "dependencies", "devDependencies", "resolutions" and "esy" it's a copy of the normal package.json, I think we could just remove most fields if we don't want them here.

} else {
file = path.join(__dirname, "..", "ocaml", "VERSION");
}
if (!fs.existsSync(file)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

myVersion,
"bin",
"ocamlopt.opt"
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

async function runtimeNinja(devmode = true) {
var ninjaCwd = "runtime";
var externalDeps = devmode ? [compilerTarget] : [];
var ninjaOutput = devmode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep this file unchanged for this PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env.ninja is not used and maintained for a while, we may consider removing it and add the corresponding one later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted changes to ninja.js

esy.json Outdated
},
"esy": {
"buildsInSource": true,
"buildDev": [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I remove this part as well since the ninja.js file is not working with the setup any more? @bobzhang

@ulrikstrid
Copy link
Contributor Author

Rebased on master to fix conflict in ocamlbuild.js

@bobzhang bobzhang merged commit 5d11fb0 into rescript-lang:master Sep 20, 2019
@bobzhang
Copy link
Member

Would you provide a doc or guide on how to use bs-platform with esy? Thanks

@jordwalke
Copy link

Thank you @ulrikstrid !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants