Skip to content

Commit

Permalink
Fixes build.zig for stage2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix "xq" Queißner committed Sep 8, 2022
1 parent 2c03490 commit 2e11e56
Showing 1 changed file with 95 additions and 93 deletions.
188 changes: 95 additions & 93 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const std = @import("std");

fn sdkRoot() []const u8 {
return (std.fs.path.dirname(@src().file) orelse ".") ++ "/";
fn sdkPath(comptime suffix: []const u8) []const u8 {
if (suffix[0] != '/') @compileError("relToPath requires an absolute path!");
return comptime blk: {
const root_dir = std.fs.path.dirname(@src().file) orelse ".";
break :blk root_dir ++ suffix;
};
}

const sdk_root = sdkRoot();

const pkgs = struct {
const serve = std.build.Pkg{
.name = "serve",
Expand Down Expand Up @@ -78,7 +80,7 @@ pub fn build(b: *std.build.Builder) void {
}

pub const include_dirs = [_][]const u8{
sdk_root ++ "vendor/wolfssl",
sdkPath("/vendor/wolfssl"),
};

pub fn createWolfSSL(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.LibExeObjStep {
Expand All @@ -87,7 +89,7 @@ pub fn createWolfSSL(b: *std.build.Builder, target: std.zig.CrossTarget) *std.bu
lib.setTarget(target);
lib.addCSourceFiles(&wolfssl_sources, &wolfssl_flags);
lib.addCSourceFiles(&wolfcrypt_sources, &wolfcrypt_flags);
lib.addIncludeDir(sdk_root ++ "vendor/wolfssl/");
lib.addIncludeDir(sdkPath("/vendor/wolfssl/"));

lib.defineCMacro("TFM_TIMING_RESISTANT", null);
lib.defineCMacro("ECC_TIMING_RESISTANT", null);
Expand Down Expand Up @@ -130,97 +132,97 @@ const wolfssl_flags = [_][]const u8{
};

const wolfssl_sources = [_][]const u8{
sdk_root ++ "vendor/wolfssl/src/bio.c",
sdk_root ++ "vendor/wolfssl/src/crl.c",
sdk_root ++ "vendor/wolfssl/src/internal.c",
sdk_root ++ "vendor/wolfssl/src/keys.c",
sdk_root ++ "vendor/wolfssl/src/ocsp.c",
sdk_root ++ "vendor/wolfssl/src/sniffer.c",
sdk_root ++ "vendor/wolfssl/src/ssl.c",
sdk_root ++ "vendor/wolfssl/src/tls.c",
sdk_root ++ "vendor/wolfssl/src/tls13.c",
sdk_root ++ "vendor/wolfssl/src/wolfio.c",
sdkPath("/vendor/wolfssl/src/bio.c"),
sdkPath("/vendor/wolfssl/src/crl.c"),
sdkPath("/vendor/wolfssl/src/internal.c"),
sdkPath("/vendor/wolfssl/src/keys.c"),
sdkPath("/vendor/wolfssl/src/ocsp.c"),
sdkPath("/vendor/wolfssl/src/sniffer.c"),
sdkPath("/vendor/wolfssl/src/ssl.c"),
sdkPath("/vendor/wolfssl/src/tls.c"),
sdkPath("/vendor/wolfssl/src/tls13.c"),
sdkPath("/vendor/wolfssl/src/wolfio.c"),
};

const wolfcrypt_flags = [_][]const u8{
"-std=c89",
};
const wolfcrypt_sources = [_][]const u8{
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/aes.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/arc4.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/asm.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/asn.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/blake2b.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/blake2s.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/camellia.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/chacha.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/chacha20_poly1305.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/cmac.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/coding.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/compress.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/cpuid.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/cryptocb.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/curve448.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/curve25519.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/des3.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/dh.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/dsa.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/ecc.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/eccsi.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/ecc_fp.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/ed448.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/ed25519.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/error.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/evp.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/falcon.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/fe_448.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/fe_low_mem.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/fe_operations.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/ge_448.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/ge_low_mem.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/ge_operations.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/hash.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/hc128.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/hmac.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/idea.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/integer.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/kdf.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/logging.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/md2.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/md4.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/md5.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/memory.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/misc.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/pkcs7.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/pkcs12.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/poly1305.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/pwdbased.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/rabbit.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/random.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/rc2.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/ripemd.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/rsa.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sakke.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sha.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sha3.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sha256.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sha512.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/signature.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sp_arm32.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sp_arm64.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sp_armthumb.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sp_c32.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sp_c64.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sp_cortexm.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sp_dsp32.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sp_int.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/sp_x86_64.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/srp.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/tfm.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/wc_dsp.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/wc_encrypt.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/wc_pkcs11.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/wc_port.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/wolfevent.c",
sdk_root ++ "vendor/wolfssl/wolfcrypt/src/wolfmath.c",
sdkPath("/vendor/wolfssl/wolfcrypt/src/aes.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/arc4.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/asm.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/asn.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/blake2b.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/blake2s.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/camellia.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/chacha.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/chacha20_poly1305.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/cmac.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/coding.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/compress.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/cpuid.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/cryptocb.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/curve448.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/curve25519.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/des3.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/dh.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/dsa.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/ecc.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/eccsi.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/ecc_fp.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/ed448.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/ed25519.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/error.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/evp.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/falcon.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/fe_448.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/fe_low_mem.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/fe_operations.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/ge_448.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/ge_low_mem.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/ge_operations.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/hash.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/hc128.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/hmac.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/idea.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/integer.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/kdf.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/logging.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/md2.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/md4.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/md5.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/memory.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/misc.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/pkcs7.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/pkcs12.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/poly1305.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/pwdbased.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/rabbit.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/random.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/rc2.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/ripemd.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/rsa.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sakke.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sha.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sha3.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sha256.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sha512.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/signature.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sp_arm32.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sp_arm64.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sp_armthumb.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sp_c32.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sp_c64.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sp_cortexm.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sp_dsp32.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sp_int.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/sp_x86_64.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/srp.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/tfm.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/wc_dsp.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/wc_encrypt.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/wc_pkcs11.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/wc_port.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/wolfevent.c"),
sdkPath("/vendor/wolfssl/wolfcrypt/src/wolfmath.c"),
};

0 comments on commit 2e11e56

Please sign in to comment.