mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 21:17:48 +00:00
@@ -61,7 +61,7 @@ Files: "icons/koch.res"
|
||||
Files: "icons/koch_icon.o"
|
||||
|
||||
Files: "compiler/readme.txt"
|
||||
Files: "compiler/nim.ini"
|
||||
Files: "compiler/installer.ini"
|
||||
Files: "compiler/nim.nimrod.cfg"
|
||||
Files: "compiler/*.nim"
|
||||
Files: "doc/*.txt"
|
||||
@@ -77,7 +77,7 @@ Files: "tools/niminst/*.nim"
|
||||
Files: "tools/niminst/*.cfg"
|
||||
Files: "tools/niminst/*.tmpl"
|
||||
Files: "tools/niminst/*.nsh"
|
||||
Files: "web/nim.ini"
|
||||
Files: "web/website.ini"
|
||||
Files: "web/*.nim"
|
||||
Files: "web/*.txt"
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ In the case of Nim's own documentation, the ``txt`` value is just a commit
|
||||
hash to append to a formatted URL to https://github.com/Araq/Nim. The
|
||||
``tools/nimweb.nim`` helper queries the current git commit hash during doc
|
||||
generation, but since you might be working on an unpublished repository, it
|
||||
also allows specifying a ``githash`` value in ``web/nim.ini`` to force a
|
||||
also allows specifying a ``githash`` value in ``web/website.ini`` to force a
|
||||
specific commit in the output.
|
||||
|
||||
|
||||
|
||||
16
koch.nim
16
koch.nim
@@ -41,7 +41,7 @@ Options:
|
||||
Possible Commands:
|
||||
boot [options] bootstraps with given command line options
|
||||
install [bindir] installs to given directory; Unix only!
|
||||
clean cleans Nimrod project; removes generated files
|
||||
clean cleans Nim project; removes generated files
|
||||
web [options] generates the website and the full documentation
|
||||
website [options] generates only the website
|
||||
csource [options] builds the C sources for installation
|
||||
@@ -59,7 +59,7 @@ Boot options:
|
||||
-d:useGnuReadline use the GNU readline library for interactive mode
|
||||
(not needed on Windows)
|
||||
-d:nativeStacktrace use native stack traces (only for Mac OS X or Linux)
|
||||
-d:noCaas build Nimrod without CAAS support
|
||||
-d:noCaas build Nim without CAAS support
|
||||
-d:avoidTimeMachine only for Mac OS X, excludes nimcache dir from backups
|
||||
Web options:
|
||||
--googleAnalytics:UA-... add the given google analytics code to the docs. To
|
||||
@@ -97,13 +97,13 @@ const
|
||||
compileNimInst = "-d:useLibzipSrc tools/niminst/niminst"
|
||||
|
||||
proc csource(args: string) =
|
||||
exec("$4 cc $1 -r $3 --var:version=$2 --var:mingw=none csource compiler/installer.ini $1" %
|
||||
exec("$4 cc $1 -r $3 --var:version=$2 --var:mingw=none csource --main:compiler/nim.nim compiler/installer.ini $1" %
|
||||
[args, VersionAsString, compileNimInst, findNim()])
|
||||
|
||||
proc zip(args: string) =
|
||||
exec("$3 cc -r $2 --var:version=$1 --var:mingw=none scripts compiler/installer.ini" %
|
||||
exec("$3 cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
|
||||
[VersionAsString, compileNimInst, findNim()])
|
||||
exec("$# --var:version=$# --var:mingw=none zip compiler/installer.ini" %
|
||||
exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" %
|
||||
["tools/niminst/niminst".exe, VersionAsString])
|
||||
|
||||
proc buildTool(toolname, args: string) =
|
||||
@@ -121,7 +121,7 @@ proc nsis(args: string) =
|
||||
" nsis compiler/nim") % [VersionAsString, $(sizeof(pointer)*8)])
|
||||
|
||||
proc install(args: string) =
|
||||
exec("$# cc -r $# --var:version=$# --var:mingw=none scripts compiler/installer.ini" %
|
||||
exec("$# cc -r $# --var:version=$# --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
|
||||
[findNim(), compileNimInst, VersionAsString])
|
||||
exec("sh ./install.sh $#" % args)
|
||||
|
||||
@@ -282,7 +282,7 @@ when defined(withUpdate):
|
||||
when defined(haveZipLib):
|
||||
echo("Falling back.. Downloading source code from repo...")
|
||||
# use dom96's httpclient to download zip
|
||||
downloadFile("https://github.com/Araq/Nimrod/zipball/master",
|
||||
downloadFile("https://github.com/Araq/Nim/zipball/master",
|
||||
thisDir / "update.zip")
|
||||
try:
|
||||
echo("Extracting source code from archive...")
|
||||
@@ -320,7 +320,7 @@ proc winRelease() =
|
||||
|
||||
run7z("win32", "bin/nim.exe", "bin/c2nim.exe", "bin/nimgrep.exe",
|
||||
"bin/nimfix.exe",
|
||||
"bin/babel.exe", "bin/*.dll",
|
||||
"bin/nimble.exe", "bin/*.dll",
|
||||
"config", "dist/*.dll", "examples", "lib",
|
||||
"readme.txt", "contributors.txt", "copying.txt")
|
||||
# second step: XXX build 64 bit version
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#! stdtmpl(subsChar='?') | standard
|
||||
#proc generateBuildShellScript(c: ConfigData): string =
|
||||
# result = "#! /bin/sh\n# Generated from niminst\n" &
|
||||
# "# Template is in tools/buildsh.tmpl\n" &
|
||||
# "# Template is in tools/niminst/buildsh.tmpl\n" &
|
||||
# "# To regenerate run ``niminst csource`` or ``koch csource``\n"
|
||||
|
||||
set -e
|
||||
@@ -111,7 +111,7 @@ case $ucpu in
|
||||
LINK_FLAGS="$LINK_FLAGS -m64"
|
||||
fi
|
||||
mycpu="powerpc64" ;;
|
||||
*power*|*Power*|*ppc* )
|
||||
*power*|*ppc* )
|
||||
mycpu="powerpc" ;;
|
||||
*mips* )
|
||||
mycpu="mips" ;;
|
||||
|
||||
168
tools/niminst/makefile.tmpl
Normal file
168
tools/niminst/makefile.tmpl
Normal file
@@ -0,0 +1,168 @@
|
||||
#! stdtmpl(subsChar='?') | standard
|
||||
#proc generateMakefile(c: ConfigData): string =
|
||||
# result = "# Generated from niminst\n" &
|
||||
# "# Template is in tools/niminst/makefile.tmpl\n" &
|
||||
# "# To regenerate run ``niminst csource`` or ``koch csource``\n"
|
||||
|
||||
CC = gcc
|
||||
LINKER = gcc
|
||||
COMP_FLAGS = ?{c.ccompiler.flags}
|
||||
LINK_FLAGS = ?{c.linker.flags}
|
||||
binDir = ?{firstBinPath(c).toUnix}
|
||||
|
||||
koch := $(shell sh -c 'test -s ../koch.nim && echo "yes"')
|
||||
ifeq ($(koch),yes)
|
||||
binDir = ../bin
|
||||
endif
|
||||
|
||||
ucpu := $(shell sh -c 'uname -m | tr "[:upper:]" "[:lower:]"')
|
||||
uos := $(shell sh -c 'uname | tr "[:upper:]" "[:lower:]"')
|
||||
|
||||
ifeq ($(uos),linux)
|
||||
myos = linux
|
||||
LINK_FLAGS += -ldl -lm
|
||||
endif
|
||||
ifeq ($(uos),dragonfly)
|
||||
myos = freebsd
|
||||
LINK_FLAGS += -lm
|
||||
endif
|
||||
ifeq ($(uos),freebsd)
|
||||
myos= freebsd
|
||||
CC = clang
|
||||
LINKER = clang
|
||||
LINK_FLAGS += -lm
|
||||
endif
|
||||
ifeq ($(uos),openbsd)
|
||||
myos = openbsd
|
||||
LINK_FLAGS += -lm
|
||||
endif
|
||||
ifeq ($(uos),netbsd)
|
||||
myos = netbsd
|
||||
LINK_FLAGS += -lm
|
||||
endif
|
||||
ifeq ($(uos),darwin)
|
||||
myos = macosx
|
||||
CC = clang
|
||||
LINKER = clang
|
||||
LINK_FLAGS += -ldl -lm
|
||||
ifeq ($HOSTTYPE,x86_64)
|
||||
ucpu = amd64
|
||||
endif
|
||||
endif
|
||||
ifeq ($(uos),aix)
|
||||
myos = aix
|
||||
LINK_FLAGS += -dl -lm
|
||||
endif
|
||||
ifeq ($(uos),solaris)
|
||||
myos = solaris
|
||||
LINK_FLAGS += -ldl -lm -lsocket -lnsl
|
||||
endif
|
||||
ifeq ($(uos),sun)
|
||||
myos = solaris
|
||||
LINK_FLAGS += -ldl -lm -lsocket -lnsl
|
||||
endif
|
||||
ifeq ($(uos),haiku)
|
||||
myos = haiku
|
||||
endif
|
||||
ifndef uos
|
||||
@echo "Error: unknown operating system: $(uos)"
|
||||
@exit 1
|
||||
endif
|
||||
|
||||
ifeq ($(ucpu),i386)
|
||||
mycpu = i386
|
||||
endif
|
||||
ifeq ($(ucpu),i486)
|
||||
mycpu = i386
|
||||
endif
|
||||
ifeq ($(ucpu),i586)
|
||||
mycpu = i386
|
||||
endif
|
||||
ifeq ($(ucpu),i686)
|
||||
mycpu = i386
|
||||
endif
|
||||
ifeq ($(ucpu),bepc)
|
||||
mycpu = i386
|
||||
endif
|
||||
ifeq ($(ucpu),i86pc)
|
||||
mycpu = i386
|
||||
endif
|
||||
ifeq ($(ucpu),amd64)
|
||||
mycpu = amd64
|
||||
endif
|
||||
ifeq ($(ucpu),x86-64)
|
||||
mycpu = amd64
|
||||
endif
|
||||
ifeq ($(ucpu),x86_64)
|
||||
mycpu = amd64
|
||||
endif
|
||||
ifeq ($(ucpu),sparc)
|
||||
mycpu = sparc
|
||||
endif
|
||||
ifeq ($(ucpu),sun)
|
||||
mycpu = sparc
|
||||
endif
|
||||
ifeq ($(ucpu),ppc64)
|
||||
mycpu = powerpc64
|
||||
ifeq ($(myos),linux)
|
||||
COMP_FLAGS += -m64
|
||||
LINK_FLAGS += -m64
|
||||
endif
|
||||
endif
|
||||
ifeq ($(ucpu),powerpc)
|
||||
mycpu = powerpc
|
||||
endif
|
||||
ifeq ($(ucpu),ppc)
|
||||
mycpu = ppc
|
||||
endif
|
||||
ifeq ($(ucpu),mips)
|
||||
mycpu = mips
|
||||
endif
|
||||
ifeq ($(ucpu),arm)
|
||||
mycpu = arm
|
||||
endif
|
||||
ifeq ($(ucpu),armeb)
|
||||
mycpu = arm
|
||||
endif
|
||||
ifeq ($(ucpu),armel)
|
||||
mycpu = arm
|
||||
endif
|
||||
ifeq ($(ucpu),armv6l)
|
||||
mycpu = arm
|
||||
endif
|
||||
ifndef ucpu
|
||||
@echo "Error: unknown processor : $(ucpu)"
|
||||
@exit 1
|
||||
endif
|
||||
|
||||
# for osA in 1..c.oses.len:
|
||||
ifeq ($(myos),?{c.oses[osA-1]})
|
||||
# for cpuA in 1..c.cpus.len:
|
||||
ifeq ($(mycpu),?{c.cpus[cpuA-1]})
|
||||
# var oFiles = ""
|
||||
# for ff in c.cfiles[osA][cpuA].items:
|
||||
# oFiles.add(" " & changeFileExt(ff.toUnix, "o"))
|
||||
# end for
|
||||
oFiles =?oFiles
|
||||
endif
|
||||
# end for
|
||||
endif
|
||||
# end for
|
||||
|
||||
ifeq ($(strip $(oFiles)),)
|
||||
@echo "Error: no C code generated for: [$(myos): $(mycpu)]"
|
||||
@exit 1
|
||||
endif
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(COMP_FLAGS) -Ic_code -c $< -o $@
|
||||
|
||||
?{"$(binDir)/" & toLower(c.name)}: $(oFiles)
|
||||
@mkdir -p $(binDir)
|
||||
$(LINKER) -o $@ $^ $(LINK_FLAGS)
|
||||
@echo "SUCCESS"
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f $(oFiles) ?{"$(binDir)/" & toLower(c.name)}
|
||||
@@ -22,6 +22,7 @@ const
|
||||
buildShFile = "build.sh"
|
||||
buildBatFile32 = "build.bat"
|
||||
buildBatFile64 = "build64.bat"
|
||||
makeFile = "makefile"
|
||||
installShFile = "install.sh"
|
||||
deinstallShFile = "deinstall.sh"
|
||||
|
||||
@@ -56,7 +57,7 @@ type
|
||||
platforms: array[1..maxOS, array[1..maxCPU, bool]]
|
||||
ccompiler, linker, innosetup, nsisSetup: tuple[path, flags: string]
|
||||
name, displayName, version, description, license, infile, outdir: string
|
||||
libpath: string
|
||||
mainfile, libpath: string
|
||||
innoSetupFlag, installScript, uninstallScript: bool
|
||||
explicitPlatforms: bool
|
||||
vars: StringTableRef
|
||||
@@ -87,6 +88,7 @@ proc iniConfigData(c: var ConfigData) =
|
||||
c.description = ""
|
||||
c.license = ""
|
||||
c.infile = ""
|
||||
c.mainfile = ""
|
||||
c.outdir = ""
|
||||
c.nimArgs = ""
|
||||
c.libpath = ""
|
||||
@@ -122,6 +124,7 @@ proc skipRoot(f: string): string =
|
||||
include "inno.tmpl"
|
||||
include "nsis.tmpl"
|
||||
include "buildsh.tmpl"
|
||||
include "makefile.tmpl"
|
||||
include "buildbat.tmpl"
|
||||
include "install.tmpl"
|
||||
include "deinstall.tmpl"
|
||||
@@ -144,6 +147,8 @@ Command:
|
||||
deb create files for debhelper
|
||||
Options:
|
||||
-o, --output:dir set the output directory
|
||||
-m, --main:file set the main nim file, by default ini-file with .nim
|
||||
extension
|
||||
--var:name=value set the value of a variable
|
||||
-h, --help shows this help
|
||||
-v, --version shows the version
|
||||
@@ -183,6 +188,7 @@ proc parseCmdLine(c: var ConfigData) =
|
||||
stdout.write(Version & "\n")
|
||||
quit(0)
|
||||
of "o", "output": c.outdir = val
|
||||
of "m", "main": c.mainfile = changeFileExt(val, "nim")
|
||||
of "var":
|
||||
var idx = val.find('=')
|
||||
if idx < 0: quit("invalid command line")
|
||||
@@ -190,6 +196,7 @@ proc parseCmdLine(c: var ConfigData) =
|
||||
else: quit(Usage)
|
||||
of cmdEnd: break
|
||||
if c.infile.len == 0: quit(Usage)
|
||||
if c.mainfile.len == 0: c.mainfile = changeFileExt(c.infile, "nim")
|
||||
|
||||
proc walkDirRecursively(s: var seq[string], root: string) =
|
||||
for k, f in walkDir(root):
|
||||
@@ -358,7 +365,7 @@ proc parseIniFile(c: var ConfigData) =
|
||||
of cfgOption: quit(errorStr(p, "syntax error"))
|
||||
of cfgError: quit(errorStr(p, k.msg))
|
||||
close(p)
|
||||
if c.name.len == 0: c.name = changeFileExt(extractFilename(c.infile), "")
|
||||
if c.name.len == 0: c.name = changeFileExt(extractFilename(c.mainfile), "")
|
||||
if c.displayName.len == 0: c.displayName = c.name
|
||||
else:
|
||||
quit("cannot open: " & c.infile)
|
||||
@@ -436,8 +443,10 @@ proc removeDuplicateFiles(c: var ConfigData) =
|
||||
proc writeInstallScripts(c: var ConfigData) =
|
||||
if c.installScript:
|
||||
writeFile(installShFile, generateInstallScript(c), "\10")
|
||||
inclFilePermissions(installShFile, {fpUserExec, fpGroupExec, fpOthersExec})
|
||||
if c.uninstallScript:
|
||||
writeFile(deinstallShFile, generateDeinstallScript(c), "\10")
|
||||
inclFilePermissions(deinstallShFile, {fpUserExec, fpGroupExec, fpOthersExec})
|
||||
|
||||
proc srcdist(c: var ConfigData) =
|
||||
if not existsDir(getOutputDir(c) / "c_code"):
|
||||
@@ -462,8 +471,7 @@ proc srcdist(c: var ConfigData) =
|
||||
var cmd = ("nim compile -f --symbolfiles:off --compileonly " &
|
||||
"--gen_mapping --cc:gcc --skipUserCfg" &
|
||||
" --os:$# --cpu:$# $# $#") %
|
||||
[osname, cpuname, c.nimArgs,
|
||||
changeFileExt(c.infile, "nim")]
|
||||
[osname, cpuname, c.nimArgs, c.mainfile]
|
||||
echo(cmd)
|
||||
if execShellCmd(cmd) != 0:
|
||||
quit("Error: call to nim compiler failed")
|
||||
@@ -476,6 +484,8 @@ proc srcdist(c: var ConfigData) =
|
||||
# second pass: remove duplicate files
|
||||
removeDuplicateFiles(c)
|
||||
writeFile(getOutputDir(c) / buildShFile, generateBuildShellScript(c), "\10")
|
||||
inclFilePermissions(getOutputDir(c) / buildShFile, {fpUserExec, fpGroupExec, fpOthersExec})
|
||||
writeFile(getOutputDir(c) / makeFile, generateMakefile(c), "\10")
|
||||
if winIndex >= 0:
|
||||
if intel32Index >= 0:
|
||||
writeFile(getOutputDir(c) / buildBatFile32,
|
||||
@@ -531,6 +541,7 @@ when haveZipLib:
|
||||
addFile(z, proj / buildBatFile32, "build" / buildBatFile32)
|
||||
addFile(z, proj / buildBatFile64, "build" / buildBatFile64)
|
||||
addFile(z, proj / buildShFile, "build" / buildShFile)
|
||||
addFile(z, proj / makeFile, "build" / makeFile)
|
||||
addFile(z, proj / installShFile, installShFile)
|
||||
addFile(z, proj / deinstallShFile, deinstallShFile)
|
||||
for f in walkFiles(c.libpath / "lib/*.h"):
|
||||
@@ -571,6 +582,7 @@ proc debDist(c: var ConfigData) =
|
||||
|
||||
# Don't copy all files, only the ones specified in the config:
|
||||
copyNimDist(buildShFile, buildShFile)
|
||||
copyNimDist(makeFile, makeFile)
|
||||
copyNimDist(installShFile, installShFile)
|
||||
createDir(workingDir / upstreamSource / "build")
|
||||
for f in walkFiles(c.libpath / "lib/*.h"):
|
||||
|
||||
Reference in New Issue
Block a user