Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Fix build failing when executing run watch on a clean build. #1395

Merged
merged 4 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
with a browser of your choice.
- [JS visualizations have consistent gestures with the IDE][1291]. Panning and
zooming now works just as expected on trackpad and mouse.
- [Running `watch` command works on first try.][1395]. Running the build command
`run watch` would fail if it was run as the first command on a clean
repository. This now works.
- [The `inputType` field of visualizations is actually taken into consideration]
[1384]. The visualization chooser shows entries accepting the node's output's
type only.
Expand Down Expand Up @@ -127,6 +130,7 @@ you can find their release notes
[1341]: https://github.com/enso-org/ide/pull/1341
[1348]: https://github.com/enso-org/ide/pull/1348
[1353]: https://github.com/enso-org/ide/pull/1353
[1395]: https://github.com/enso-org/ide/pull/1395
[1363]: https://github.com/enso-org/ide/pull/1363
[1384]: https://github.com/enso-org/ide/pull/1384
[1385]: https://github.com/enso-org/ide/pull/1385
Expand Down
76 changes: 48 additions & 28 deletions build/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,33 +262,48 @@ commands['toml-fmt'].rust = async function() {

commands.watch = command(`Start a file-watch utility and run interactive mode`)
commands.watch.options = Object.assign({},commands.build.options)
commands.watch.parallel = true
commands.watch.rust = async function(argv) {
let build_args = []
if (argv.crate !== undefined) {
build_args.push(`--crate=${argv.crate}`)
}
commands.watch.parallel = false
commands.watch.common = async function(argv) {
argv.dev = true

// Init JS build and project manager.

await installJsDeps()
if (argv.backend !== 'false') {
build_project_manager().then(run_project_manager)
await build_project_manager().then(run_project_manager)
}

build_args = build_args.join(' ')
let target =
'"' +
`node ${paths.script.main} build --skip-version-validation --no-js --dev ${build_args} -- ` +
cargoArgs.join(' ') +
'"'
let args = ['watch', '-s', `${target}`]
// Run build processes.

await cmd.with_cwd(paths.rust.root, async () => {
await cmd.run('cargo',args)
return commands.build.rust(argv);
})
}

commands.watch.js = async function() {
await installJsDeps()
await cmd.with_cwd(paths.js.root, async () => {
await run('npm',['run','watch'])
return commands.build.js(argv)
})

// Run watch processes.

const rust_process = cmd.with_cwd(paths.rust.root, async () => {
let build_args = []
if (argv.crate !== undefined) {
build_args.push(`--crate=${argv.crate}`)
}
build_args = build_args.join(' ')
const target =
'"' +
`node ${paths.script.main} build --skip-version-validation --no-js --dev ${build_args} -- ` +
cargoArgs.join(' ') +
'"'
let args = ['watch', '-s', `${target}`]
return cmd.run('cargo',args)
})
const js_process = cmd.with_cwd(paths.js.root, async () => {
return run('npm',['run','watch']);
})

await rust_process
await js_process
}


Expand Down Expand Up @@ -518,18 +533,23 @@ async function runCommand(command,argv) {
cargoArgs = cargoArgs.slice(0,index)
}
let runner = async function () {
let do_rust = argv.rust && config.rust
let do_js = argv.js && config.js
let rustCmd = () => cmd.with_cwd(paths.rust.root, async () => await config.rust(argv))
let jsCmd = () => cmd.with_cwd(paths.js.root , async () => await config.js(argv))
let do_common = config.common
let do_rust = argv.rust && config.rust
let do_js = argv.js && config.js

let commonCmd = () => cmd.with_cwd(paths.root, async () => await config.common(argv))
let rustCmd = () => cmd.with_cwd(paths.rust.root, async () => await config.rust(argv))
let jsCmd = () => cmd.with_cwd(paths.js.root , async () => await config.js(argv))
if(config.parallel) {
let promises = []
if (do_rust) { promises.push(rustCmd()) }
if (do_js) { promises.push(jsCmd()) }
if (do_common ) { promises.push(commonCmd()) }
if (do_rust) { promises.push(rustCmd()) }
if (do_js) { promises.push(jsCmd()) }
await Promise.all(promises)
} else {
if (do_rust) { await rustCmd() }
if (do_js) { await jsCmd() }
if (do_common) { await commonCmd() }
if (do_rust) { await rustCmd() }
if (do_js) { await jsCmd() }
}
}
cmd.section(command)
Expand Down