Error response:
$ npm install --save bs-platform
> [email protected] postinstall C:\Users\<user>\Projects\tmp\bs\node_modules\bs-platform
> ./scripts/postinstall.sh
'.' is not recognized as an internal or external command,
operable program or batch file.
npm WARN bs No description
npm WARN bs No repository field.
npm WARN bs No license field.
verbose stack Error: [email protected] postinstall: `./scripts/postinstall.sh`
verbose stack Exit status 1
verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:245:16)
verbose stack at emitTwo (events.js:106:13)
verbose stack at EventEmitter.emit (events.js:191:7)
verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14) 3438 verbose stack at emitTwo (events.js:106:13)
verbose stack at ChildProcess.emit (events.js:191:7)
verbose stack at maybeClose (internal/child_process.js:850:16)
verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
verbose pkgid [email protected]
verbose cwd C:\Users\<user>\Projects\tmp\bs
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "bs-platform"
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! [email protected] postinstall: `./scripts/postinstall.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script './scripts/postinstall.sh'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bs-platform package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./scripts/postinstall.sh
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bs-platform
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bs-platform
Same response whether from full cygwin, a mingw bash shell, command prompt, or powershell. Do have ocaml/opam installed and working.
And for note, in package.json changing the line of:
"postinstall": "./scripts/postinstall.sh"
To:
"postinstall": "bash ./scripts/postinstall.sh"
fixed it, probably 'sh' would work but I've not looked over postinstall.sh to ensure it is simple enough for sh, 'dash' might work too.
I.E. 'worked' as in it continued on and was able to compile,then to die on:
strip: unable to rename 'tmpheader.exe'; reason: Permission denied
stripmake[2]: *** [Makefile:50: target_camlheader] Error 1
: make[2]: *** Waiting for unfinished jobs....unable to rename '
tmpheader.exe'; reason: Permission denied
mv: cannot stat 'tmpheader.exe': No such file or directory
make[2]: *** [Makefile:50: camlheader_ur] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/<user>/Projects/tmp/bs/node_modules/bs-platform/ocaml_src/stdlib'
make[1]: *** [Makefile:192: coldstart] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/<user>/Projects/tmp/bs/node_modules/bs-platform/ocaml_src'
make: *** [Makefile:142: world.opt] Error 2
./scripts/postinstall.sh: line 40: cd: jscomp: No such file or directory
The first bit looks like a race condition, the file is still being committed to the drive but then is tried to be renamed, which cannot happen concurrently on ntfs like it can on ext3/ext4/etc...
hi, thanks for trying it on windows. It's very hard to build on windows, here
https://github.com/bloomberg/bucklescript/blob/master/scripts/postinstall.sh#L31
maybe you need change it to -j 1
we did manage to have a windows installer thanks to my colleague, are you familiar with packaging a binary file to npm, maybe on windows platform we can just provide a binary instead,
let me know if you are interested
I can try changing that when I get to work next (Win10 there, I only have linux at home and it works perfectly here). I'm not really knowledgeable with npm, at all, I'm mostly a C++/ocaml/rust back-end person and the node ecosystem is new and weird to me. ^.^
I can help build anything that you may need though if you wish, at least binaries built for windows should work decently on any other windows so it makes sense to include that in the distribution.
Tried again at work on Win10 in cygwin (where ocaml itself works fine, and with my 'bash' bit still in the file), got:
Log:
/* snip */
3424 silly gunzTarPerm extractEntry site/docsource/Semantic-differences-from-other-backends.adoc
3425 silly gunzTarPerm extractEntry site/docsource/Why-bucklescript-matters-for-Javascript-platform.adoc
3426 silly gunzTarPerm extractEntry site/docsource/Why_BuckleScript.adoc
3427 silly gunzTarPerm extractEntry site/process.js
3428 silly gentlyRm C:\Users\<user>\Projects\tmp\bs\node_modules\.staging\bs-platform-be7df614\node_modules is being purged
3429 verbose gentlyRm don't care about contents; nuking C:\Users\<user>\Projects\tmp\bs\node_modules\.staging\bs-platform-be7df614\node_modules
3430 silly doParallel preinstall 1
3431 silly preinstall [email protected] C:\Users\<user>\Projects\tmp\bs\node_modules\.staging\bs-platform-be7df614
3432 info lifecycle [email protected]~preinstall: [email protected]
3433 silly lifecycle [email protected]~preinstall: no script for preinstall, continuing
3434 silly doReverseSerial remove 0
3435 silly doSerial move 0
3436 silly doSerial finalize 1
3437 silly finalize C:\Users\<user>\Projects\tmp\bs\node_modules\bs-platform
3438 silly doSerial build 1
3439 silly build [email protected]
3440 info linkStuff [email protected]
3441 silly linkStuff [email protected] has C:\Users\<user>\Projects\tmp\bs\node_modules as its parent node_modules
3442 verbose linkBins [email protected]
3443 verbose link bins [ { bsc: './bin/bsc',
3443 verbose link bins bsppx: './bin/bsppx',
3443 verbose link bins bspack: './bin/bspack',
3443 verbose link bins ocaml: './bin/ocaml',
3443 verbose link bins ocamlc: './bin/ocamlc',
3443 verbose link bins 'ocamlc.opt': './bin/ocamlc.opt',
3443 verbose link bins ocamldep: './bin/ocamldep.opt',
3443 verbose link bins ocamllex: './bin/ocamllex.opt',
3443 verbose link bins ocamlobjinfo: './bin/ocamlobjinfo',
3443 verbose link bins 'ocamlopt.opt': './bin/ocamlopt',
3443 verbose link bins ocamlrun: './bin/ocamlrun',
3443 verbose link bins ocamlyacc: './bin/ocamlyacc' },
3443 verbose link bins 'C:\\Users\\<user>\\Projects\\tmp\\bs\\node_modules\\.bin',
3443 verbose link bins false ]
3444 verbose linkMans [email protected]
3445 silly doSerial global-link 0
3446 silly doParallel update-linked 0
3447 silly doSerial install 1
3448 silly install [email protected] C:\Users\<user>\Projects\tmp\bs\node_modules\.staging\bs-platform-be7df614
3449 info lifecycle [email protected]~install: [email protected]
3450 silly lifecycle [email protected]~install: no script for install, continuing
3451 silly doSerial postinstall 1
3452 silly postinstall [email protected] C:\Users\<user>\Projects\tmp\bs\node_modules\.staging\bs-platform-be7df614
3453 info lifecycle [email protected]~postinstall: [email protected]
3454 verbose lifecycle [email protected]~postinstall: unsafe-perm in lifecycle true
3455 verbose lifecycle [email protected]~postinstall: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\<user>\Projects\tmp\bs\node_modules\bs-platform\node_modules\.bin;C:\Users\<user>\Projects\tmp\bs\node_modules\.bin;C:\Program Files\nodejs;C:\Users\<user>\.opam\4.02.3+mingw64c\bin;C:\OCaml64\usr\x86_64-w64-mingw32\sys-root\mingw\bin;C:\OCaml64\usr\local\bin;C:\OCaml64\bin;C:\Program Files\ConEmu\ConEmu\Scripts;C:\Program Files\ConEmu;C:\Program Files\ConEmu\ConEmu;C:\Program Files\Docker\Docker\Resources\bin;C:\oracle-12\product\12.1.0\client_1\bin;C:\ProgramData\Oracle\Java\javapath;C:\oracle\product\11.2.0\client_1\bin;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files (x86)\Gow\bin;C:\Program Files\MiKTeX 2.9\miktex\bin\x64;C:\Program Files\erl7.3\bin;C:\Program Files\nodejs;C:\Program Files\erl8.0\bin;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Elixir\bin;C:\Users\<user>\.mix\escripts;C:\Program Files (x86)\PuTTY;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;C:\Users\<user>\AppData\Local\Programs\Python\Python35-32\Scripts;C:\Users\<user>\AppData\Local\Programs\Python\Python35-32;C:\Users\<user>\.cargo\bin;C:\Program Files (x86)\Elm Platform\0.17.1\bin;C:\Users\<user>\AppData\Local\atom\bin;C:\Users\<user>\AppData\Roaming\npm;C:\Program Files\Java\jdk1.8.0_92\bin
3456 verbose lifecycle [email protected]~postinstall: CWD: C:\Users\<user>\Projects\tmp\bs\node_modules\bs-platform
3457 silly lifecycle [email protected]~postinstall: Args: [ '/d /s /c', 'bash ./scripts/postinstall.sh' ]
3458 silly lifecycle [email protected]~postinstall: Returned: code: 1 signal: null
3459 info lifecycle [email protected]~postinstall: Failed to exec postinstall script
3460 verbose unlock done using C:\Users\<user>\AppData\Roaming\npm-cache\_locks\staging-113a3b1df821c8a0.lock for C:\Users\<user>\Projects\tmp\bs\node_modules\.staging
3461 silly rollbackFailedOptional Starting
3462 silly rollbackFailedOptional Finishing
3463 silly runTopLevelLifecycles Starting
3464 silly runTopLevelLifecycles Finishing
3465 silly install printInstalled
3466 warn bs No description
3467 warn bs No repository field.
3468 warn bs No license field.
3469 verbose stack Error: [email protected] postinstall: `bash ./scripts/postinstall.sh`
3469 verbose stack Exit status 1
3469 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:245:16)
3469 verbose stack at emitTwo (events.js:106:13)
3469 verbose stack at EventEmitter.emit (events.js:191:7)
3469 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
3469 verbose stack at emitTwo (events.js:106:13)
3469 verbose stack at ChildProcess.emit (events.js:191:7)
3469 verbose stack at maybeClose (internal/child_process.js:850:16)
3469 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
3470 verbose pkgid [email protected]
3471 verbose cwd C:\Users\<user>\Projects\tmp\bs
3472 error Windows_NT 10.0.10586
3473 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "bs-platform-1.0.1.tar"
3474 error node v6.2.0
3475 error npm v3.8.9
3476 error code ELIFECYCLE
3477 error [email protected] postinstall: `bash ./scripts/postinstall.sh`
3477 error Exit status 1
3478 error Failed at the [email protected] postinstall script 'bash ./scripts/postinstall.sh'.
3478 error Make sure you have the latest version of node.js and npm installed.
3478 error If you do, this is most likely a problem with the bs-platform package,
3478 error not with npm itself.
3478 error Tell the author that this fails on your system:
3478 error bash ./scripts/postinstall.sh
3478 error You can get information on how to open an issue for this project with:
3478 error npm bugs bs-platform
3478 error Or if that isn't available, you can get their info via:
3478 error npm owner ls bs-platform
3478 error There is likely additional logging output above.
3479 verbose exit [ 1, true ]
stdout/stderr:
Configuring for host x86_64-unknown-cygwin ...
Configuring for target x86_64-unknown-cygwin ...
Using compiler gcc.
The C compiler is ANSI-compliant.
Checking the sizes of integers and pointers...
[ERROR!] Since datatype sizes cannot be guessed when cross-compiling,
a hardcoded list is used but your architecture isn't known yet.
You need to determine the sizes yourself.
Please submit a bug report in order to expand the list.
./scripts/postinstall.sh: line 40: cd: jscomp: No such file or directory
npm WARN bs No description
npm WARN bs No repository field.
npm WARN bs No license field.
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "bs-platform-1.0.1.tar"
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! [email protected] postinstall: `bash ./scripts/postinstall.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'bash ./scripts/postinstall.sh'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bs-platform package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! bash ./scripts/postinstall.sh
If you need me to do anything just ask, I'm quite curious in bucklescript as an actual decent language to use in the browser. :-)
Honestly if the output javascript that is at the 'Try Bucklescript` site works as well as the base compiler (even if slower), that would be fantastic as a fall-back to put into brunch as a compiler.
EDIT: Eh, except opam, unsure how that could work with the system ocaml packages...
When trying to follow https://github.com/bloomberg/bucklescript/blob/master/site/docsource/Installation.adoc on this step I get this error:
$ pwd
/cygdrive/c/Users/<user>/Projects/tmp/bucklescript/ocaml
$ ./configure -prefix `pwd`
Configuring for host x86_64-unknown-cygwin ...
Configuring for target x86_64-unknown-cygwin ...
Using compiler gcc.
The C compiler is ANSI-compliant.
Checking the sizes of integers and pointers...
[ERROR!] Since datatype sizes cannot be guessed when cross-compiling,
a hardcoded list is used but your architecture isn't known yet.
You need to determine the sizes yourself.
Please submit a bug report in order to expand the list.
So this gets even more fun. ^.^
From asking around a bit it seems that the windows binary should be packaged with it directly (usually as separate npm package conditionally brought in if on Windows, can generate a 'WARN' but that is fine).
Although considering opam usage and so forth there needs to be a way to point it to a directory (brunch configuration for example could specify this) with the opam packages if base install, or could include a setup of opam where you define packages that are needed (again in something like brunch for the user) and it downloads those as needed to make a completely self-sufficient setup.
Hi @OvermindDL1 just let you know, windows support is our top priority, we are actively working on it
Hi @OvermindDL1 just let you know, windows support is our top priority, we are actively working on it
Looking forward to it! If this becomes as easy to install as any other npm package (say like npm install --save-dev elm-brunch), then just configure it (either using global opam or perhaps a project-specific opam), then just with a decent vdom library for bucklescript and a good pattern (similar to how Elm's works, I'd might even make this part) this could very quickly become the go-to language for the functional'ish side of the react/elm/etc crowd. As an ocaml user where Elm consistently feels foreign and incomplete, this would be my dream for being able to do front-end work.
If there is anything that I can assist with please state. We will be using Windows at work for a long while longer (though hopefully the next few years will see the main servers replaced with Illumos or linux) so I have it around. I would love to convert the others here and push out docs publicly as well. :-)
All I'd need next is an OCaml -> EVM/BEAM compiler for the back-end. ^.^
Bit more work, changed up some of the ocaml build system and I get this as a result now:
$ ./configure -prefix `pwd`
Configuring for host x86_64-unknown-cygwin ...
Configuring for target x86_64-unknown-cygwin ...
Using compiler gcc.
runtest: gcc -O -o tst ansi.c
The C compiler is ANSI-compliant.
Checking the sizes of integers and pointers...
runtest: gcc -O -o tst sizes.c
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot open output file tst.exe: Permission denied
collect2: error: ld returned 1 exit status
[ERROR!] Since datatype sizes cannot be guessed when cross-compiling,
a hardcoded list is used but your architecture isn't known yet.
You need to determine the sizes yourself.
Please submit a bug report in order to expand the list.
The file tst.exe exists, but it seems to be trying to run ld on it before the file write is complete and the handle is released. I'm not experiencing this if I run the commands manually instead of via script. I really want to go back to linux... >.>
Hi @OvermindDL1 , we will ship a binary as you said, so you don't need bother cygwin issues
@OvermindDL1 share some good news with you, I get a native windows compiler working now, need a couple of days to polish and test
hi @OvermindDL1 https://github.com/bloomberg/bucklescript/pull/760 I tested it on my windows, it works fine, would you give it a try (assuming you already have ocaml 4.02.3 cygwin version installed)
Oh hi, I did not even notice that branch. :-)
Yep the cygwin variant of ocaml, clone'ing bucklescript, checking it out, and compiling (via following the instructions here, ocaml built successfully (first time!), however, when at the make world step in the above instructions it runs over the ocaml project again. I'm guessing there was a forgot cd .. command or so, so did that, tried make world, however that failed due to no rule, and apparently no Makefile here at all in the root bucklescript directory, searching for Makefile in the tree and I found one in jscomp itself, so cd jscomp, then make world, got this:
$ make world
Making compiler
make releasebuild
make[1]: Entering directory '/cygdrive/c/Users/<user>/Projects/tmp/bucklescript/jscomp'
ocamlopt.opt -w -a -I bin unix.cmxa bin/bspack.mli bin/bspack.ml -o bin/bspack
>> Fatal error: Cmmgen.transl_prim_2
Fatal error: exception Misc.Fatal_error
make[1]: *** [Makefile:35: bin/bspack] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/<user>/Projects/tmp/bucklescript/jscomp'
make: *** [Makefile:98: world] Error 2
And this immediately jumped outside my realm of knowledge with that Fatal error.
Significantly further than before. :-)
Oh and yes, the base ocaml install in the cygwin area is:
$ ocaml -version
The OCaml toplevel, version 4.02.3
Just for fun I also tried building reason in the ./reason subdirectory, it needed the opam package 'BetterErrors' installed, which requires the opam package 'ANSITerminal', which fails installing via opam with:
=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] The installation of ANSITerminal failed at "ocaml setup.ml -install".
Processing 2/2: [ANSITerminal: ocamlfind remove]
#=== ERROR while installing ANSITerminal.0.7 ==================================#
# opam-version 1.3.0~dev (98188f141dbeb429258f2b2c00f6240d0af02b84)
# os win32
# command ocaml setup.ml -install
# path C:/Users/<user>/.opam/4.02.3+mingw64c/build/ANSITerminal.0.7
# exit-code 1
# env-file C:/Users/<user>/.opam/4.02.3+mingw64c/build/ANSITerminal.0.7\ANSITerminal-404-1872ec.env
# stdout-file C:/Users/<user>/.opam/4.02.3+mingw64c/build/ANSITerminal.0.7\ANSITerminal-404-1872ec.out
# stderr-file C:/Users/<user>/.opam/4.02.3+mingw64c/build/ANSITerminal.0.7\ANSITerminal-404-1872ec.err
### stderr ###
# [...]
# Installed C:\Users\<user>\.opam\4.02.3+mingw64c\lib\ANSITerminal\ANSITerminal.cmxs
# Installed C:\Users\<user>\.opam\4.02.3+mingw64c\lib\ANSITerminal\ANSITerminal.cmi
# Installed C:\Users\<user>\.opam\4.02.3+mingw64c\lib\ANSITerminal\ANSITerminal.cmti
# Installed C:\Users\<user>\.opam\4.02.3+mingw64c\lib\ANSITerminal\ANSITerminal.cmt
# Installed C:\Users\<user>\.opam\4.02.3+mingw64c\lib\ANSITerminal\ANSITerminal.annot
# Installed C:\Users\<user>\.opam\4.02.3+mingw64c\lib\ANSITerminal\ANSITerminal_common.cmx
# Installed C:\Users\<user>\.opam\4.02.3+mingw64c\lib\ANSITerminal\ANSITerminal.cmx
# Installed C:\Users\<user>\.opam\4.02.3+mingw64c\lib\ANSITerminal\META
# Installed C:\Users\<user>\.opam\4.02.3+mingw64c\lib\stublibs\dllANSITerminal_stubs.dll
# Installed C:\Users\<user>\.opam\4.02.3+mingw64c\lib\stublibs\dllANSITerminal_stubs.dll.owner
# ocamlfind: [WARNING] You have installed DLLs but the directory C:\Users\<user>\.opam\4.02.3+mingw64c\lib\stublibs is not mentioned in ld.conf
# E: Field 'datarootdir' is not set: Cannot handle os_type Win32 filename concat
hi @OvermindDL1 assuming you have ocamlc.opt in PATH
try this
git clone github/bucklescript
mkdir node
cd node
npm install ../bucklescript
you don't need build ocaml compiler if you already have ocaml installed, we improved it that BuckleScript no longer depends on patches to the original compiler
$ where ocamlc.opt
C:\Users\<user>\Projects\tmp\bucklescript\ocaml\bin\ocamlc.opt.exe
C:\Users\<user>\.opam\4.02.3+mingw64c\bin\ocamlc.opt.exe
$ mkdir node
<user>@<user> ~/Projects/tmp/bucklescript
$ cd node
<user>@<user> ~/Projects/tmp/bucklescript/node
$ npm install ../bucklescript
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "../bucklescript"
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! code ENOSELF
npm ERR! Refusing to install bs-platform as a dependency of itself
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\<user>\Projects\tmp\bucklescript\node\npm-debug.log
$ # Err...
$ npm install ..
npm WARN deprecated [email protected]: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated [email protected]: to-iso-string has been deprecated, use @segment/to-iso-string instead.
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
> [email protected] postinstall C:\Users\<user>\Projects\tmp\bucklescript
> node scripts/config.js
Working dir C:\Users\<user>\Projects\tmp\bucklescript
config_output:
version: 4.02.3+dev1-2016-05-24
standard_library_default: /cygdrive/c/Users/<user>/Projects/tmp/bucklescript/ocaml/lib/ocaml
standard_library: C:/Users/<user>/.opam/4.02.3+mingw64c/lib/ocaml
standard_runtime: /cygdrive/c/Users/<user>/Projects/tmp/bucklescript/ocaml/bin/ocamlrun
ccomp_type: cc
bytecomp_c_compiler: gcc -O -fno-defer-pop -Wall -U_WIN32 -D_FILE_OFFSET_BITS=64 -D_REENTRANT -O
bytecomp_c_libraries: -lm -lpthread
native_c_compiler: gcc -O -Wall -U_WIN32 -D_FILE_OFFSET_BITS=64 -D_REENTRANT
native_c_libraries: -lm
native_pack_linker: ld -r -o
ranlib: ranlib
cc_profile: -pg
architecture: amd64
model: default
system: cygwin
asm: as
asm_cfi_supported: true
with_frame_pointers: false
ext_obj: .o
ext_asm: .s
ext_lib: .a
ext_dll: .so
os_type: Cygwin
default_executable_name: camlprog.exe
systhread_supported: true
host: x86_64-unknown-cygwin
target: x86_64-unknown-cygwin
exec_magic_number: Caml1999X011
cmi_magic_number: Caml1999I017
cmo_magic_number: Caml1999O010
cma_magic_number: Caml1999A011
cmx_magic_number: Caml1999Y014
cmxa_magic_number: Caml1999Z013
ast_impl_magic_number: Caml1999M016
ast_intf_magic_number: Caml1999N015
cmxs_magic_number: Caml2007D002
cmt_magic_number: Caml2012T004
keyvalues [ [ 'version', '4.02.3+dev1-2016-05-24' ],
[ 'standard_library_default',
'/cygdrive/c/Users/<user>/Projects/tmp/bucklescript/ocaml/lib/ocaml' ],
[ 'standard_library',
'C:/Users/<user>/.opam/4.02.3+mingw64c/lib/ocaml' ],
[ 'standard_runtime',
'/cygdrive/c/Users/<user>/Projects/tmp/bucklescript/ocaml/bin/ocamlrun' ],
[ 'ccomp_type', 'cc' ],
[ 'bytecomp_c_compiler',
'gcc -O -fno-defer-pop -Wall -U_WIN32 -D_FILE_OFFSET_BITS=64 -D_REENTRANT -O' ],
[ 'bytecomp_c_libraries', '-lm -lpthread' ],
[ 'native_c_compiler',
'gcc -O -Wall -U_WIN32 -D_FILE_OFFSET_BITS=64 -D_REENTRANT' ],
[ 'native_c_libraries', '-lm' ],
[ 'native_pack_linker', 'ld -r -o' ],
[ 'ranlib', 'ranlib' ],
[ 'cc_profile', '-pg' ],
[ 'architecture', 'amd64' ],
[ 'model', 'default' ],
[ 'system', 'cygwin' ],
[ 'asm', 'as' ],
[ 'asm_cfi_supported', 'true' ],
[ 'with_frame_pointers', 'false' ],
[ 'ext_obj', '.o' ],
[ 'ext_asm', '.s' ],
[ 'ext_lib', '.a' ],
[ 'ext_dll', '.so' ],
[ 'os_type', 'Cygwin' ],
[ 'default_executable_name', 'camlprog.exe' ],
[ 'systhread_supported', 'true' ],
[ 'host', 'x86_64-unknown-cygwin' ],
[ 'target', 'x86_64-unknown-cygwin' ],
[ 'exec_magic_number', 'Caml1999X011' ],
[ 'cmi_magic_number', 'Caml1999I017' ],
[ 'cmo_magic_number', 'Caml1999O010' ],
[ 'cma_magic_number', 'Caml1999A011' ],
[ 'cmx_magic_number', 'Caml1999Y014' ],
[ 'cmxa_magic_number', 'Caml1999Z013' ],
[ 'ast_impl_magic_number', 'Caml1999M016' ],
[ 'ast_intf_magic_number', 'Caml1999N015' ],
[ 'cmxs_magic_number', 'Caml2007D002' ],
[ 'cmt_magic_number', 'Caml2012T004' ] ]
config_map { version: '4.02.3+dev1-2016-05-24',
standard_library_default: '/cygdrive/c/Users/<user>/Projects/tmp/bucklescript/ocaml/lib/ocaml',
standard_library: 'C:/Users/<user>/.opam/4.02.3+mingw64c/lib/ocaml',
standard_runtime: '/cygdrive/c/Users/<user>/Projects/tmp/bucklescript/ocaml/bin/ocamlrun',
ccomp_type: 'cc',
bytecomp_c_compiler: 'gcc -O -fno-defer-pop -Wall -U_WIN32 -D_FILE_OFFSET_BITS=64 -D_REENTRANT -O',
bytecomp_c_libraries: '-lm -lpthread',
native_c_compiler: 'gcc -O -Wall -U_WIN32 -D_FILE_OFFSET_BITS=64 -D_REENTRANT',
native_c_libraries: '-lm',
native_pack_linker: 'ld -r -o',
ranlib: 'ranlib',
cc_profile: '-pg',
architecture: 'amd64',
model: 'default',
system: 'cygwin',
asm: 'as',
asm_cfi_supported: 'true',
with_frame_pointers: 'false',
ext_obj: '.o',
ext_asm: '.s',
ext_lib: '.a',
ext_dll: '.so',
os_type: 'Cygwin',
default_executable_name: 'camlprog.exe',
systhread_supported: 'true',
host: 'x86_64-unknown-cygwin',
target: 'x86_64-unknown-cygwin',
exec_magic_number: 'Caml1999X011',
cmi_magic_number: 'Caml1999I017',
cmo_magic_number: 'Caml1999O010',
cma_magic_number: 'Caml1999A011',
cmx_magic_number: 'Caml1999Y014',
cmxa_magic_number: 'Caml1999Z013',
ast_impl_magic_number: 'Caml1999M016',
ast_intf_magic_number: 'Caml1999N015',
cmxs_magic_number: 'Caml2007D002',
cmt_magic_number: 'Caml2012T004' }
Build the compiler and runtime ..
Making compiler
ocamlopt.opt.exe -w -a -I bin ./bin/whole_compiler_config.ml -open Whole_compiler_config ./bin/whole_compiler.mli ./bin/whole_compiler.ml -o bin/bsc.exe
>> Fatal error: Cmmgen.transl_prim_2
Fatal error: exception Misc.Fatal_error
Called from file "arg.ml", line 214, characters 2-73
make: *** [Makefile:103: windows-world] Error 2
child_process.js:518
throw err;
^
Error: Command failed: make windows-world
at checkExecSyncError (child_process.js:475:13)
at Object.execSync (child_process.js:515:13)
at Object.<anonymous> (C:\Users\<user>\Projects\tmp\bucklescript\scripts\config.js:116:19)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN [email protected] license should be a valid SPDX license expression
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" ".."
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! [email protected] postinstall: `node scripts/config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node scripts/config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bs-platform package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bs-platform
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bs-platform
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\<user>\Projects\tmp\bucklescript\node\npm-debug.log
npm is installed system-wide, not in cygwin (nor do I find it in the cygwin installer).
you don't need build ocaml compiler if you already have ocaml installed, we improved it that BuckleScript no longer depends on patches to the original compiler
Oh, very awesome, and with that let me try node install .. via the standard ocaml compiler instead of the custom built one, and success! I have a bsc.exe, tied to cygwin currently, but regardless, success!
$ ls ../bin
bsc.exe bspack.exe bsppx.exe
@OvermindDL1 so with the standard ocaml compiler, it works? btw, the node directory should be outside bucklescript like below:
|-- bucklescript
`-- node
@OvermindDL1 so with the standard ocaml compiler, it works?
Yep.
btw, the node directory should be outside bucklescript like below:
And yep.
Looking good though, initial tests show it works, and I see lots of output files in lib of the standard set, although to save space/sanity have you thought about a UMD header for the javascript as it would support vanilla inclusion, amd modules, commonjs modules, and a few other styles all at once without needing to make a variety of output directories and output types for the generated javascript standard library? :-)
Oh, for note, if I do npm install ../bucklescript from a directory adjacent to the bucklscript windows clone I get:
<user>@<user> ~/Projects/tmp/node
$ npm install ../bucklescript
npm ERR! addLocal Could not install C:\Users\<user>\Projects\bucklescript
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "../bucklescript"
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! path C:\Users\<user>\Projects\bucklescript
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\<user>\Projects\bucklescript'
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\<user>\Projects\bucklescript'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
<user>@<user> ~/Projects/tmp/node
$ pwd
/cygdrive/c/Users/<user>/Projects/tmp/node
And yet if I make a directory 'inside' the bucklescript clone then run npm install .. then it runs no problem.
I've no clue why it is going 'higher' up in a directory then where it should based on my typing of ../bucklescript, something odd in the build script perhaps? Or npm...
Oh now this is fascinating:
Bucklescript is at: ~/tmp/bucklescript
I am at: ~/tmp/bs
It fails with npm install ../bucklescript because it says it cannot find bucklescript at ~/bucklescript.
I _succeeds_ with: npm install ./bucklescript, note the single ., not ...
And if I run npm install when I am just sitting in the bucklescript directory it works fine too.
All with the stock compiler.
EDIT: Assuming it is using the ocaml compiler from the path:
$ whereis ocamlopt.opt
ocamlopt: /cygdrive/c/Users/<user>/.opam/4.02.3+mingw64c/bin/ocamlopt.exe
Cool, we will provide pre-built binaries so users don't need Cygwin , are you familiar with creating npm binaries?
Honestly, not a clue, the whole Javascript ecosystem is still an odd thing to me (I come from C++/Erlang/Rust/Etc... areas primarily). If you need me to do something I can with instructions though. :-)
Thanks for the offer, I will do some research
one pain point to distribute a stand alone executable is the relative path to stdlib files, mostly for cmi. we can backport https://github.com/ocaml/ocaml/pull/706 and embed cmis into a single binary, then it would solve the problem.
Otherwise we have to set up an env variable to tell where is OCAMLLIB
An environment variable is not too odd a thing to add so it could be a 'for now' thing. Is there no way to use a relative location either?
I've written a bucklescript-brunch project, it works but I want to flesh it out with options as it is very low level right now (but hey, as I hit save in my editor everything gets re-compiled immediately and instantly, so that is quite nice even as-is), and as I am unable to find a Gitter.im or so chat I'm wondering if I could ask a few questions?
-bs-main and -bs-files (I know these ones, more curious about the rest of the -bs-* options).-I <dir> to other OCaml files, will these compile to javascript in the same output directory as the rest?hi @OvermindDL1 , we will create a forum so that we can discuss questions there (cc @kpfleming )
To answer your questions:
- Is there a location that describes in detail the command line parameters to bsc such as
-bs-mainand-bs-files(I know these ones, more curious about the rest of the-bs-*options).
Yes, checkout docs here: http://bloomberg.github.io/bucklescript/Manual.html#_extended_compiler_options
- What should be preferred, giving a list of 'main entry' files, or is it safe to compile each file in 'isolation' (brunch works best this way as it feeds me files as they are changed/updated/etc...).
Yes, it supports separate compilation, I use a makefile: https://github.com/bloomberg/bucklescript/blob/master/jscomp/test/Makefile
It is quite easy to adapt OMake for bucklescript (OMake also has a watch mode), are you interested in help here? (OMake works on windows)
rebel seems provide first class support for Buckle too.
- Is there a way to set the 'base' directory that the file packages are looked up via without needing to set the cwd?
Checkout the extra -bs flags
- I would love, I mean so very much love if there were a way to compile files one-at-a-time and get back the javascript directly so I could feed it up the compiler chain, if not is not a good way to handle it then is there a way to put intermediate files (*.cmi and *.cmj) into an intermediate directory instead of putting them in the same directories as the source?
Yes, checkout -o, -bs-packge-output you can put cmi cmj and js in different directory
- Is it documented anywhere what the possible compiling styles are? Such as the above of is it best to compile based on a set of 'main points' or is it feasible to handle individual files well?
Currently I use Makefile, which works perfect for a single directory, but I think we should move it to OMake or Rebel for large scale projects
- I've not tried yet, but specifying include directories via
-I <dir>to other OCaml files, will these compile to javascript in the same output directory as the rest?
checkout -bs-package-output
I may not understand your questions clearly, feel free to make a more concrete question, thanks
hi @OvermindDL1 , we will create a forum so that we can discuss questions there (cc @kpfleming )
Looking forward!
Yes, checkout docs here: http://bloomberg.github.io/bucklescript/Manual.html#_extended_compiler_options
Ahh, how did I miss that, I have about 10 tabs of that manual page up... >.>
Yes, it supports separate compilation, I use a makefile: https://github.com/bloomberg/bucklescript/blob/master/jscomp/test/Makefile
It is quite easy to adapt OMake for bucklescript (OMake also has a watch mode), are you interested in help here? (OMake works on windows)
Not heard of omake before, and their google'd homepage of http://omake.metaprl.org/ is not responding at the moment... >.>
Let me describe what I am trying to do right quick. :-)
compile(data, inFile, callback) callback. data holds system info, do not care much about it. inFile is a string that is the relative path from the project root to the file that has been 'changed' (this function gets called with every file on first-build, only changed files after that unless cleaned or forced), and callback is an ES6 style promise handler that you call with either callback(null, "compiled output") or callback(error, "Usually blank here, unless some output is still valid") based on success or failure. For example, compiling the file "src/main_entry.ml" gets passed into my brunch plugin, which trims off the early parts of the path until it gets to what the user defines as their root directory for bucklescript, then calls the bsc compiler with the additional arguments the user specified in their brunch config file, which compiles the ml file to the output javascript directory, which then brunch sees and reprocesses into the final file(s). However this ends up making a "src/main_entry.ml" javascript module, which is entirely empty, and a "js/main_entry.js" module, which is where the javascript lives.getDependencies(file) where I can return an array of file paths that this file depends on, that way I have it properly compile everything that is required instead of needing to update one at a time?-bs-eval might dump the javascript to the output based on the manual, however when I try it, it states bsc: unknown option '-bs-eval'. and I do not see it in the -help output of the actual bsc compiler.rebel seems provide first class support for Buckle too.
I've actually been looking at including reason support as well. Do you think it would be best to skip ocaml support via bsc directly and just support reason instead? I've not used reason before and the fat arrows rather annoy me for some reason over the thin arrows... >.>
And it looks like rebel is not wanting to install (Windows issues again maybe?) so that is out for now.
I may be jumping around a bit in my questions, juggling a dozen things at once so I do apologize. :-)
-bs-eval is only available in latest Bucklescript, I will merge this PR soon, so you will get that on Windows too, what's brunch, is there a link?
https://github.com/ocaml-omake/omake
We will work on omake to provide build system support for Windows, contributions are appreciated
Brunch is an npm/bower driven build system, very simple, powerful, and entirely asynchronous, thus very fast. Two main reasons I use it for the front-end compilation with a few other side reasons:
The optimal way that a brunch plugin would compile something to javascript via its 'javascript' path is:
.ml and .mli files listened to).lint(data, path, callback) called on it, the data is the string of the file contents and path is the path to the file, this function should only returns a true or false based on whether the content looks valid, either by running it through the parser to verify or just returning true without doing anything, also a good place to spit out stylistic warnings. If this function does not exist in the plugin then true is implicit.getDependencies(data, path, callback) called on it, data and path are the same as what was passed into lint, this returns an array of strings, the strings are relative paths from the project root directory to each file that needs to be compiled before this one and all of those will have their pipeline run through before this one continues. If not specified then it acts like an empty array is returned.compile(dataInfo, callback) called on it along with each other plugin that processes the same file types, dataInfo.data here is the possibly processed source from another plugin that handles the same extension as it is piped from one to another (used for things like processing ES7 to ES6 to ES5 javascript, or Flow to javascript, or typescript to javascript, dataInfo.path is the filepath of the original file, this will be the original source even if something else processed over the source and returned new content in the 'data', so you should not really use this (but I am currently), and dataInfo.map is the javascript sourcemap generated thus far. Plugins are supposed to process over the dataInfo.data, although I've not found a way to direct stdin to bsc yet so I just have it process the file (unlikely something else would pre-process ml/mli files anyway).A general plugin for something like a new language that compiles to javascript would be:
'use strict';
var Bucklescript = require('bucklescript');
class BucklescriptBrunchPlugin {
constructor(config) {
this.config = config && config.plugins && config.plugins.bucklescriptBrunch;
this.bucklescript = new Bucklescript();
this.bucklescript.setOptions(blah);
}
getDependencies(data, path, callback) {
this.bucklescript.getDependencies(data, path,
(files) => callback(null, files)
);
}
compile(filedata, callback) {
this.bucklescript.compileStringToJavascript(filedata.data, filedata.path,
(result) => {
if(result.error) callback(error, "");
else callback(null, result.javascript);
}
)
}
Assuming the dependency lookup and compilation steps themselves can be done asynchronously, such as by calling an external process and indeed this is how languages such as babel, react/jsx, typescript, and others are implemented as their compilers are either in javascript or have a javascript module that handles a native file interactions asynchronously. :-)
Of course it can get more complex than the above since you can expose all kinds of configurations and such, but that is the basics. I've been trying to figure out how to get dependencies and how to get the output javascript via stdout from bsc currently. I hope that showing how it works demonstrates what I would optimally try to achieve. :-)
Secondarily, if the optimal method is not feasible, and what I am doing currently, is just recompiling all ml/mli files in the project in their entirety anytime any of them change, that ensures that I at least have no dependency issues, but seems potentially overkill especially for large projects.
I went ahead and setup a temp directory for the files to be output for now, I just read them back in (all simultaneously and asynchronously at least). Testing my 4-ocaml file test project through bsc with the output javascript being read back in, given to brunch, combined together into a single file with all the other javascript (mostly just the module system code and the live-reloader code since I am in testing) where it compiles those 4 files, scans them to determine what they are requireing in turn, includes those from the node_modules directory (I.E., grabbed it looks like about 40 JS files from bs-platform), including all those, and saving it into an app.js and app.css took a total from a fresh build of 379ms, on a system without a fast filesystem. Bit round-about method of doing it but it works well, and from javascript I can just import {main_entry} from "src/main_entry.ml"; and it is working beautifully. :-)
I.E., my bucklescript brunch compiler plugin is a huge hack of writing and reading multiple files, but it is fast'ish since it is done in parallel but importing is natural and expected now between javascript and ocaml. :-)
I'll try to clean up my hackplugin and publish it to npm for others to play with. Currently you have to specify where bsc is, though I just keep it on my global path for now, which it tries to detect and use by default if not otherwise configured, though once it successfully comes from bs-platform I can default to that location and make my plugin optionally depend on it then to make it super simple for others to include and use it. :-)
Dependency scanning is very broken right now though since I am handling it on a file-by-file basis now, so one file that depends on the others causes a compile error since I've not built the dependency listing yet... I really hope there is a way to get that information out of bsc?
@OvermindDL1
ocamldep -ppx bsppx -modules YouFile.ml
We will provide such support in bsc too
Ahh so that is how it works! Awesome, that'd fix my last race condition then, I'll try to add it later. :-)
If you are curious how the brunch plugin works from the user-side, I put a little example together at: https://elixirforum.com/t/bucklescript/1579/24?u=overminddl1
I will close this issue, feel free to re-open it if you find new issues