| ... | ... | @@ -414,82 +414,123 @@ pub const Builder = struct { |
| 414 | 414 | self.h_dir = self.pathJoin(&h_list); |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | | fn convertOptionalPathToFileSource(path: ?[]const u8) ?FileSource { |
| 418 | | return if (path) |p| |
| 419 | | FileSource{ .path = p } |
| 420 | | else |
| 421 | | null; |
| 422 | | } |
| 423 | | |
| 424 | | pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep { |
| 425 | | return addExecutableSource(self, name, convertOptionalPathToFileSource(root_src)); |
| 426 | | } |
| 427 | | |
| 428 | | pub fn addExecutableSource(builder: *Builder, name: []const u8, root_src: ?FileSource) *LibExeObjStep { |
| 429 | | return LibExeObjStep.createExecutable(builder, name, root_src); |
| 430 | | } |
| 431 | | |
| 432 | 417 | pub fn addOptions(self: *Builder) *OptionsStep { |
| 433 | 418 | return OptionsStep.create(self); |
| 434 | 419 | } |
| 435 | 420 | |
| 436 | | pub fn addObject(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep { |
| 437 | | return addObjectSource(self, name, convertOptionalPathToFileSource(root_src)); |
| 438 | | } |
| 439 | | |
| 440 | | pub fn addObjectSource(builder: *Builder, name: []const u8, root_src: ?FileSource) *LibExeObjStep { |
| 441 | | return LibExeObjStep.createObject(builder, name, root_src); |
| 442 | | } |
| 443 | | |
| 444 | | pub fn addSharedLibrary( |
| 445 | | self: *Builder, |
| 421 | pub const ExecutableOptions = struct { |
| 446 | 422 | name: []const u8, |
| 447 | | root_src: ?[]const u8, |
| 448 | | kind: LibExeObjStep.SharedLibKind, |
| 449 | | ) *LibExeObjStep { |
| 450 | | return addSharedLibrarySource(self, name, convertOptionalPathToFileSource(root_src), kind); |
| 423 | root_source_file: ?FileSource, |
| 424 | version: ?std.builtin.Version = null, |
| 425 | target: CrossTarget, |
| 426 | optimize: std.builtin.Mode, |
| 427 | linkage: ?LibExeObjStep.Linkage = null, |
| 428 | }; |
| 429 | |
| 430 | pub fn addExecutable(b: *Builder, options: ExecutableOptions) *LibExeObjStep { |
| 431 | return LibExeObjStep.create(b, .{ |
| 432 | .name = options.name, |
| 433 | .root_source_file = options.root_source_file, |
| 434 | .version = options.version, |
| 435 | .target = options.target, |
| 436 | .optimize = options.optimize, |
| 437 | .kind = .exe, |
| 438 | .linkage = options.linkage, |
| 439 | .version = options.version, |
| 440 | }); |
| 451 | 441 | } |
| 452 | 442 | |
| 453 | | pub fn addSharedLibrarySource( |
| 454 | | self: *Builder, |
| 443 | pub const ObjectOptions = struct { |
| 455 | 444 | name: []const u8, |
| 456 | | root_src: ?FileSource, |
| 457 | | kind: LibExeObjStep.SharedLibKind, |
| 458 | | ) *LibExeObjStep { |
| 459 | | return LibExeObjStep.createSharedLibrary(self, name, root_src, kind); |
| 460 | | } |
| 445 | root_source_file: ?FileSource, |
| 446 | target: CrossTarget, |
| 447 | optimize: std.builtin.Mode, |
| 448 | }; |
| 461 | 449 | |
| 462 | | pub fn addStaticLibrary(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep { |
| 463 | | return addStaticLibrarySource(self, name, convertOptionalPathToFileSource(root_src)); |
| 450 | pub fn addObject(b: *Builder, options: ObjectOptions) *LibExeObjStep { |
| 451 | return LibExeObjStep.create(b, .{ |
| 452 | .name = options.name, |
| 453 | .root_source_file = options.root_source_file, |
| 454 | .target = options.target, |
| 455 | .optimize = options.optimize, |
| 456 | .kind = .obj, |
| 457 | }); |
| 464 | 458 | } |
| 465 | 459 | |
| 466 | | pub fn addStaticLibrarySource(self: *Builder, name: []const u8, root_src: ?FileSource) *LibExeObjStep { |
| 467 | | return LibExeObjStep.createStaticLibrary(self, name, root_src); |
| 468 | | } |
| 460 | pub const SharedLibraryOptions = struct { |
| 461 | name: []const u8, |
| 462 | root_source_file: ?FileSource, |
| 463 | version: ?std.builtin.Version = null, |
| 464 | target: CrossTarget, |
| 465 | optimize: std.builtin.Mode, |
| 466 | }; |
| 469 | 467 | |
| 470 | | pub fn addTest(self: *Builder, root_src: []const u8) *LibExeObjStep { |
| 471 | | return LibExeObjStep.createTest(self, "test", .{ .path = root_src }); |
| 468 | pub fn addSharedLibrary(b: *Builder, options: SharedLibraryOptions) *LibExeObjStep { |
| 469 | return LibExeObjStep.create(b, .{ |
| 470 | .name = options.name, |
| 471 | .root_source_file = options.root_source_file, |
| 472 | .kind = .lib, |
| 473 | .linkage = .dynamic, |
| 474 | .version = options.version, |
| 475 | .target = options.target, |
| 476 | .optimize = options.optimize, |
| 477 | }); |
| 472 | 478 | } |
| 473 | 479 | |
| 474 | | pub fn addTestSource(self: *Builder, root_src: FileSource) *LibExeObjStep { |
| 475 | | return LibExeObjStep.createTest(self, "test", root_src.dupe(self)); |
| 476 | | } |
| 480 | pub const StaticLibraryOptions = struct { |
| 481 | name: []const u8, |
| 482 | root_source_file: ?FileSource = null, |
| 483 | target: CrossTarget, |
| 484 | optimize: std.builtin.Mode, |
| 485 | version: ?std.builtin.Version = null, |
| 486 | }; |
| 477 | 487 | |
| 478 | | pub fn addTestExe(self: *Builder, name: []const u8, root_src: []const u8) *LibExeObjStep { |
| 479 | | return LibExeObjStep.createTestExe(self, name, .{ .path = root_src }); |
| 480 | | } |
| 488 | pub fn addStaticLibrary(b: *Builder, options: StaticLibraryOptions) *LibExeObjStep { |
| 489 | return LibExeObjStep.create(b, .{ |
| 490 | .name = options.name, |
| 491 | .root_source_file = options.root_source_file, |
| 492 | .kind = .lib, |
| 493 | .linkage = .static, |
| 494 | .version = options.version, |
| 495 | .target = options.target, |
| 496 | .optimize = options.optimize, |
| 497 | }); |
| 498 | } |
| 499 | |
| 500 | pub const TestOptions = struct { |
| 501 | name: []const u8 = "test", |
| 502 | kind: LibExeObjStep.Kind = .@"test", |
| 503 | root_source_file: FileSource, |
| 504 | target: CrossTarget, |
| 505 | optimize: std.builtin.Mode, |
| 506 | version: ?std.builtin.Version = null, |
| 507 | }; |
| 481 | 508 | |
| 482 | | pub fn addTestExeSource(self: *Builder, name: []const u8, root_src: FileSource) *LibExeObjStep { |
| 483 | | return LibExeObjStep.createTestExe(self, name, root_src.dupe(self)); |
| 509 | pub fn addTest(b: *Builder, options: TestOptions) *LibExeObjStep { |
| 510 | return LibExeObjStep.create(b, .{ |
| 511 | .name = options.name, |
| 512 | .kind = options.kind, |
| 513 | .root_source_file = options.root_source_file, |
| 514 | .target = options.target, |
| 515 | .optimize = options.optimize, |
| 516 | }); |
| 484 | 517 | } |
| 485 | 518 | |
| 486 | | pub fn addAssemble(self: *Builder, name: []const u8, src: []const u8) *LibExeObjStep { |
| 487 | | return addAssembleSource(self, name, .{ .path = src }); |
| 488 | | } |
| 519 | pub const AssemblyOptions = struct { |
| 520 | name: []const u8, |
| 521 | source_file: FileSource, |
| 522 | target: CrossTarget, |
| 523 | optimize: std.builtin.Mode, |
| 524 | }; |
| 489 | 525 | |
| 490 | | pub fn addAssembleSource(self: *Builder, name: []const u8, src: FileSource) *LibExeObjStep { |
| 491 | | const obj_step = LibExeObjStep.createObject(self, name, null); |
| 492 | | obj_step.addAssemblyFileSource(src.dupe(self)); |
| 526 | pub fn addAssembly(b: *Builder, options: AssemblyOptions) *LibExeObjStep { |
| 527 | const obj_step = LibExeObjStep.create(b, .{ |
| 528 | .name = options.name, |
| 529 | .root_source_file = null, |
| 530 | .target = options.target, |
| 531 | .optimize = options.optimize, |
| 532 | }); |
| 533 | obj_step.addAssemblyFileSource(options.source_file.dupe(b)); |
| 493 | 534 | return obj_step; |
| 494 | 535 | } |
| 495 | 536 | |
| ... | ... | @@ -593,17 +634,6 @@ pub const Builder = struct { |
| 593 | 634 | return TranslateCStep.create(self, source.dupe(self)); |
| 594 | 635 | } |
| 595 | 636 | |
| 596 | | pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) LibExeObjStep.SharedLibKind { |
| 597 | | _ = self; |
| 598 | | return .{ |
| 599 | | .versioned = .{ |
| 600 | | .major = major, |
| 601 | | .minor = minor, |
| 602 | | .patch = patch, |
| 603 | | }, |
| 604 | | }; |
| 605 | | } |
| 606 | | |
| 607 | 637 | pub fn make(self: *Builder, step_names: []const []const u8) !void { |
| 608 | 638 | try self.makePath(self.cache_root); |
| 609 | 639 | |