Install a nimblemeta.json file
This commit is contained in:
parent
e5eeb9771b
commit
225f91c6aa
|
@ -10,6 +10,7 @@
|
|||
# Any path
|
||||
*.swp
|
||||
*~
|
||||
build/
|
||||
nimcache/
|
||||
|
||||
# Windows executables
|
||||
|
|
14
nimbus.1
14
nimbus.1
|
@ -12,6 +12,7 @@
|
|||
.Op Fl Fl binDir : Ns Ar path
|
||||
.Op Fl Fl nimbleDir : Ns Ar path
|
||||
.Op Fl Fl nim : Ns Ar path
|
||||
.Op Fl Fl url : Ns Ar url
|
||||
.Op nim opts...
|
||||
.Ar sourceDir
|
||||
.Op Ar buildDir
|
||||
|
@ -39,6 +40,16 @@ Set the Nimble directory.
|
|||
.
|
||||
.It Fl Fl nim : Ns Ar path
|
||||
Set the Nim compiler.
|
||||
.
|
||||
.It Fl Fl url : Ns Ar url
|
||||
If this options is set,
|
||||
.Nm
|
||||
will generate and install a
|
||||
.Pa nimblemeta.json
|
||||
file.
|
||||
Some packages specify their dependencies using URLs and
|
||||
.Nm
|
||||
is unable to find them unless a metadata file exists.
|
||||
.El
|
||||
.Pp
|
||||
All unrecognized flags are passed to the Nim compiler.
|
||||
|
@ -48,9 +59,10 @@ All unrecognized flags are passed to the Nim compiler.
|
|||
A variable prepended to each installed target file.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width installer.nims
|
||||
.Bl -tag -width nimblemeta.json
|
||||
.It Pa build.ninja
|
||||
.It Pa installer.nims
|
||||
.It Pa nimblemeta.json
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Ex -std
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Package
|
||||
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
author = "Anna"
|
||||
description = "A Nim build system."
|
||||
license = "BSD"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
const
|
||||
nimbusVersion* = "0.1.0"
|
||||
nimbusVersion* = "0.1.1"
|
||||
|
||||
defaultBinDir* = "/usr/local/bin"
|
||||
defaultNimbleDir* = "/opt/nimble"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import os, strformat
|
||||
|
||||
import options, packageinfo
|
||||
import common, options, packageinfo
|
||||
|
||||
proc writeCpFile(f: File, source, dest: string) =
|
||||
f.write(&"""echo "-- Installing " & destDir & "{dest}"""")
|
||||
|
@ -26,6 +26,10 @@ let destDir = getEnv("DESTDIR")
|
|||
f.writeCpFile(pkgInfo.nimbleFile,
|
||||
packageDir / pkgInfo.nimbleFile.lastPathPart)
|
||||
|
||||
let nimbleMeta = options.getBuildDir() / packageMetadataFileName
|
||||
if fileExists(nimbleMeta):
|
||||
f.writeCpFile(nimbleMeta, packageDir / packageMetadataFileName)
|
||||
|
||||
let offset = pkgInfo.getSourceDir(options).len
|
||||
for entry in pkgInfo.getInstallFiles(options):
|
||||
let dest = packageDir / entry.path.substr(offset)
|
||||
|
|
|
@ -12,6 +12,7 @@ type
|
|||
nimbleDir*: string
|
||||
binDir*: string
|
||||
nim*: string # Nim compiler location
|
||||
url*: string
|
||||
sourceDir*: string
|
||||
buildDir*: string
|
||||
logger*: ConsoleLogger
|
||||
|
@ -19,8 +20,8 @@ type
|
|||
|
||||
const
|
||||
help* = """
|
||||
Usage: nimbus [-h] [--nimbleDir:path] [--binDir:path] [--nim:path] [nim opts...]
|
||||
sourceDir [buildDir]
|
||||
Usage: nimbus [-h] [--nimbleDir:path] [--binDir:path] [--nim:path] [--url:url]
|
||||
[nim opts...] sourceDir [buildDir]
|
||||
|
||||
positional arguments:
|
||||
sourceDir
|
||||
|
@ -31,6 +32,7 @@ optional arguments:
|
|||
--nimbleDir:path Nimble directory (default: /opt/nimble).
|
||||
--binDir:path Executable directory (default: /usr/local/bin).
|
||||
--nim:path Nim compiler (default: nim).
|
||||
--url:url Package URL.
|
||||
|
||||
Unrecognized flags are passed to the Nim compiler.
|
||||
"""
|
||||
|
@ -135,6 +137,7 @@ proc parseFlag*(flag, val: string, result: var Options, kind = cmdLongOption) =
|
|||
of "nimbledir": result.nimbleDir = val
|
||||
of "bindir": result.binDir = val
|
||||
of "nim": result.nim = val
|
||||
of "url": result.url = val
|
||||
else: result.passNimFlags.add(getFlagString(kind, flag, val))
|
||||
|
||||
proc parseCmdLine*(): Options =
|
||||
|
|
|
@ -5,7 +5,7 @@ import os, sequtils, strtabs, strutils
|
|||
|
||||
import nimbs/common, nimbs/dependencyresolver, nimbs/installerscript,
|
||||
nimbs/ninjasyntax, nimbs/nimbleexecutor, nimbs/options,
|
||||
nimbs/packageinfo, nimbs/version
|
||||
nimbs/packageinfo, nimbs/packagemetadata, nimbs/version
|
||||
|
||||
proc processDependencies(requires: seq[string], options: Options): seq[string] =
|
||||
for req in requires:
|
||||
|
@ -63,6 +63,13 @@ proc setup(options: Options) =
|
|||
copyFile(pkgInfo.nimbleFile, nimsFile)
|
||||
let tasks = nimsFile.getTasks(options)
|
||||
|
||||
if options.url.len != 0:
|
||||
echo "-- Generating nimblemeta.json"
|
||||
let nimblemeta = open(options.getBuildDir() / packageMetadataFileName,
|
||||
fmWrite)
|
||||
nimblemeta.writeMetaData(options.url)
|
||||
nimblemeta.close()
|
||||
|
||||
echo "-- Generating installer script"
|
||||
let installer = open(options.getBuildDir() / installerFileName, fmWrite)
|
||||
installer.writeInstallerScript(pkgInfo, options)
|
||||
|
@ -82,11 +89,12 @@ proc setup(options: Options) =
|
|||
ninja.variable("builddir", options.getBuildDir())
|
||||
ninja.variable("bindir", options.getBinDir())
|
||||
ninja.variable("nimbledir", options.getNimbleDir())
|
||||
ninja.variable("url", options.url)
|
||||
ninja.newline()
|
||||
|
||||
ninja.rule("REGENERATE_BUILD",
|
||||
command = "$nimbus --binDir:$bindir --nimbleDir:$nimbledir --nim:$nim " &
|
||||
"$nimflags $sourcedir $builddir",
|
||||
"--url:$url $nimflags $sourcedir $builddir",
|
||||
description = "Regenerating build files.",
|
||||
pool = "console",
|
||||
generator = true)
|
||||
|
|
Loading…
Reference in New Issue