rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

port ninja/config.py to nodejs script

Open bobzhang opened this issue 4 years ago • 10 comments

Our prebuilt ninja may not work on some exotic OSes, in this case ninja will be built from source, it has a dependency on Python which is unneeded. Since ReScript implies nodejs dependency by default, it may be worthwhile to port the script to node

bobzhang avatar Jun 13 '21 08:06 bobzhang

where is this script? it lives in ninja fork?

amiralies avatar Jun 13 '21 09:06 amiralies

yes, it lives in submodule, ninja/config.py

bobzhang avatar Jun 13 '21 09:06 bobzhang

I've came across the issue trying to use the node:14.17.0-alpine container

DZakh avatar Sep 18 '21 19:09 DZakh

I think the log with the actual error may be useful for the issue.

$ npm install rescript

> [email protected] postinstall /workspace/promo/node_modules/rescript
> node scripts/install.js

ninja not compatible? Error: Command failed: "/workspace/promo/node_modules/rescript/linux/ninja.exe" --version
building ninja
.clang-format
.gitignore
.travis.yml
COPYING
HACKING.md
README
RELEASING
appveyor.yml
bootstrap.py
configure.py
doc/
doc/README.md
doc/dblatex.xsl
doc/docbook.xsl
doc/doxygen.config
doc/manual.asciidoc
doc/style.css
misc/
misc/afl-fuzz-tokens/
misc/afl-fuzz-tokens/kw_build
misc/afl-fuzz-tokens/kw_default
misc/afl-fuzz-tokens/kw_include
misc/afl-fuzz-tokens/kw_pool
misc/afl-fuzz-tokens/kw_rule
misc/afl-fuzz-tokens/kw_subninja
misc/afl-fuzz-tokens/misc_a
misc/afl-fuzz-tokens/misc_b
misc/afl-fuzz-tokens/misc_colon
misc/afl-fuzz-tokens/misc_cont
misc/afl-fuzz-tokens/misc_dollar
misc/afl-fuzz-tokens/misc_eq
misc/afl-fuzz-tokens/misc_indent
misc/afl-fuzz-tokens/misc_pipe
misc/afl-fuzz-tokens/misc_pipepipe
misc/afl-fuzz-tokens/misc_space
misc/afl-fuzz/
misc/afl-fuzz/build.ninja
misc/bash-completion
misc/ci.py
misc/inherited-fds.ninja
misc/long-slow-build.ninja
misc/measure.py
misc/ninja-mode.el
misc/ninja.vim
misc/ninja_syntax.py
misc/ninja_syntax_test.py
misc/output_test.py
misc/packaging/
misc/packaging/ninja.spec
misc/packaging/rpmbuild.sh
misc/write_fake_manifests.py
misc/zsh-completion
snapshot.js
src/
src/browse.cc
src/browse.h
src/browse.py
src/build.cc
src/build.h
src/build_log.cc
src/build_log.h
src/build_log_perftest.cc
src/build_log_test.cc
src/build_test.cc
src/canon_perftest.cc
src/clean.cc
src/clean.h
src/clean_test.cc
src/clparser.cc
src/clparser.h
src/clparser_perftest.cc
src/clparser_test.cc
src/debug_flags.cc
src/debug_flags.h
src/depfile_parser.cc
src/depfile_parser.h
src/depfile_parser.in.cc
src/depfile_parser_perftest.cc
src/depfile_parser_test.cc
src/deps_log.cc
src/deps_log.h
src/deps_log_test.cc
src/disk_interface.cc
src/disk_interface.h
src/disk_interface_test.cc
src/dyndep.cc
src/dyndep.h
src/dyndep_parser.cc
src/dyndep_parser.h
src/dyndep_parser_test.cc
src/edit_distance.cc
src/edit_distance.h
src/edit_distance_test.cc
src/eval_env.cc
src/eval_env.h
src/exit_status.h
src/gen_doxygen_mainpage.sh
src/getopt.c
src/getopt.h
src/graph.cc
src/graph.h
src/graph_test.cc
src/graphviz.cc
src/graphviz.h
src/hash_collision_bench.cc
src/hash_map.h
src/includes_normalize-win32.cc
src/includes_normalize.h
src/includes_normalize_test.cc
src/inline.sh
src/lexer.cc
src/lexer.h
src/lexer.in.cc
src/lexer_test.cc
src/line_printer.cc
src/line_printer.h
src/manifest_parser.cc
src/manifest_parser.h
src/manifest_parser_perftest.cc
src/manifest_parser_test.cc
src/metrics.cc
src/metrics.h
src/minidump-win32.cc
src/msvc_helper-win32.cc
src/msvc_helper.h
src/msvc_helper_main-win32.cc
src/msvc_helper_test.cc
src/ninja.cc
src/ninja_test.cc
src/parser.cc
src/parser.h
src/state.cc
src/state.h
src/state_test.cc
src/string_piece.h
src/string_piece_util.cc
src/string_piece_util.h
src/string_piece_util_test.cc
src/subprocess-posix.cc
src/subprocess-win32.cc
src/subprocess.h
src/subprocess_test.cc
src/test.cc
src/test.h
src/timestamp.h
src/util.cc
src/util.h
src/util_test.cc
src/version.cc
src/version.h
src/win32port.h
No prebuilt Ninja, building Ninja now
env: can't execute 'python': No such file or directory
child_process.js:679
    throw err;
    ^

