summary refs log tree commit diff stats
path: root/tools/niminst/niminst.nim
diff options
context:
space:
mode:
authorAlain Kalker <a.c.kalker@gmail.com>2013-03-16 23:10:06 +0100
committerAlain Kalker <a.c.kalker@gmail.com>2013-03-17 20:10:24 +0100
commitcaf9140b23cb743f866e71f7efc9c68ec96d3368 (patch)
tree68b87fd8fc87cd1ec3ca68cfba40a35c3a18c80e /tools/niminst/niminst.nim
parent29d0a774e985fa457da14e288f1e2dc634496c8b (diff)
downloadNim-caf9140b23cb743f866e71f7efc9c68ec96d3368.tar.gz
Separate out install/uninstall script generation
- Add new feature to niminst: scripts - build install scripts
  (based on csource feature)
- Change install feature in koch to build the install scripts, then
  run install.sh
- Don't track install scripts in Git.
Diffstat (limited to 'tools/niminst/niminst.nim')
-rw-r--r--tools/niminst/niminst.nim16
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/niminst/niminst.nim b/tools/niminst/niminst.nim
index f41ab665e..98a7ab8bb 100644
--- a/tools/niminst/niminst.nim
+++ b/tools/niminst/niminst.nim
@@ -32,6 +32,7 @@ type
     actionNone,   # action not yet known
     actionCSource # action: create C sources
     actionInno,   # action: create Inno Setup installer
+    actionScripts # action: create install and deinstall scripts
     actionZip,    # action: create zip file
     actionDeb     # action: prepare deb package
 
@@ -128,6 +129,7 @@ Usage:
   niminst [options] command[;command2...] ini-file[.ini] [compile_options]
 Command:
   csource             build C source code for source based installations
+  scripts             build install and deinstall scripts
   zip                 build the ZIP file
   inno                build the Inno Setup installer
   deb                 create files for debhelper
@@ -153,6 +155,7 @@ proc parseCmdLine(c: var TConfigData) =
         for a in split(normalize(key.string), {';', ','}):
           case a
           of "csource": incl(c.actions, actionCSource)
+          of "scripts": incl(c.actions, actionScripts)
           of "zip": incl(c.actions, actionZip)
           of "inno": incl(c.actions, actionInno)
           of "deb": incl(c.actions, actionDeb)
@@ -382,6 +385,12 @@ proc removeDuplicateFiles(c: var TConfigData) =
                 RemoveFile(dup)
                 c.cfiles[osA][cpuA][i] = orig
 
+proc writeInstallScripts(c: var TConfigData) =
+  if c.installScript:
+    writeFile(installShFile, GenerateInstallScript(c), "\10")
+  if c.uninstallScript:
+    writeFile(deinstallShFile, GenerateDeinstallScript(c), "\10")
+
 proc srcdist(c: var TConfigData) =
   for x in walkFiles(c.libpath / "lib/*.h"):
     CopyFile(dest="build" / extractFilename(x), source=x)
@@ -408,10 +417,7 @@ proc srcdist(c: var TConfigData) =
   writeFile(buildShFile, GenerateBuildShellScript(c), "\10")
   writeFile(buildBatFile32, GenerateBuildBatchScript(c, tWin32), "\13\10")
   writeFile(buildBatFile64, GenerateBuildBatchScript(c, tWin64), "\13\10")
-  if c.installScript:
-    writeFile(installShFile, GenerateInstallScript(c), "\10")
-  if c.uninstallScript:
-    writeFile(deinstallShFile, GenerateDeinstallScript(c), "\10")
+  writeInstallScripts(c)
 
 # --------------------- generate inno setup -----------------------------------
 proc setupDist(c: var TConfigData) =
@@ -514,6 +520,8 @@ if actionInno in c.actions:
   setupDist(c)
 if actionCSource in c.actions:
   srcdist(c)
+if actionScripts in c.actions:
+  writeInstallScripts(c)
 if actionZip in c.actions:
   when haveZipLib:
     zipdist(c)