Skip to content

Commit

Permalink
Enable macros to use certain things from the OS module when the targe…
Browse files Browse the repository at this point in the history
…t OS is not supported (#24639)

Essentially this PR removes the `{.error.}` pragmas littered around in
the OS module and submodules which prevents them from being imported if
the target OS is not supported. This made it impossible to use certain
supported features of the OS module in macros from a supported host OS.
Instead of the `{.error.}` pragmas the `oscommon` module now has a
constant `supportedSystem` which is false in the cases where the
`{.error.}` pragmas where generated. All procedures which can't be run
by macros is also not declared when `supportedSystem` is false.

It would be possible to create dummy versions of the omitted functions
with an `{.error.}` pragma that would trigger upon their use, but this
is currently not done.

This properly fixes #19414

(cherry picked from commit 1f9cac1)
  • Loading branch information
PMunch authored and narimiran committed Jan 27, 2025
1 parent ae011ea commit c2b8257
Show file tree
Hide file tree
Showing 9 changed files with 768 additions and 767 deletions.
2 changes: 1 addition & 1 deletion compiler/vmops.nim
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ proc registerAdditionalOps*(c: PCtx) =
wrap2si(readLines, ioop)
systemop getCurrentExceptionMsg
systemop getCurrentException
registerCallback c, "stdlib.osdirs.staticWalkDir", proc (a: VmArgs) {.nimcall.} =
registerCallback c, "stdlib.staticos.staticWalkDir", proc (a: VmArgs) {.nimcall.} =
setResult(a, staticWalkDirImpl(getString(a, 0), getBool(a, 1)))
registerCallback c, "stdlib.staticos.staticDirExists", proc (a: VmArgs) {.nimcall.} =
setResult(a, dirExists(getString(a, 0)))
Expand Down
Loading

0 comments on commit c2b8257

Please sign in to comment.