Browse Source

Implemented legacy support for asm generation.

woollybah 10 years ago
parent
commit
b1e980a170
4 changed files with 107 additions and 16 deletions
  1. 73 5
      bmk_make.bmx
  2. 6 2
      bmk_modutil.bmx
  3. 8 4
      bmk_util.bmx
  4. 20 5
      make.bmk

+ 73 - 5
bmk_make.bmx

@@ -187,7 +187,14 @@ Type TBuildManager
 		source.bcc_opts :+ " -t " + opt_apptype
 		source.bcc_opts :+ " -t " + opt_apptype
 	
 	
 		' create bmx stages :
 		' create bmx stages :
-		Local gen:TSourceFile = CreateGenStage(source)
+		Local gen:TSourceFile
+		' for osx x86 on legacy, we need to convert asm
+		If processor.BCCVersion() = "BlitzMax" And processor.CPU() = "x86" And processor.Platform() = "macos" Then
+			Local fasm2as:TSourceFile = CreateFasm2AsStage(source)
+			gen = CreateGenStage(fasm2as)
+		Else
+			gen = CreateGenStage(source)
+		End If
 		Local link:TSourceFile = CreateLinkStage(gen)
 		Local link:TSourceFile = CreateLinkStage(gen)
 
 
 	End Method
 	End Method
@@ -247,6 +254,29 @@ Type TBuildManager
 								m.iface_time = time_(0)
 								m.iface_time = time_(0)
 					
 					
 							End If
 							End If
+
+						Case STAGE_FASM2AS
+
+							For Local s:TSourceFile = EachIn m.depsList
+								If s.requiresBuild Then
+									m.requiresBuild = True
+									Exit
+								End If
+							Next
+
+							If m.requiresBuild Or (m.time > m.obj_time Or m.iface_time < m.MaxIfaceTime()) Then
+							
+								m.requiresBuild = True
+
+								If Not opt_quiet Then
+									Print "Converting:" + StripDir(StripExt(m.obj_path) + ".s")
+								End If
+								
+								Fasm2As m.path, m.obj_path
+	
+								m.asm_time = time_(0)
+					
+							End If
 							
 							
 						Case STAGE_OBJECT
 						Case STAGE_OBJECT
 						
 						
@@ -451,9 +481,17 @@ Type TBuildManager
 							
 							
 							CalculateDependencies(s, isMod, rebuildImports)
 							CalculateDependencies(s, isMod, rebuildImports)
 							
 							
-							Local gen:TSourceFile = CreateGenStage(s)
-	
+							Local gen:TSourceFile
+							
+							' for osx x86 on legacy, we need to convert asm
+							If processor.BCCVersion() = "BlitzMax" And processor.CPU() = "x86" And processor.Platform() = "macos" Then
+								Local fasm2as:TSourceFile = CreateFasm2AsStage(s)
+								gen = CreateGenStage(fasm2as)
+							Else
+								gen = CreateGenStage(s)
+							End If
 							source.deps.Insert(gen.GetSourcePath(), gen)
 							source.deps.Insert(gen.GetSourcePath(), gen)
+	
 							If Not source.depsList Then
 							If Not source.depsList Then
 								source.depsList = New TList
 								source.depsList = New TList
 							End If
 							End If
@@ -584,7 +622,16 @@ Type TBuildManager
 			CalculateDependencies(source, True, rebuild)
 			CalculateDependencies(source, True, rebuild)
 			
 			
 			' create bmx stages :
 			' create bmx stages :
-			Local gen:TSourceFile = CreateGenStage(source)
+			Local gen:TSourceFile
+			
+			' for osx x86 on legacy, we need to convert asm
+			If processor.BCCVersion() = "BlitzMax" And processor.CPU() = "x86" And processor.Platform() = "macos" Then
+				Local fasm2as:TSourceFile = CreateFasm2AsStage(source)
+				gen = CreateGenStage(fasm2as)
+			Else
+				gen = CreateGenStage(source)
+			End If
+			
 			link = CreateLinkStage(gen)
 			link = CreateLinkStage(gen)
 		Else
 		Else
 			link = TSourceFile(sources.ValueForKey(source.arc_path))
 			link = TSourceFile(sources.ValueForKey(source.arc_path))
