[Reworked strict mode patch to apply to new indentation and to incorporate Quags fixes
Jonas Eschenburg <indyjo@gmx.de>**20080119174820] {
hunk ./debian/changelog 8
+  * Reworked strict mode build patch
hunk ./debian/patches/00list 9
-add-strict-mode-option-to-build.io.dpatch
+add-strict-mode-option-to-build.io-2.dpatch
addfile ./debian/patches/add-strict-mode-option-to-build.io-2.dpatch
hunk ./debian/patches/add-strict-mode-option-to-build.io-2.dpatch 1
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## add-strict-mode-option-to-build.io-2.dpatch by Jonas Eschenburg <indyjo@gmx.de>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: No description.
+
+@DPATCH@
+diff --git a/build.io b/build.io
+--- a/build.io
++++ b/build.io
+@@ -7,12 +7,32 @@ Directory fileNamedOrNil := method(path,
+ 
+ Directory setCurrentWorkingDirectory(launchPath)
+ 
++addonToBuild := nil
++command := nil
++
+ project := Project clone
+-args := System args clone
+-if(args at(1) == "-a") then(
+-	project buildAddon(args at(2))
+-) elseif (args at(1)) then(
+-	project clone doString(args at(1))
+-) else (
+-	project clone build
++
++args := System args clone slice(1)
++while(args isNotEmpty,
++	if(args at(0) == "-s") then(
++		project setStrictMode(true)
++		args removeFirst
++	) elseif (args at(0) == "-a") then(
++		addonToBuild = args at(1)
++		args = args slice(2)
++	) else(
++		command = args at(0)
++		break
++	)
+ )
++
++if (addonToBuild isNil) then(
++	if (command isNil) then(
++		project build
++	) else(
++		project doString(command)
++	)
++) else(
++	project buildAddon(addonToBuild)
++)
++
+diff --git a/build/AddonBuilder.io b/build/AddonBuilder.io
+--- a/build/AddonBuilder.io
++++ b/build/AddonBuilder.io
+@@ -3,6 +3,9 @@ Sequence prepend := method(s, s .. self)
+ AddonBuilder := Object clone do(
+ 	isDisabled := false
+ 	disable := method(isDisabled = true)
++	
++	# Fail if the addon has an error while building
++	newSlot("strictMode", false)
+ 
+ 	platform := System platform split at(0) asLowercase
+ 	cflags := method(System getEnvironmentVariable("CFLAGS") ifNilEval(""))
+@@ -190,7 +193,18 @@ AddonBuilder := Object clone do(
+ 	)
+ 
+ 	systemCall := method(s,
+-		if(trySystemCall(s) == 256, System exit(1))
++		retval := trySystemCall(s)
++		if(retval == 256, System exit(1))
++		retval
++	)
++
++	strictSystemCall := method(s,
++		retval := systemCall(s)
++		if(strictMode and retval != 0,
++			"Command exited with code #{retval}." interpolate println
++			"Aborting because strict mode is set." println
++			System exit(1)
++		)
+ 	)
+ 
+ 	trySystemCall := method(s,
+@@ -259,7 +273,7 @@ AddonBuilder := Object clone do(
+ 									s = s .. "_ADDON "
+ 								)
+ 				s = s .. "-c " .. ccOutFlag .. "_build/objs/" .. obj .. " source/" .. f name
+-				systemCall(s)
++				strictSystemCall(s)
+ 			)
+ 		)
+ 
+@@ -272,8 +286,8 @@ AddonBuilder := Object clone do(
+ 
+ 	buildLib := method(
+ 		mkdir("_build/lib")
+-		systemCall(ar .. " " .. arFlags ..  "_build/lib/" .. libName .. " _build/objs/*.o")
+-				if (ranlib != nil, systemCall(ranlib .. " _build/lib/" .. libName))
++		strictSystemCall(ar .. " " .. arFlags ..  "_build/lib/" .. libName .. " _build/objs/*.o")
++		if (ranlib != nil, strictSystemCall(ranlib .. " _build/lib/" .. libName))
+ 	)
+ 
+ 	dllSuffix := method(
+@@ -323,13 +337,13 @@ AddonBuilder := Object clone do(
+ 			s := " -install_name " .. System installPrefix .. "/lib/io/addons/" .. self name .. "/_build/dll/" .. libname
+ 		)
+ 
+-		systemCall(linkdll .. " " .. cflags .. " " .. dllCommand .. " " .. s .. " " .. linkOutFlag .. "_build/dll/" .. libname .. " _build/objs/*.o" .. " " .. links join(" "))
++		strictSystemCall(linkdll .. " " .. cflags .. " " .. dllCommand .. " " .. s .. " " .. linkOutFlag .. "_build/dll/" .. libname .. " _build/objs/*.o" .. " " .. links join(" "))
+ 	)
+ 
+ 	embedManifest := method(
+ 		dllFilePath := "_build/dll/" .. dllNameFor("Io" .. name)
+ 		manifestFilePath := dllFilePath .. ".manifest"
+-			systemCall("mt.exe -manifest " .. manifestFilePath .. " -outputresource:" .. dllFilePath .. ";2")
++		strictSystemCall("mt.exe -manifest " .. manifestFilePath .. " -outputresource:" .. dllFilePath .. ";2")
+ 		writeln("Removing manifest file: " .. manifestFilePath)
+ 		File with(folder path .. "/" .. manifestFilePath) remove
+ 	)
+diff --git a/build/Project.io b/build/Project.io
+--- a/build/Project.io
++++ b/build/Project.io
+@@ -3,6 +3,9 @@ Project := Object clone do(
+ 	cxx := method(System getEnvironmentVariable("CXX") ifNilEval(return "g++"))
+ 	platform := System platform split at(0) asLowercase
+ 
++	# Fail if any addon has an error while building
++	newSlot("strictMode", false)
++
+ 	systemCall := method(s,
+ 		r := trySystemCall(s)
+ 		if(r == 256, System exit(1))
+@@ -28,6 +31,8 @@ Project := Object clone do(
+ 
+ 	addons := method(
+ 		self addons := modulesInFolder("addons") sortInPlaceBy(block(x, y, x name < y name))
++		self addons foreach(setStrictMode(strictMode))
++		self addons
+ 	)
+ 
+ 	buildAddon := method(name,
hunk ./debian/patches/add-strict-mode-option-to-build.io.dpatch 1
-#! /bin/sh /usr/share/dpatch/dpatch-run
-## 05_addonloader.dpatch by Jonas Eschenburg <indyjo@gmx.de>
-##
-## All lines beginning with `## DP:' are a description of the patch.
-## DP: Running build.io with the -s option will cause addon building to abort.
-
-@DPATCH@
-diff -urNad a/build.io b/build.io
---- a/build.io
-+++ b/build.io
-@@ -7,11 +7,35 @@ Directory fileNamedOrNil := method(path,
- 
- Directory setCurrentWorkingDirectory(launchPath)
- 
-+arguments := args slice(1)
-+
-+strictMode := false
-+addonToBuild := nil
-+command := nil
-+
-+while(arguments isNotEmpty,
-+    if(arguments at(0) == "-s") then(
-+        strictMode = true
-+        arguments removeFirst
-+    ) elseif (arguments at(0) == "-a") then(
-+        addonToBuild = arguments at(1)
-+        arguments = arguments slice(2)
-+    ) else(
-+        command = arguments at(0)
-+        break
-+    )
-+)
-+
- project := Project clone
--if(args at(1) == "-a") then(
--    project buildAddon(args at(2))
--) elseif (args at(1)) then(
--	project clone doString(args at(1))
--) else (
--	project clone build
-+project setStrictMode(strictMode)
-+
-+if (addonToBuild isNil) then(
-+    if (command isNil) then(
-+        project build
-+    ) else(
-+        project doString(command)
-+    )
-+) else(
-+    project buildAddon(addonToBuild)
- )
-+
-diff -urNad a/build/AddonBuilder.io b/build/AddonBuilder.io
---- a/build/AddonBuilder.io
-+++ b/build/AddonBuilder.io
-@@ -189,8 +189,14 @@ AddonBuilder := Object clone do(
- 		module
- 	)
- 
--	systemCall := method(s,
--		if(trySystemCall(s) == 256, System exit(1))
-+	systemCall := method(s, strictMode,
-+		retval := trySystemCall(s)
-+		if(retval == 256, System exit(1))
-+		if(strictMode and retval != 0,
-+			"Error while executing '#{s}': exit code was #{retval}." interpolate println
-+			"Aborting because strict mode is set." println
-+			System exit(1)
-+		)
- 	)
- 
- 	trySystemCall := method(s,
-@@ -231,7 +237,7 @@ AddonBuilder := Object clone do(
- 		includePaths
- 	)
- 
--	build := method(options,
-+	build := method(options, strictMode,
- 		writeln(("--- " .. folder name .. " ") alignLeft(79, "-"))
- 		writeln("build.io: Entering directory `", folder path, "'")
- 		mkdir("_build/headers")
-@@ -259,21 +265,21 @@ AddonBuilder := Object clone do(
-                                     s = s .. "_ADDON "
-                                 )
- 				s = s .. "-c " .. ccOutFlag .. "_build/objs/" .. obj .. " source/" .. f name
--				systemCall(s)
-+				systemCall(s, strictMode)
- 			)
- 		)
- 
--		buildLib
--		buildDynLib
-+		buildLib(strictMode)
-+		buildDynLib(strictMode)
- 		if(platform == "windows", embedManifest)
- 		writeln("build.io: Leaving directory `", folder path, "'")
- 		writeln
- 	)
- 	
--	buildLib := method(
-+	buildLib := method(strictMode,
- 		mkdir("_build/lib")
--		systemCall(ar .. " " .. arFlags ..  "_build/lib/" .. libName .. " _build/objs/*.o")
--                if (ranlib != nil, systemCall(ranlib .. " _build/lib/" .. libName))
-+		systemCall(ar .. " " .. arFlags ..  "_build/lib/" .. libName .. " _build/objs/*.o", strictMode)
-+		if (ranlib != nil, systemCall(ranlib .. " _build/lib/" .. libName, strictMode))
- 	)
- 
- 	dllSuffix := method(
-@@ -296,7 +302,7 @@ AddonBuilder := Object clone do(
-             )
-         )
- 
--	buildDynLib := method(
-+	buildDynLib := method(strictMode,
- 		mkdir("_build/dll")
- 
- 		links := depends addons map(b, linkDirPathFlag .. "../" .. b .. "/_build/dll")
-@@ -323,7 +329,8 @@ AddonBuilder := Object clone do(
- 			s := " -install_name " .. System installPrefix .. "/lib/io/addons/" .. self name .. "/_build/dll/" .. libname
- 		)
- 
--		systemCall(linkdll .. " " .. cflags .. " " .. dllCommand .. " " .. s .. " " .. linkOutFlag .. "_build/dll/" .. libname .. " _build/objs/*.o" .. " " .. links join(" "))
-+		command := linkdll .. " " .. cflags .. " " .. dllCommand .. " " .. s .. " " .. linkOutFlag .. "_build/dll/" .. libname .. " _build/objs/*.o" .. " " .. links join(" ")
-+		systemCall(command, strictMode)
- 	)
- 
- 	embedManifest := method(
-diff -urNad a/build/Project.io b/build/Project.io
---- a/build/Project.io
-+++ b/build/Project.io
-@@ -2,6 +2,7 @@ Project := Object clone do(
- 	cc  := method(System getenv("CC")  ifNilEval(return "cc"))
- 	cxx := method(System getenv("CXX") ifNilEval(return "g++"))
- 	platform := System platform split at(0) asLowercase
-+	newSlot("strictMode", false)
- 
- 	systemCall := method(s,
- 		r := trySystemCall(s)
-@@ -31,7 +32,7 @@ Project := Object clone do(
- 	)
- 
-     buildAddon := method(name,
--        addons detect(addon, addon name == name) build(options)
-+        addons detect(addon, addon name == name) build(options, strictMode)
-     )
- 
- 	availableAddon := method(addon,
-@@ -97,7 +98,7 @@ Project := Object clone do(
- 	buildAddons := method(
- 		writeln("\n--- building addons ---\n")
- 
--		orderedAddons foreach(build(options))
-+		orderedAddons foreach(build(options, strictMode))
- 		self
- 	)
rmfile ./debian/patches/add-strict-mode-option-to-build.io.dpatch
}
