summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-09-01 10:36:13 +0200
committerAraq <rumpf_a@web.de>2013-09-01 10:36:13 +0200
commit8087f51d145c553c6bbca3987015ed5f87d0d654 (patch)
tree4390e81102ab130cb55decf0f3213b2c06cec206
parent0464a1071eb09fd77893a8981a155e33a899137e (diff)
downloadNim-8087f51d145c553c6bbca3987015ed5f87d0d654.tar.gz
fixes #582
-rw-r--r--compiler/nimrod.ini1
-rw-r--r--todo.txt1
-rw-r--r--tools/niminst/buildbat.tmpl8
-rw-r--r--tools/niminst/buildsh.tmpl5
-rw-r--r--tools/niminst/deinstall.tmpl6
-rw-r--r--tools/niminst/inno.tmpl6
-rw-r--r--tools/niminst/install.tmpl28
-rw-r--r--tools/niminst/niminst.nim23
8 files changed, 48 insertions, 30 deletions
diff --git a/compiler/nimrod.ini b/compiler/nimrod.ini
index 49dcd25ba..482fe63c9 100644
--- a/compiler/nimrod.ini
+++ b/compiler/nimrod.ini
@@ -1,7 +1,6 @@
 [Project]
 Name: "Nimrod"
 Version: "$version"
-; Windows and i386 must be first!
 OS: "windows;linux;macosx;solaris;freebsd;netbsd;openbsd"
 CPU: "i386;amd64;powerpc64;arm"  # ;sparc
 Authors: "Andreas Rumpf"
diff --git a/todo.txt b/todo.txt
index 6fce93290..732045a5e 100644
--- a/todo.txt
+++ b/todo.txt
@@ -22,6 +22,7 @@ version 0.9.4
 Bugs
 ====
 
+- compilation of niminst takes way too long. looks like a regression
 - simple closure iterator doesn't work
 - docgen: sometimes effects are listed twice
 - 'result' is not properly cleaned for NRVO --> use uninit checking instead
diff --git a/tools/niminst/buildbat.tmpl b/tools/niminst/buildbat.tmpl
index 256f61b3d..f7ccbcbfa 100644
--- a/tools/niminst/buildbat.tmpl
+++ b/tools/niminst/buildbat.tmpl
@@ -1,11 +1,11 @@
 #! stdtmpl(subsChar='?') | standard
-#proc GenerateBuildBatchScript(c: TConfigData, target: TTarget): string = 
+#proc GenerateBuildBatchScript(c: TConfigData, winIndex, cpuIndex: int): string = 
 #  result = "@echo off\nREM Generated by niminst\n"
 SET CC=gcc
 SET LINKER=gcc
 SET COMP_FLAGS=?{c.ccompiler.flags}
 SET LINK_FLAGS=?{c.linker.flags}
-SET BIN_DIR=?{firstBinPath(c)}
+SET BIN_DIR=?{firstBinPath(c).slashify}
 
 if EXIST ..\koch.nim SET BIN_DIR=..\bin
 
@@ -15,8 +15,8 @@ REM call the compiler:
 
 #  block win32:
 #    var linkCmd = ""
-#    for ff in items(c.cfiles[1][ord(target)]):
-#      let f = ff.replace('/', '\\')
+#    for ff in items(c.cfiles[winIndex][cpuIndex]):
+#      let f = ff.slashify
 ECHO %CC% %COMP_FLAGS% -Isrc -c ?{f} -o ?{changeFileExt(f, "o")}
 %CC% %COMP_FLAGS% -Isrc -c ?{f} -o ?{changeFileExt(f, "o")}
 #      linkCmd.add(" " & changeFileExt(f, "o"))
diff --git a/tools/niminst/buildsh.tmpl b/tools/niminst/buildsh.tmpl
index 1ce182b63..244d73710 100644
--- a/tools/niminst/buildsh.tmpl
+++ b/tools/niminst/buildsh.tmpl
@@ -35,7 +35,7 @@ LINK_FLAGS="?{c.linker.flags}"
 ucpu=`uname -m`
 uos=`uname`
 #  add(result, "# bin dir detection\n")
-binDir=?{firstBinPath(c)}
+binDir=?{firstBinPath(c).slashify}
 
 if [ -s ../koch.nim ]; then
   binDir="../bin"
@@ -126,7 +126,8 @@ case $myos in
 #    for cpuA in 1..c.cpus.len:
   ?{c.cpus[cpuA-1]})
 #      var linkCmd = ""
