Browse Source

Added build system

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7664 8c9fc860-2736-0410-a75d-ab315db34111
eth.negelef 7 năm trước cách đây
mục cha
commit
e10c55e6c3
3 tập tin đã thay đổi với 121 bổ sung0 xóa
  1. 60 0
      tools/builds/DependencyWalker.Mod
  2. 61 0
      tools/builds/makefile
  3. BIN
      tools/builds/oberon

+ 60 - 0
tools/builds/DependencyWalker.Mod

@@ -0,0 +1,60 @@
+MODULE DependencyWalker;
+
+IMPORT Commands, Diagnostics, Files, Options, Streams, FoxBasic, FoxGlobal, FoxParser, FoxScanner, FoxSyntaxTree;
+
+PROCEDURE Process (CONST moduleName, fileExtension: ARRAY OF CHAR; diagnostics: Diagnostics.Diagnostics; writer: Streams.Writer): BOOLEAN;
+VAR reader: Streams.Reader; scanner: FoxScanner.Scanner; parser: FoxParser.Parser;
+VAR module: FoxSyntaxTree.Module; import: FoxSyntaxTree.Import; string: ARRAY 64 OF CHAR;
+BEGIN
+	reader := FoxBasic.GetFileReader (moduleName);
+	IF reader = NIL THEN diagnostics.Error (moduleName, Diagnostics.Invalid, Diagnostics.Invalid, "Failed to open module"); RETURN FALSE END;
+	scanner := FoxScanner.NewScanner (moduleName, reader, 0, diagnostics);
+	NEW (parser, scanner, diagnostics);
+	module := parser.Module ();
+	IF parser.error THEN RETURN FALSE END;
+	FoxGlobal.ModuleFileName (module.name, module.context, string);
+	writer.String (string);
+	writer.String (fileExtension);
+	writer.String (": ");
+	writer.String (moduleName);
+	import := module.moduleScope.firstImport;
+	WHILE import # NIL DO
+		IF import.moduleName # FoxGlobal.SystemName THEN
+			writer.Char (' ');
+			IF import.context # FoxSyntaxTree.invalidIdentifier THEN
+				FoxGlobal.ModuleFileName (import.moduleName, import.context, string);
+			ELSE
+				FoxGlobal.ModuleFileName (import.moduleName, module.context, string);
+			END;
+			writer.String (string);
+			writer.String (fileExtension);
+		END;
+		import := import.nextImport;
+	END;
+	writer.Ln;
+	RETURN TRUE;
+END Process;
+
+PROCEDURE Walk* (context: Commands.Context);
+VAR options : Options.Options; diagnostics : Diagnostics.StreamDiagnostics;
+VAR fileExtension: Options.Parameter; moduleName: Files.FileName;
+BEGIN
+	NEW (options);
+	options.Add ('e', "fileExtension", Options.String);
+	IF ~options.Parse (context.arg, context.error) THEN
+		context.result := Commands.CommandParseError; RETURN;
+	END;
+	IF ~options.GetString ("fileExtension", fileExtension) THEN fileExtension := ".Sym" END;
+
+	NEW (diagnostics, context.error);
+	LOOP
+		context.arg.SkipWhitespace;
+		context.arg.String (moduleName);
+		IF moduleName = "" THEN EXIT END;
+		IF ~Process (moduleName, fileExtension, diagnostics, context.out) THEN
+			context.result := Commands.CommandError; RETURN;
+		END;
+	END;
+END Walk;
+
+END DependencyWalker.

+ 61 - 0
tools/builds/makefile

@@ -0,0 +1,61 @@
+all: build
+
+.PHONY: all compiler execution compilation execution clean
+MAKEFLAGS += --no-builtin-rules --no-builtin-variables
+.SUFFIXES: # delete the default suffixes
+
+tool := $(if $(wildcard build), ./build, ./oberon)
+
+# module dependencies
+
+modules: source/Release.Tool
+	@env AOSPATH=source ./oberon Release.Build --list Linux32G | tr -d '\r' | grep "^[^ ]\+\.Mod\s" | tr -d ' ' > $@
+
+dependencies: modules source/*.Mod
+	@./oberon DependencyWalker.Walk --fileExtension=.GofU $(addprefix source/, $(shell sort -u modules)) DependencyWalker.Mod | tr -d '\r' | grep "^.\+\.GofU:" > $@
+
+-include dependencies
+Trace.GofU Streams.GofU: Runtime.GofU
+FoxArrayBase.GofU: ComplexNumbers.GofU
+
+%.GofU:
+	@$(tool) compile $(if $<, $<, $(error no target for $@))
+
+# targets
+
+build: $(addsuffix .GofU, Runtime Trace Glue Unix Machine Heaps Modules Objects Streams Kernel Reflection KernelLog TrapWriters Commands Pipes StdIO Traps Files UnixFiles BitSets StringPool ObjectFile Diagnostics Reals Clock Dates Strings GenericLinker GenericLoader WMRectangles CLUTs Plugins Displays Raster UTF8Strings WMRasterScale SoundDevices XMLObjects DynamicStrings XML XMLScanner XMLParser Configuration Inflate CRC Unzip WMEvents Locks FP1616 Texts Archives Codecs WMGraphics WMDefaultFont StdIOShell Shell Options ProcessInfo0 ProcessInfo SystemVersion SystemTools Debugging FoxBasic FoxScanner FoxSyntaxTree FoxGlobal FoxParser FoxFingerPrinter FoxPrintout FoxFormats FoxSemanticChecker FoxBackend FoxFrontend Compiler FoxOberonFrontend FoxSections FoxBinaryCode FoxIntermediateCode FoxInterfaceComparison FoxTextualSymbolFile FoxIntermediateBackend FoxAMD64InstructionSet FoxAMD64Assembler FoxBinarySymbolFile FoxBinaryObjectFile FoxCodeGenerators FoxAMDBackend FoxGenericObjectFile Math MathL ComplexNumbers FoxArrayBase StaticLinker DependencyWalker Localization Repositories UnicodeProperties TextUtilities ReleaseThreadPool Zlib ZlibBuffers ZlibInflate ZlibReaders ZlibDeflate ZlibWriters Zip CompilerInterface Release)
+	@$(tool) StaticLinker.Link -p=Linux32G --fileName=$@ Runtime Traps UnixFiles GenericLoader WMDefaultFont StdIOShell Shell SystemTools Compiler FoxOberonFrontend FoxAMDBackend FoxGenericObjectFile FoxArrayBase StaticLinker DependencyWalker Release && chmod +x $@
+# grep ":processing\s$" build.log | grep "^[^:]\+" -o | tr '\n' ' '
+
+compiler: $(addsuffix .GofU, FoxA2Interface FoxActiveCells FoxAMD64Assembler FoxAMD64InstructionSet FoxAMDBackend FoxARMAssembler FoxARMBackend FoxARMInstructionSet FoxArrayBase FoxAssembler FoxBackend FoxBasic FoxBinaryCode FoxBinaryObjectFile FoxBinarySymbolFile FoxCodeGenerators Compiler FoxCSharpFrontend FoxCSharpParser FoxCSharpScanner FoxDisassembler FoxDocumentationBackend FoxDocumentationHtml FoxDocumentationParser FoxDocumentationPrinter FoxDocumentationScanner FoxDocumentationTree FoxFingerPrinter FoxFormats FoxFrontend FoxGenericObjectFile FoxGlobal FoxHardware FoxInterfaceComparison FoxIntermediateAssembler FoxIntermediateBackend FoxIntermediateCode FoxIntermediateLinker FoxIntermediateObjectFile FoxIntermediateParser FoxInterpreterBackend FoxMinosObjectFile FoxOberonFrontend FoxParser FoxPrintout FoxProfiler FoxProgTools FoxScanner FoxSections FoxSemanticChecker FoxSyntaxTree FoxTest TextCompiler FoxTextualSymbolFile FoxTranspilerBackend FoxTRMAssembler FoxTRMBackend FoxTRMInstructionSet)
+# grep "^Fox" modules | sed 's/\.Mod//g' | tr '\n' ' '
+
+compilation: Oberon.Compilation.Test.Diff
+
+Oberon.Compilation.Test.Diff: build FoxTest.GofU source/Oberon.Compilation.Test
+	@./build FoxTest.Compile source/Oberon.Compilation.Test
+
+execution: Oberon.Execution.Test.Diff
+
+Oberon.Execution.Test.Diff: build FoxTest.GofU source/Oberon.Execution.Test
+	@./build FoxTest.Compile source/Oberon.Execution.Test
+
+ifdef platform
+
+.PHONY: release
+release: $(if $(filter Linux32G Win32G, $(platform)), $(platform), $(error invalid platform))
+
+$(platform): build source/Release.Tool $(addprefix source/, $(shell env AOSPATH=source ./oberon Release.Build --list $(platform) | tr -d '\r' | grep "^[^ ]\+\.Mod\s" | tr -d ' '))
+	@rm -rf $@ && mkdir $@
+	@env AOSPATH=source ./build Release.Build --path=$@/ --build $(platform) || (rm -rf $@ && false)
+
+endif
+
+# utilities
+
+oberon: build
+	@cp build $@
+
+clean:
+	@rm -f modules dependencies build *.SymU *.GofU *.Log *.log
+	@rm -rf Linux32G Win32G

BIN
tools/builds/oberon