@@ -595,13 +642,34 @@ Type TBuildManager
 		
 		
 		Return link
 		Return link
 	End Method
 	End Method
+
+	Method CreateFasm2AsStage:TSourceFile(source:TSourceFile)
+		Local fasm:TSourceFile = New TSourceFile
+		
+		source.CopyInfo(fasm)
+		
+		fasm.deps.Insert(source.path, source)
+		fasm.stage = STAGE_FASM2AS
+		fasm.processed = True
+		fasm.depsList = New TList
+		fasm.depsList.AddLast(source)		
+
+		sources.Insert(StripExt(fasm.obj_path) + ".s", fasm)
+
+		Return fasm
+	End Method
 	
 	
 	Method CreateGenStage:TSourceFile(source:TSourceFile)
 	Method CreateGenStage:TSourceFile(source:TSourceFile)
 		Local gen:TSourceFile = New TSourceFile
 		Local gen:TSourceFile = New TSourceFile
 		
 		
 		source.CopyInfo(gen)
 		source.CopyInfo(gen)
 		
 		
-		gen.deps.Insert(source.path, source)
+		If processor.BCCVersion() = "BlitzMax" And processor.CPU() = "x86" And processor.Platform() = "macos" Then
+			gen.deps.Insert(StripExt(source.obj_path) + ".s", source)
+		Else
+			gen.deps.Insert(source.path, source)
+		End If
+		
 		gen.stage = STAGE_OBJECT
 		gen.stage = STAGE_OBJECT
 		gen.processed = True
 		gen.processed = True
 		gen.depsList = New TList
 		gen.depsList = New TList

+ 6 - 2
bmk_modutil.bmx

@@ -18,8 +18,9 @@ Const SOURCE_ASM:Int = $10
 ' etc ?
 ' etc ?
 
 
 Const STAGE_GENERATE:Int = 0
 Const STAGE_GENERATE:Int = 0
-Const STAGE_OBJECT:Int = 1
-Const STAGE_LINK:Int = 2
+Const STAGE_FASM2AS:Int = 1
+Const STAGE_OBJECT:Int = 2
+Const STAGE_LINK:Int = 3
 
 
 Type TSourceFile
 Type TSourceFile
 	Field ext$		'one of: "bmx", "i", "c", "cpp", "m", "s", "h"
 	Field ext$		'one of: "bmx", "i", "c", "cpp", "m", "s", "h"
@@ -46,6 +47,7 @@ Type TSourceFile
 	Field time:Int
 	Field time:Int
 	Field obj_time:Int
 	Field obj_time:Int
 	Field arc_time:Int
 	Field arc_time:Int
+	Field asm_time:Int
 	Field iface_time:Int
 	Field iface_time:Int
 	Field requiresBuild:Int
 	Field requiresBuild:Int
 	Field didBuild:Int
 	Field didBuild:Int
@@ -213,6 +215,8 @@ Type TSourceFile
 		Select stage
 		Select stage
 			Case STAGE_GENERATE
 			Case STAGE_GENERATE
 				p = path
 				p = path
+			Case STAGE_FASM2AS
+				p = StripExt(obj_path) + ".s"
 			Case STAGE_OBJECT
 			Case STAGE_OBJECT
 				p = StripExt(obj_path) + ".c"
 				p = StripExt(obj_path) + ".c"
 			Case STAGE_LINK
 			Case STAGE_LINK

+ 8 - 4
bmk_util.bmx

@@ -90,6 +90,10 @@ Function Assemble( src$,obj$ )
 	processor.RunCommand("assemble", [src, obj])
 	processor.RunCommand("assemble", [src, obj])
 End Function
 End Function
 
 
