-
Notifications
You must be signed in to change notification settings - Fork 64
Multiple features #63
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
Conversation
genotrance
commented
May 28, 2018
- Support for installation of binary builds on Windows with detection of gcc arch
- Support for 64-bit detection - issue Windows 64 bit builds? #16 and Improve gcc detection logic #27
- Download sources and csources from Github if not available combined on nim-lang.org - issue Serve all downloads from GitHub? #42
|
see also #65 (as mentioned by @genotrance) |
|
Ping @dom96 |
|
I'm going to remove your comments because they are incredibly distracting to me as I'm reviewing this, sorry. (I backed them up in this screenshot) |
|
No worries. |
|
|
||
| downloadFile(url, result, params) | ||
|
|
||
| proc downloadCheckRenamed(params: CliParams, url, filename: string): string = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this code should be in a procedure. Also the downloadCheck proc above should be renamed to something else or restructured. Even something long like downloadIfNecessary would be better, the current name is too vague.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe hashedDownload?
| except HttpRequestError: | ||
| # Fallback to downloading from Github | ||
| # Rename to nim-VERSION.tar.gz to disambiguate | ||
| result = downloadCheckRenamed(params, githubUrl % ("v" & $version), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would GitHub have it, but not nim-lang.org? This seems redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to fallback to github.com if nim-lang.org was down. It should fall back to tar.gz + csources on Linux as well since github.com won't have an xz file with built-in csources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nim-lang.org has so far a better uptime than github.com. It's a nice thought but I doubt this complexity is worth it.
| result = getDownloadDir(params) / filename | ||
| if not fileExists(result): | ||
| let origfile = downloadCheck(params, url) | ||
| moveFile(origfile, result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking at this in more detail this seems unnecessary. The downloadFile proc takes an outputPath, also the params.getDownloadPath used in needsDownload should already use the right path. You shouldn't need to move the file for cases where you're downloading "nim-0.19.0.tar.gz", from what I can tell your code just moves it to the same place...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into cleaning up the proc names and avoid renaming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually now that I looked at this further, the reason its this way is because needsDownload() sets the outputPath, you cannot pass a value down if you want a rename, it will get overwritten.
There are two reasons to rename:
- Line 269 - downloading Nim sources from github - you get a master.tgz, no version in name
- Line 285 - downloading csources from github - you again get a master.tgz, no version in name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, what I would do is overload needsDownload:
proc needsDownload(params: CliParams, downloadUrl: string, outputPath: string): bool =Also I would get rid of these procs, putting two lines into a proc isn't worth it.
| return outputPath | ||
| try: | ||
| # Download csources tagged version from Github | ||
| # Rename to csources-VERSION.tar.gz to disambiguate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my remark above, renaming shouldn't be necessary.
| "csources-$1.tar.gz" % $version) | ||
| except HttpRequestError: | ||
| result = downloadCheck(params, csourcesUrl % "master") | ||
| display("Warning:", "Building from latest C sources. They may not be " & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick:
*Downloading the latest C sources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you want to change the message? Csources are already downloaded by now though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case "Downloaded", the point is that this procedure isn't building the C sources. You don't know what context it might be called from, it's better to make the messages reflect what the procedure is doing.
| if not needsDownload(params, mingwUrl, outputPath): | ||
| return outputPath | ||
|
|
||
| display("Downloading", "C compiler (Mingw32)", priority = HighPriority) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be misleading since it will be shown even if the download doesn't happen.
| display("Downloading", "DLLs (openssl, pcre, ...)", priority = HighPriority) | ||
| downloadFile(dllsUrl, outputPath, params) | ||
| return outputPath | ||
| result = downloadCheck(params, dllsUrl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
| proc extractZip(path: string, extractDir: string) = | ||
| var cmd = "unzip -o $1 -d $2" | ||
| if defined(windows): | ||
| cmd = "powershell -nologo -noprofile -command \"& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('$1', '$2'); }\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's awesome that powershell supports this.
Sadly it will fail on older Windows versions. I test choosenim on Win XP, any chance we could get a good fallback for those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No good answer for this. Options are to use nimarchive or some other capable extraction lib that supports gz and xz as well. Alternative is to disallow binary install if powershell isn't available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternative is to disallow binary install if powershell isn't available.
I would like this, but I'm not going to block you for it.
| # Fix win binary folder to avoid /nim-0.xx.0/nim-0.xx.0 | ||
| let winFolder = extractDir/"nim-$1" % $version | ||
| if dirExists(winFolder): | ||
| moveDirContents(winFolder, extractDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just use moveDir here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moveDir() raises an exception since directory already exists.
Error: unhandled exception: Cannot create a file when that file already exists. Good old Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would that directory already exist? Even if it exists, can't we just overwrite it?
| errC = 0 | ||
|
|
||
| when defined(windows): | ||
| (outp, errC) = execCmdEx("cmd /c echo int main^(^) { return sizeof^(void *^); } | gcc -xc - -o archtest && archtest") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not POSIX Shell syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what was added to build.bat to allow gcc arch detection.
https://github.com/nim-lang/csources/blob/master/build.bat#L14
|
I'm closing this PR in favor of simpler PRs that can be reviewed and accepted quickly. |
fix(switcher.nim): fix CC for FreeBSD