Support for Windows cross-compilation from Linux (#295)

Since `DirSep` matches the default separator of the target OS, it's
not suitable for performing path operations during compile-time on
the host OS.

The particular fix here solves the issue for cross-compiling a Windows
build from a Linux host, but Nim seems to need a more general solution
for detecting the host OS during compilation, so a host OS specific
separator can be used in paths derived from `currentSourcePath`.
This commit is contained in:
zah 2023-04-28 13:31:44 +03:00 committed by GitHub
parent f014ea44a5
commit 37048e87de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -5,14 +5,14 @@
import import
std/[strformat, strutils] std/[strformat, strutils]
from os import DirSep from os import DirSep, AltSep
const const
# FIELD_ELEMENTS_PER_BLOB is overrideable from # FIELD_ELEMENTS_PER_BLOB is overrideable from
# compiler switch -d: or --define: # compiler switch -d: or --define:
FIELD_ELEMENTS_PER_BLOB* {.intdefine.} = 4096 FIELD_ELEMENTS_PER_BLOB* {.intdefine.} = 4096
# kzgPath: c-kzg-4844 project path, removing 3 last elem # kzgPath: c-kzg-4844 project path, removing 3 last elem
kzgPath = currentSourcePath.rsplit(DirSep, 3)[0] & "/" kzgPath = currentSourcePath.rsplit({DirSep, AltSep}, 3)[0] & "/"
blstPath = kzgPath & "blst/" blstPath = kzgPath & "blst/"
srcPath = kzgPath & "src/" srcPath = kzgPath & "src/"
bindingsPath = blstPath & "bindings" bindingsPath = blstPath & "bindings"
@ -65,14 +65,14 @@ type
# An array of 48 bytes. Represents an untrusted # An array of 48 bytes. Represents an untrusted
# (potentially invalid) commitment/proof. # (potentially invalid) commitment/proof.
KzgBytes48* = array[48, byte] KzgBytes48* = array[48, byte]
# An array of 32 bytes. Represents an untrusted # An array of 32 bytes. Represents an untrusted
# (potentially invalid) field element. # (potentially invalid) field element.
KzgBytes32* = array[32, byte] KzgBytes32* = array[32, byte]
# A trusted (valid) KZG commitment. # A trusted (valid) KZG commitment.
KzgCommitment* = KzgBytes48 KzgCommitment* = KzgBytes48
# A trusted (valid) KZG proof. # A trusted (valid) KZG proof.
KzgProof* = KzgBytes48 KzgProof* = KzgBytes48