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

[internal] get the reason bspack build script working with esy #2153

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

jaredly
Copy link
Contributor

@jaredly jaredly commented Aug 21, 2018

This basically means all you need is to clone the repo and do cd bspacks; ./bspack.js and it will All Work™

I think this is a much smoother workflow... lmk if there's anything I haven't thought of though.

(this is motivated in part by the desire to make reason releases easier to do)

let version = "3.3.3"
let git_version = "fefe5e4db3a54a7946c2220ee037dd2f407011c9"
let git_short_version = "fefe5e4d"
let version = "4.4.5"
Copy link
Contributor

Choose a reason for hiding this comment

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

This version seems interesting 😄

bspacks/esy.json Outdated
"build": [
["echo", "No-op"]
],
"_dependenciesForNewEsyInstaller": {
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be needed. Was it? It was just a hack for some special cased packages to make sure some old projects will continue to install correctly. It no longer applies.

bspacks/esy.json Outdated
"@opam/menhir": " >= 20170418.0.0 <= 20171013.0.0",
"@opam/ocaml-migrate-parsetree": "*"
},
"peerDependencies": {
Copy link
Member

Choose a reason for hiding this comment

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

peerDependencies are now no longer needed. The constraint solver fixed that ;)

cd $THIS_SCRIPT_DIR

# Install & build menhir, omp
esy i
Copy link
Member

@jordwalke jordwalke Aug 21, 2018

Choose a reason for hiding this comment

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

<3

I had the same idea a while ago (to automate the CI via esy). Glad you're doing it.

# rebuild the project in case it was stale
cd ..
# We need 4.02 for js_of_ocaml (it has a stack overflow otherwise :/)
sed -i '' 's/"ocaml": "~4.6.0"/"ocaml": "~4.2.3004"/' ./esy.json
Copy link
Member

Choose a reason for hiding this comment

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

I can see why you wanted the sandboxes feature. It's unfortunate you had to destroy the esy.json file.

cd ..
# We need 4.02 for js_of_ocaml (it has a stack overflow otherwise :/)
sed -i '' 's/"ocaml": "~4.6.0"/"ocaml": "~4.2.3004"/' ./esy.json
make pre_release
Copy link
Member

Choose a reason for hiding this comment

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

I think you want to do something like version=<VERSION> make pre_release. Probably want to read it out of the esy.json file's version field.

get_omp () {
mkdir $ocamlMigrateParseTreeTargetDir

esy build-env node_modules/@opam/ocaml-migrate-parsetree > _get_root
Copy link
Member

@jordwalke jordwalke Aug 21, 2018

Choose a reason for hiding this comment

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

In the latest esy you can make esy.json "scripts" entries which give you access to variables such as #{ocaml-migrate-parsetree.build}.

You can then run them via esy script-name

cd $THIS_SCRIPT_DIR

# Install & build menhir, omp
esy i
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't

esy install
esy build

the same as just esy now? But I maybe we want it more explicit?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. However, we might find some issues with the esy=esy i && esy b shortcut so it's good to be explicit in case it changes.

@jordwalke
Copy link
Member

Ready to have this merged?

@chenglou
Copy link
Member

chenglou commented Aug 23, 2018

I think I have a different sed:

sed: can't read s/"ocaml": "~4.6.0"/"ocaml": "~4.2.3004"/: No such file or directory

I recall installing gnu-sed because the macOS sed is old. What to do here? This might fail CI

@ulrikstrid
Copy link
Contributor

When using -i on my mac I had to use '' but that fails on Linux where it's not needed and I think that is what @chenglou is hitting.

@chenglou
Copy link
Member

@jaredly hold on, you make refmt work with bsc. Maybe the sed can be dropped altogether?

@jaredly
Copy link
Contributor Author

jaredly commented Aug 24, 2018

@chenglou I changed set to use gnu format.
And the "make it work with bsc" is a rather more invasive change, I wanted to get this merged first.

@chenglou
Copy link
Member

On newest Esy:

❯ version=3.4.5 ./reason_bspack.sh
info esy install 0.2.6
info esy build 0.2.6
info found esy manifests: esy.json
esy: error, exiting...
     invalid dependency @opam/ocaml: unable to resolve package
       processing package: get-js-of-ocaml@xxx
       processing package: @opam/base-ocamlbuild@base

@chenglou
Copy link
Member

chenglou commented Oct 5, 2018

Trying this again. I got:

File "reason_parser.ml", line 5, characters 2-42:
Error: Unbound value MenhirLib.StaticVersion.require_20180905

@jaredly
Copy link
Contributor Author

jaredly commented Oct 5, 2018

That means it's finding the wrong version of menhir :/ I'll take a look.

@jchavarri
Copy link
Contributor

jchavarri commented Nov 25, 2019

I picked up from @jaredly's branch, and updated with latest master: https://github.com/jchavarri/reason/tree/joo. Feel free to incorporate it to this PR if it's useful.

Most relevant changes:

  • Move to esy.lock folder format of recents versions of esy
  • Added ppx_derivers as explicit dev of bspacks, as it's been added as dep of omp recently
  • Make sure bspacks uses the same version of menhir as the parser. I ran into the problem about StaticVersion mentioned above but it seems it happens when there are stale builds of the parser locally. I managed to solve it by cleaning build artifacts from parser and building everything again (so that both parser and bspacks use the same version).

I am blocked on one more error though, it seems the new build config for reason_parser.mly doesn't produce the ml file on build folder, so I get this:

File "src/reason-parser/reason_declarative_lexer.mll", line 70, characters 5-18:
Error: Unbound module Reason_parser

What'd be the change needed to produce a reason_parser.ml file from the menhir file?

@jchavarri
Copy link
Contributor

Managed to fix the menhir issue, there were more paths that had to be migrated from _build to _esy.

So both refmt binary and refmt js api seem to be building ok now 🎉 Fixed some issues with omp modules being generated by bspack like Migrate_parsetree__Ast_404 (picked the fix from #2495, thanks @ryyppy!)

Also, updated refmt js api to the latest breaking changes after reerror.

Same branch: https://github.com/jchavarri/reason/tree/joo

@jchavarri
Copy link
Contributor

@jaredly Added another small change so that the script gets bspack.ml from BS github repo: jaredly#3.

Some future tasks could be:

  • migration to 4.06 for bs7
  • publish refmt-js-api to npm (i think it's reason? very confusing...) directly from GH actions, whenever there's a new release or merge to master
  • maybe publish bspacked-refmt to npm with same version using GH actions as well, so it can be consumed from BuckleScript's esy.json that @ulrikstrid has been working on.

As far as I can tell though, this is ready to merge.

@jaredly
Copy link
Contributor Author

jaredly commented Dec 2, 2019

@jchavarri ok I added sandboxes, so now this script works with both 4.02 and 4.06! Very clean

@ulrikstrid
Copy link
Contributor

I opened this PR against bucklescript which should allow us to use bspack from upstream instead of vendoring it.

@jaredly
Copy link
Contributor Author

jaredly commented Dec 12, 2019

Ok @jordwalke @ulrikstrid @jchavarri I think this is good to go!

@ulrikstrid
Copy link
Contributor

What is stopping this from going in? Seems like something that would be nice since the community wants to upstream reason changes into bucklescript more frequently

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

Successfully merging this pull request may close these issues.

None yet

8 participants