-#      for f in items(c.cfiles[osA][cpuA]):
+#      for ff in items(c.cfiles[osA][cpuA]):
+#        let f = ff.slashify
     echo "$CC $COMP_FLAGS -Isrc -c ?{f} -o ?{changeFileExt(f, "o")}"
     $CC $COMP_FLAGS -Isrc -c ?{f} -o ?{changeFileExt(f, "o")}
 #        add(linkCmd, " \\\n" & changeFileExt(f, "o"))
diff --git a/tools/niminst/deinstall.tmpl b/tools/niminst/deinstall.tmpl
index 61141f78e..c961ac07a 100644
--- a/tools/niminst/deinstall.tmpl
+++ b/tools/niminst/deinstall.tmpl
@@ -39,10 +39,12 @@ if [ $# -eq 1 ] ; then
   esac
   echo "removing files..."
 
-#for f in items(c.cat[fcUnixBin]):
+#for ff in items(c.cat[fcUnixBin]):
+  #let f = ff.slashify
   rm -f $bindir/?f.skipRoot
 #end for
-#for f in items(c.cat[fcConfig]): 
+#for ff in items(c.cat[fcConfig]): 
+  #let f = ff.slashify
   rm -f $configdir/?f.skipRoot
 #end for
   rm -rf $docdir
diff --git a/tools/niminst/inno.tmpl b/tools/niminst/inno.tmpl
index df1460e42..0219dea1f 100644
--- a/tools/niminst/inno.tmpl
+++ b/tools/niminst/inno.tmpl
@@ -21,7 +21,7 @@ Name: english; MessagesFile: compiler:Default.isl
 [Files] 
   #for i in low(TFileCategory)..fcWindows:
   #  for f in items(c.cat[i]):
-Source: ${expandFilename(f)}; DestDir: {app}\${splitFile(f).dir}; Flags: ignoreversion
+Source: ${expandFilename(f).slashify}; DestDir: {app}\${splitFile(f).dir.slashify}; Flags: ignoreversion
   #  end for
   #end for
 
@@ -32,7 +32,7 @@ Name: {group}\Console for $c.displayName; Filename: {cmd}
 Name: {group}\$c.displayName; Filename: {app}\${c.name}.exe
   #end if
   #for f in items(c.cat[fcDocStart]):
-Name: {group}\Documentation; Filename: {app}\$f
+Name: {group}\Documentation; Filename: {app}\${f.slashify}
   #end for
 Name: {group}\{cm:UninstallProgram,$c.displayName}; Filename: {uninstallexe}
 
@@ -65,7 +65,7 @@ begin
   setArrayLength(result, $c.binPaths.len);
     #var i = 0
     #for b in items(c.binPaths):
-  result[$i] := ExpandConstant('{app}') + '\$b';
+  result[$i] := ExpandConstant('{app}') + '\${b.slashify}';
       #inc(i)
     #end for
 end;
diff --git a/tools/niminst/install.tmpl b/tools/niminst/install.tmpl
index bfba024c7..3eb07b8af 100644
--- a/tools/niminst/install.tmpl
+++ b/tools/niminst/install.tmpl
@@ -7,7 +7,7 @@ set -e
 
 if [ $# -eq 1 ] ; then
 # if c.cat[fcUnixBin].len > 0:
-  if test -f ?{c.cat[fcUnixBin][0]}
+  if test -f ?{c.cat[fcUnixBin][0].slashify}
   then 
     echo "?c.displayName build detected"
   else
@@ -65,35 +65,35 @@ if [ $# -eq 1 ] ; then
 #      mk = unixDirVars[cat] & "/" & mk
 #      if not createdDirs.hasKey(mk):
 #        createdDirs[mk] = "true"
-  mkdir -p ?mk
+  mkdir -p ?{mk.slashify}
 #      end if
 #    end if
 #  end for
 #end for
 
 #for f in items(c.cat[fcUnixBin]):
-  cp ?f $bindir/?f.skipRoot
-  chmod 755 $bindir/?f.skipRoot
+  cp ?f.slashify $bindir/?f.skipRoot.slashify
+  chmod 755 $bindir/?f.skipRoot.slashify
 #end for
 #for f in items(c.cat[fcConfig]): 
-  cp ?f $configdir/?f.skipRoot
-  chmod 644 $configdir/?f.skipRoot
+  cp ?f.slashify $configdir/?f.skipRoot.slashify
+  chmod 644 $configdir/?f.skipRoot.slashify
 #end for
 #for f in items(c.cat[fcData]): 
-  if [ -f ?f ]; then
-    cp ?f $datadir/?f.skipRoot
-    chmod 644 $datadir/?f.skipRoot
+  if [ -f ?f.slashify ]; then
+    cp ?f.slashify $datadir/?f.skipRoot.slashify
+    chmod 644 $datadir/?f.skipRoot.slashify
   fi
 #end for
 #for f in items(c.cat[fcDoc]):
-  if [ -f ?f ]; then
-    cp ?f $docdir/?f.skipRoot
-    chmod 644 $docdir/?f.skipRoot
+  if [ -f ?f.slashify ]; then
+    cp ?f.slashify $docdir/?f.skipRoot.slashify
+    chmod 644 $docdir/?f.skipRoot.slashify
   fi
 #end for
 #for f in items(c.cat[fcLib]):
-  cp ?f $libdir/?f.skipRoot
-  chmod 644 $libdir/?f.skipRoot
+  cp ?f.slashify $libdir/?f.skipRoot.slashify
+  chmod 644 $libdir/?f.skipRoot.slashify
 #end for
   
   echo "installation successful"
diff --git a/tools/niminst/niminst.nim b/tools/niminst/niminst.nim
index 4ee60f853..4da734d13 100644
--- a/tools/niminst/niminst.nim
+++ b/tools/niminst/niminst.nim
@@ -27,7 +27,6 @@ const
 
 type
   TAppType = enum appConsole, appGUI
-  TTarget = enum tWin32 = 1, tWin64 = 2
   TAction = enum
     actionNone,   # action not yet known
     actionCSource # action: create C sources
@@ -103,6 +102,9 @@ proc firstBinPath(c: TConfigData): string =
 proc `\`(a, b: string): string =
   result = if a.len == 0: b else: a & '\\' & b
 
+proc slashify(s: string): string =
+  when defined(unix): s.replace('\\', '/') else: s.replace('/', '\\')
+
 proc skipRoot(f: string): string =
   # "abc/def/xyz" --> "def/xyz"
   var i = 0
@@ -400,15 +402,23 @@ proc srcdist(c: var TConfigData) =
   for x in walkFiles(c.libpath / "lib/*.h"):
     echo(getOutputDir(c) / "src" / extractFilename(x))
     copyFile(dest=getOutputDir(c) / "src" / extractFilename(x), source=x)
+  var winIndex = -1
+  var intel32Index = -1
+  var intel64Index = -1
   for osA in 1..c.oses.len:
+    let osname = c.oses[osA-1]
+    if osname.cmpIgnoreStyle("windows") == 0: winIndex = osA-1
     for cpuA in 1..c.cpus.len:
+      let cpuname = c.cpus[cpuA-1]
+      if cpuname.cmpIgnoreStyle("i386") == 0: intel32Index = cpuA-1
+      elif cpuname.cmpIgnoreStyle("amd64") == 0: intel64Index = cpuA-1
       var dir = getOutputDir(c) / buildDir(osA, cpuA)
       if existsDir(dir): removeDir(dir)
       createDir(dir)
       var cmd = ("nimrod compile -f --symbolfiles:off --compileonly " &
                  "--gen_mapping --cc:gcc --skipUserCfg" &
                  " --os:$# --cpu:$# $# $#") %
-                 [c.oses[osA-1], c.cpus[cpuA-1], c.nimrodArgs,
+                 [osname, cpuname, c.nimrodArgs,
                  changeFileExt(c.infile, "nim")]
       echo(cmd)
       if execShellCmd(cmd) != 0:
@@ -422,8 +432,13 @@ proc srcdist(c: var TConfigData) =
   # second pass: remove duplicate files
   removeDuplicateFiles(c)
   writeFile(getOutputDir(c) / buildShFile, generateBuildShellScript(c), "\10")
-  writeFile(getOutputDir(c) / buildBatFile32, generateBuildBatchScript(c, tWin32), "\13\10")
-  writeFile(getOutputDir(c) / buildBatFile64, generateBuildBatchScript(c, tWin64), "\13\10")
+  if winIndex >= 0:
+    if intel32Index >= 0:
+      writeFile(getOutputDir(c) / buildBatFile32,
+                generateBuildBatchScript(c, winIndex, intel32Index), "\13\10")
+    if intel64Index >= 0:
+      writeFile(getOutputDir(c) / buildBatFile64,
+                generateBuildBatchScript(c, winIndex, intel64Index), "\13\10")
   writeInstallScripts(c)
 
 # --------------------- generate inno setup -----------------------------------