+Function Fasm2As( src$,obj$ )
+	processor.RunCommand("fasm2as", [src, obj])
+End Function
+
 Function CompileC( src$,obj$,opts$ )
 Function CompileC( src$,obj$,opts$ )
 	processor.RunCommand("CompileC", [src, obj, opts])
 	processor.RunCommand("CompileC", [src, obj, opts])
 End Function
 End Function
@@ -110,10 +114,10 @@ Function CompileBMX( src$,obj$,opts$ )
 ?			
 ?			
 	processor.RunCommand("CompileBMX", [src, azm, opts])
 	processor.RunCommand("CompileBMX", [src, azm, opts])
 
 
-	If processor.BCCVersion() = "BlitzMax" Then
+	'If processor.BCCVersion() = "BlitzMax" Then
 		' it would be nice to be able to call this from the script... but we need more refactoring first :-p
 		' it would be nice to be able to call this from the script... but we need more refactoring first :-p
-		Assemble azm,obj
-	End If
+	'	Assemble azm,obj
+	'End If
 End Function
 End Function
 
 
 Function CreateArc( path$ , oobjs:TList )
 Function CreateArc( path$ , oobjs:TList )
@@ -159,7 +163,7 @@ Function CreateArc( path$ , oobjs:TList )
 		Next
 		Next
 	End If
 	End If
 
 
-	If cmd And Sys( cmd )
+	If cmd And processor.MultiSys( cmd, path )
 		DeleteFile path
 		DeleteFile path
 		Throw "Build Error: Failed to create archive "+path
 		Throw "Build Error: Failed to create archive "+path
 	EndIf
 	EndIf

+ 20 - 5
make.bmk

@@ -72,16 +72,31 @@
 		bmk.ThrowNew("Build Error: failed to compile " .. src)
 		bmk.ThrowNew("Build Error: failed to compile " .. src)
 	end
 	end
 
 
+	#if bmk.Platform() == "macos" and bmk.CPU() == "x86" and bmk.BCCVersion() == "BlitzMax" then
+	#	cmd = bmk.Quote(utils.BlitzMaxPath() .. "/bin/fasm2as") .. " " .. bmk.Quote(azm)
+	#		if bmk.Sys( cmd ) ~= 0 then
+	#			bmk.ThrowNew("Fasm2as failed - please contact BRL!")
+	#	end
+	#end
+
+	# TODO : we can't call another generated function from here... so we'd need to make sure this is called elsewhere.
+	#assemble(nil, azm, obj)
+@end
+
+@define fasm2as
+	local src = nvl(arg1, %infile%)
+	local obj = nvl(arg2, %outfile%)
+
+	local azm = sys.StripExt(obj) .. ".s"
+
 	if bmk.Platform() == "macos" and bmk.CPU() == "x86" and bmk.BCCVersion() == "BlitzMax" then
 	if bmk.Platform() == "macos" and bmk.CPU() == "x86" and bmk.BCCVersion() == "BlitzMax" then
 		cmd = bmk.Quote(utils.BlitzMaxPath() .. "/bin/fasm2as") .. " " .. bmk.Quote(azm)
 		cmd = bmk.Quote(utils.BlitzMaxPath() .. "/bin/fasm2as") .. " " .. bmk.Quote(azm)
-			if bmk.Sys( cmd ) ~= 0 then
-				bmk.ThrowNew("Fasm2as failed - please contact BRL!")
+		if bmk.MultiSys( cmd ) ~= 0 then
+			bmk.ThrowNew("Fasm2as failed - please contact BRL!")
 		end
 		end
 	end
 	end
 
 
-	# TODO : we can't call another generated function from here... so we'd need to make sure this is called elsewhere.
-	#assemble(nil, azm, obj)
-@end
+@end 
 
 
 @define compileC
 @define compileC
 	local src = nvl(arg1, %infile%)
 	local src = nvl(arg1, %infile%)