(zilch lang rust cargo): parse cfg values at runtime
This commit is contained in:
parent
9f23179d46
commit
054b320f27
3 changed files with 34 additions and 37 deletions
|
|
@ -9,6 +9,7 @@
|
|||
(chicken foreign)
|
||||
(srfi 4) (srfi 128) (srfi 146) (srfi 152) (srfi 207)
|
||||
(zilch lang rust registry) (zilch lang rust) (zilch lang rust cfg)
|
||||
(zilch lang rust cfg)
|
||||
(zilch lang go vfs))
|
||||
|
||||
(export
|
||||
|
|
@ -36,6 +37,8 @@
|
|||
<cargo-workspace> make-cargo-workspace cargo-workspace?
|
||||
cargo-workspace-members cargo-workspace-exclude cargo-workspace-dependencies
|
||||
|
||||
cfg-values
|
||||
|
||||
parse-cargo-toml)
|
||||
|
||||
(begin
|
||||
|
|
@ -182,45 +185,28 @@
|
|||
(cargo-workspace-exclude entry)
|
||||
(cargo-workspace-dependencies entry)))
|
||||
|
||||
; TODO(puck): aaaa
|
||||
(foreign-declare "#include \"cfgfetch_source.h\"")
|
||||
(define cfgfetch-bin
|
||||
(cdar
|
||||
(call-rustc
|
||||
(zfile (foreign-value "cfgfetch_source" nonnull-c-string)) '()
|
||||
#:codegen-flags (cons "linker" (force linker))
|
||||
#:crate-type 'bin
|
||||
#:crate-name "cfgfetch"
|
||||
#:edition "2021"
|
||||
#:emits '(#:link #t))))
|
||||
|
||||
(define cfg-target "x86_64-unknown-linux-gnu")
|
||||
(define (read-cfg-value port rest)
|
||||
(define line (read-line port))
|
||||
(if (eof-object? line)
|
||||
rest
|
||||
(let* ((line (cfg-parse line)))
|
||||
(read-cfg-value port (cons (cdr line) rest)))))
|
||||
|
||||
(define cfg-values
|
||||
'(( "debug_assertions" . #f)
|
||||
( "fmt_debug" . "full")
|
||||
( "overflow_checks" . #f)
|
||||
( "panic" . "unwind")
|
||||
( "relocation_model" . "pic")
|
||||
( "target_abi" . "")
|
||||
( "target_arch" . "x86_64")
|
||||
( "target_endian" . "little")
|
||||
( "target_env" . "gnu")
|
||||
( "target_family" . "unix")
|
||||
( "target_feature" . "fxsr")
|
||||
( "target_feature" . "sse")
|
||||
( "target_feature" . "sse2")
|
||||
( "target_has_atomic" . #f)
|
||||
( "target_has_atomic" . "16")
|
||||
( "target_has_atomic" . "32")
|
||||
( "target_has_atomic" . "64")
|
||||
( "target_has_atomic" . "8")
|
||||
( "target_has_atomic" . "ptr")
|
||||
( "target_has_atomic_equal_alignment" . "16")
|
||||
( "target_has_atomic_equal_alignment" . "32")
|
||||
( "target_has_atomic_equal_alignment" . "64")
|
||||
( "target_has_atomic_equal_alignment" . "8")
|
||||
( "target_has_atomic_equal_alignment" . "ptr")
|
||||
( "target_has_atomic_load_store" . #f)
|
||||
( "target_has_atomic_load_store" . "16")
|
||||
( "target_has_atomic_load_store" . "32")
|
||||
( "target_has_atomic_load_store" . "64")
|
||||
( "target_has_atomic_load_store" . "8")
|
||||
( "target_has_atomic_load_store" . "ptr")
|
||||
( "target_os" . "linux")
|
||||
( "target_pointer_width" . "64")
|
||||
( "target_thread_local" . #f)
|
||||
( "target_vendor" . "unknown")
|
||||
( "ub_checks" . #f)
|
||||
( "unix" . #f)))
|
||||
(let ((vals (cdar (store-path-for-ca-drv* "cfg-values" "x86_64-linux" #~(#$cfgfetch-bin) #~(("rustc" . ,(string-append #$rustc "/bin/rustc"))) '("out")))))
|
||||
(call-with-port (store-path-open vals) (lambda (p) (read-cfg-value p '())))))
|
||||
|
||||
(define (cratify-name name)
|
||||
; NOTE! string-map _has_ to return a char. non-chars are mistreated and cause memory corruption.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue