-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
117 lines (96 loc) · 3.29 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const root_source_file = b.path("src/lib.zig");
// Module
const astroz_mod = b.addModule("astroz", .{
.target = target,
.optimize = optimize,
.root_source_file = root_source_file,
});
// Library
const lib_step = b.step("lib", "Install library");
const lib = b.addStaticLibrary(.{
.name = "astroz",
.target = target,
.optimize = optimize,
.root_source_file = root_source_file,
});
const zigimg_dependency = b.dependency("zigimg", .{
.target = target,
.optimize = optimize,
});
lib.root_module.addImport("zigimg", zigimg_dependency.module("zigimg"));
astroz_mod.addImport("zigimg", zigimg_dependency.module("zigimg"));
const cfitsio_dep = b.dependency("cfitsio", .{
.target = target,
.optimize = optimize,
});
lib.root_module.addImport("cfitsio", cfitsio_dep.module("cfitsio"));
astroz_mod.addImport("cfitsio", cfitsio_dep.module("cfitsio"));
const lib_install = b.addInstallArtifact(lib, .{});
lib_step.dependOn(&lib_install.step);
b.default_step.dependOn(lib_step);
// Documentation
const doc_step = b.step("doc", "Emit documentation");
const doc_install = b.addInstallDirectory(.{
.install_dir = .prefix,
.install_subdir = "doc",
.source_dir = lib.getEmittedDocs(),
});
doc_step.dependOn(&doc_install.step);
b.default_step.dependOn(doc_step);
// Example suite
const examples_step = b.step("example", "Run example suite");
inline for (EXAMPLE_NAMES) |EXAMPLE_NAME| {
const example = b.addExecutable(.{
.name = EXAMPLE_NAME,
.target = target,
.optimize = optimize,
.root_source_file = b.path("examples/" ++ EXAMPLE_NAME ++ ".zig"),
});
example.root_module.addImport("astroz", astroz_mod);
const example_run = b.addRunArtifact(example);
examples_step.dependOn(&example_run.step);
}
b.default_step.dependOn(examples_step);
// Test suite
const tests_step = b.step("test", "Run test suite");
const tests = b.addTest(.{
.target = target,
.root_source_file = root_source_file,
});
tests.root_module.addImport("zigimg", zigimg_dependency.module("zigimg"));
tests.root_module.addImport("cfitsio", cfitsio_dep.module("cfitsio"));
const tests_run = b.addRunArtifact(tests);
tests_step.dependOn(&tests_run.step);
b.default_step.dependOn(tests_step);
// Formatting checks
const fmt_step = b.step("fmt", "Run formatting checks");
const fmt = b.addFmt(.{
.paths = &.{
"src/",
"build.zig",
},
.check = true,
});
fmt_step.dependOn(&fmt.step);
b.default_step.dependOn(fmt_step);
}
const EXAMPLE_NAMES = &.{
"create_ccsds_packet_config",
"create_ccsds_packet",
"orbit_phase_change",
"orbit_plane_change",
"orbit_prop_impulse",
"orbit_prop",
"parse_ccsds_file_sync",
"parse_ccsds",
"parse_tle",
"parse_vita49_callback",
"parse_vita49",
"precess_star",
"simple_spacecraft_orientation",
"parse_fits_image",
};