Skip to content

Commit

Permalink
Merge pull request #3 from ATTron/feature/sc-55
Browse files Browse the repository at this point in the history
feat: [sc-55] Astroz: create constants for the known forces
  • Loading branch information
ATTron authored Jun 25, 2024
2 parents ba64cfb + d78336f commit 2fa32fb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
25 changes: 12 additions & 13 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ pub fn build(b: *std.Build) void {
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});

const lib = b.addStaticLibrary(.{
.name = "astroz",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
_ = b.addModule("astroz", .{
.root_source_file = b.path("src/lib.zig"),
.target = target,
.optimize = optimize,
});

_ = b.addModule("astroz.ccsds", .{
.root_source_file = b.path("src/ccsds.zig"),
.target = target,
.optimize = optimize,
});

// This declares intent for the library to be installed into the standard
// location when the user invokes the "install" step (the default step when
// running `zig build`).
b.installArtifact(lib);
_ = b.addModule("astroz.constants", .{
.root_source_file = b.path("src/constants.zig"),
.target = target,
.optimize = optimize,
});

// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const lib_unit_tests = b.addTest(.{
.root_source_file = b.path("src/ccsds.zig"),
.target = target,
Expand All @@ -38,9 +40,6 @@ pub fn build(b: *std.Build) void {

const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);

// Similar to creating the run step earlier, this exposes a `test` step to
// the `zig build --help` menu, providing a way for the user to request
// running the unit tests.
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
}
12 changes: 12 additions & 0 deletions src/constants.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// gravity
pub const G = 6.6743e-11;
// sol
pub const c = 299792458;
// earth mass
pub const moe = 5.97216787e+24;
// solar mass
pub const mos = 1.49597871e+11;
// planck constant
pub const h = 6.62607015e-34;
// astronmical unit
pub const au = 1.49597871e+11;
2 changes: 2 additions & 0 deletions src/lib.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const ccsds = @import("ccsds.zig");
const constants = @import("constants.zig");

0 comments on commit 2fa32fb

Please sign in to comment.