Skip to content

Conversation

genotrance
Copy link
Contributor

Fixes #802 - moved compile script into the nimcache directory - makes most sense since the idea is to take this nimcache directory onto the target machine to build so having the script together with the code makes sense. Also easy since the .c file paths don't need any adjustments in the generated script.

Fixes #803 - copies nimbase.h into the nimcache directory since it is required for build on the target machine.

Fixes #3775 - --genscript means noAbsolutePaths() so compile commands all failed due to bad paths. But there's no reason to compile anything on this machine, so --genscript should imply --compileOnly.

@Araq
Copy link
Member

Araq commented Apr 23, 2018

Very nice, but it needs a test case to keep this feature from bit-rotting.

@genotrance
Copy link
Contributor Author

Added a new test category for --genscript as discussed on IRC. It runs on Windows and Linux.

script &= ".bat"

when defined(linux):
cmd = "bash -c \"" & cmd & "./$#\""
Copy link
Contributor

Choose a reason for hiding this comment

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

And if bash not installed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bash is available on Travis so test passes. Do we need to change this to "sh -c" instead? Do we run full tests on other systems that don't have bash?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to change this to "sh -c" instead?

IMO, it would be better.

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've changed it to sh, makes sense.

doc/advopt.txt Outdated
--noMain do not generate a main procedure
--genScript generate a compile script (in the 'nimcache'
subdirectory named 'compile_$$project$$scriptext')
subdirectory named 'compile_$project$scriptext'),
Copy link
Contributor

Choose a reason for hiding this comment

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

this line causes the build to fail. You need to keep the doubled $$

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

cmd = "sh -c \"" & cmd & "./$#\""
script &= ".sh"

setFilePermissions(flagsDir / "nimcache" / script,
Copy link
Member

Choose a reason for hiding this comment

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

This is not required.


var build = ""
var run = ""
var cmd = "cd " & flagsDir / "nimcache" & " && "
Copy link
Member

Choose a reason for hiding this comment

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

Don't use && and string munging. Call execShellCmd once or twice instead.


# Build
var (outp, errC) = execCmdEx(build)
r.total += 1
Copy link
Member

Choose a reason for hiding this comment

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

There should be procs for this, don't mess manually with r.total and r.passed here.

@genotrance
Copy link
Contributor Author

Per feeback from @Araq, I've improved the testing of --genscript. This includes adding a new testExec() proc in testament to run executables and shell scripts as normal test cases. It is also now clear in the logs which test was run and with what parameters.

PASS: tgenscript C --genscript                                     (9.35208607 secs)
PASS: tgenscript C sh -c "cd nimcache/tests/flags/tgenscript_7a9eea86db4a06cfbc3b096715a16af8 && sh compile_tgenscript.sh" (13.59303904 secs)
PASS: tgenscript C nimcache/tests/flags/tgenscript_7a9eea86db4a06cfbc3b096715a16af8/tgenscript (0.27823400 secs)

if exitCode != 0: given.err = reExitCodesDiffer
if given.err == reSuccess: inc(r.passed)

proc testExec(r: var TResults, test: TTest) =
Copy link
Member

Choose a reason for hiding this comment

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

It is still a bit dubious why this is required, but it's much better than before. Will merge once the tests are green.

@Araq Araq merged commit e931f3b into nim-lang:devel Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants