Hi all -
I’m having problems with the addSourceFiles statement in the build system.
I’ve done web searches and tried to find some info in the docs, but I find the documentation to be difficult to follow.
Anyway - here’s my build file -
// build.zig
// The build file for Rome.
// This code is released to the public domain.
// "Share and enjoy....." :)
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "rome_compiler" ,
.root_source_file = b.path("src/main.zig") ,
.target = target,
.optimize = optimize,
});
b.installArtifact(exe);
// Add source files
exe.addSourceFiles(.{
.files = &.{
"src/lexer/lexer.zig",
"src/parser/parser.zig",
"src/ast/ast.zig",
"src/semantic_analyzer/semantic_analyzer.zig",
"src/ir/ir.zig",
"src/codegen/codegen.zig",
},
});
// exe.addSourceFile("src/lexer/lexer.zig");
// exe.addSourceFile("src/parser/parser.zig");
// exe.addSourceFile("src/ast/ast.zig");
// exe.addSourceFile("src/semantic_analyzer/semantic_analyzer.zig");
// exe.addSourceFile("src/ir/ir.zig");
// exe.addSourceFile("src/codegen/code_generator.zig");
exe.install();
}
When I run the build, I get this -
andy@obsidian:~/rome$ zig build
/home/andy/rome/build.zig:28:10: error: no field or member function named 'addSourceFiles' in 'Build.Step.Compile'
exe.addSourceFiles(.{
~~~^~~~~~~~~~~~~~~
/home/andy/zig/lib/std/Build/Step/Compile.zig:1:1: note: struct declared here
const builtin = @import("builtin");
^~~~~
referenced by:
runBuild__anon_8818: /home/andy/zig/lib/std/Build.zig:2116:27
main: /home/andy/zig/lib/compiler/build_runner.zig:301:29
remaining reference traces hidden; use '-freference-trace' to see all reference traces
andy@obsidian:~/rome$
When I saw that, I looked at the docs but they’re difficult to take in.
I contrast them to the Python docs which are really well laid-out and easy to find any aspect of the language in. ( No offense meant there - just an example of a language which does that well. )
So, I’m hoping that someone can point out the correct syntax for addSourceFiles.
Many thanks in advance -
- mooseman