Error: Command failed: ./configure.py --bootstrap
    at checkExecSyncError (child_process.js:640:11)
    at Object.execSync (child_process.js:676:15)
    at build_ninja (/workspace/promo/node_modules/rescript/scripts/install.js:47:10)
    at provideNinja (/workspace/promo/node_modules/rescript/scripts/install.js:94:3)
    at Object.<anonymous> (/workspace/promo/node_modules/rescript/scripts/install.js:217:1)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  status: 127,
  signal: null,
  output: [ null, null, null ],
  pid: 31,
  stdout: null,
  stderr: null
}

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/node/.npm/_logs/2021-09-18T20_25_29_084Z-debug.log

DZakh avatar Sep 18 '21 20:09 DZakh

It looks like this connected with the issue https://github.com/rescript-lang/rescript-compiler/issues/3666

DZakh avatar Sep 18 '21 20:09 DZakh

It still requires g++ and make besides python, so migrating from python to node would be cool, but there'll still stay some dependencies that can't be omitted.

DZakh avatar Sep 18 '21 21:09 DZakh

In theory, we could make it only depends on g++, since it is one time build, make is not strictly required. I don't have a testing environment for alpine, contributions are welcome.

bobzhang avatar Sep 19 '21 08:09 bobzhang

FYI It started failing on GH Actions with ubuntu-latest & node@16: https://github.com/shakacode/rescript-logger/runs/5259633886?check_suite_focus=true

alex35mil avatar Feb 19 '22 16:02 alex35mil

Hmm it fails on ubuntu-18.04 as well.

alex35mil avatar Feb 19 '22 16:02 alex35mil

Oh lol, sorry for the noise. I forgot I run it in an alpine container for static linking.

alex35mil avatar Feb 19 '22 16:02 alex35mil

@alex35mil how DO I run it in an Alpine container? I'm getting this very problem.

tx46 avatar Jan 21 '23 08:01 tx46

@philiparvidsson I’m afk atm but here is the container: https://github.com/shakacode/rescript-logger/blob/13c2a37607add17a586edd216a4565bfb3c735a1/.github/workflows/ci.yml#L79

And it requires a small patch: https://github.com/shakacode/rescript-logger/blob/13c2a37607add17a586edd216a4565bfb3c735a1/.github/workflows/ci.yml#L86

alex35mil avatar Jan 21 '23 12:01 alex35mil

Not an issue anymore as we are not building ninja binaries on npm postinstall anymore. Instead, we are already providing binaries for all supported platforms as part of the rescript npm package, including statically linked Linux binaries for x64 and arm64.

cknitt avatar May 27 '23 19:05 cknitt