Skip to content

Commit b3d550d

Browse files
gh-90: Update search paths.
1 parent 2e47880 commit b3d550d

File tree

21 files changed

+81
-98
lines changed

21 files changed

+81
-98
lines changed

build.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<#
22
build.ps1
33
Compiles the interpreter in a temporary directory and copies the resulting EXE
4-
back into this repo. Also discovers extension C sources under stdext/ and stdlib/
4+
back into this repo. Also discovers extension C sources under ext/ and lib/
55
and compiles each one into a dynamic library next to its source file.
66
77
Requires: run from a Developer Command Prompt for Visual Studio where cl.exe is on PATH.
@@ -12,8 +12,8 @@ Usage (from Prefix-C folder):
1212
$script = Split-Path -Parent $MyInvocation.MyCommand.Definition
1313
$src = Join-Path $script "src"
1414
$extRoots = @(
15-
(Join-Path $script "stdext"),
16-
(Join-Path $script "stdlib"),
15+
(Join-Path $script "ext"),
16+
(Join-Path $script "lib"),
1717
(Join-Path $script "tests")
1818
)
1919

@@ -76,7 +76,7 @@ try {
7676
}
7777

7878
if ($extSources.Count -eq 0) {
79-
Write-Host "No extension C sources found under stdext/ or stdlib/."
79+
Write-Host "No extension C sources found under ext/, lib/"
8080
} else {
8181
Write-Host "Found $($extSources.Count) extension source file(s)."
8282
}
@@ -92,7 +92,7 @@ try {
9292
Push-Location $extBuildDir
9393
try {
9494
$extArgs = @(
95-
"/std:c17", "/Gd", "/O2", "/W4", "/WX", "/nologo", "/LD",
95+
"/std:c17", "/Gd", "/O2", "/W4", "/WX", "/nologo", "/LD", "/LTCG",
9696
"/I$src",
9797
"/Fe:$extOutName",
9898
$extSourcePath

docs/SPECIFICATION.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@
686686

687687
- `register_repl_handler(repl_fn)` to replace or augment the default REPL implementation.
688688

689-
A `.prex` pointer file MUST be treated as a text file containing one extension path per line. Blank lines MUST be ignored, and lines beginning with `!` MUST be treated as comments. Relative paths in a pointer file MUST be resolved relative to the pointer file's directory, with the current working directory and the interpreter's `stdext/` and `ext/` directories available as fallbacks when necessary. When both bundled and user extension directories are searched, `stdext/` MUST be consulted before `ext/`.
689+
A `.prex` pointer file MUST be treated as a text file containing one extension path per line. Blank lines MUST be ignored, and lines beginning with `!` MUST be treated as comments. Relative paths in a pointer file MUST be resolved relative to the pointer file's directory, with the current working directory and the interpreter's `ext/std/` and `ext/usr/` directories available as fallbacks when necessary. When both bundled and user extension directories are searched, `ext/std/` MUST be consulted before `ext/usr/`.
690690

691691
If a `.prex` file is supplied as an argument, the interpreter MUST load all referenced extensions. If no explicit extension arguments are supplied, the interpreter MUST also search for an automatically-discovered pointer file named `.prex` in the current working directory, and when running a source file it MUST also search the program's directory and the companion `<program>.prex` file beside the source file.
692692

@@ -884,7 +884,7 @@
884884
885885
Prefix package namespaces MUST use `..` as the package separator. The canonical form is `package..subpackage..module`. When `IMPORT(pkg)` is used and a package directory named `pkg` exists, the interpreter MUST prefer package resolution and attempt to load `pkg/init.pre`. If that package directory exists but contains no `init.pre`, the import MUST raise a runtime error. When `IMPORT(pkg..mod)` is used, the interpreter MUST resolve to `pkg/mod.pre`. If both a package directory and a same-named module file exist in the same search location, the package MUST take precedence.
886886
887-
When the referring source was itself loaded from a file, the search MUST begin in that source file's directory. When the referring source is executing via `-source`, the primary search directory MUST be the current working directory. After local search, the interpreter MUST consult bundled library locations before legacy `lib/` locations.
887+
When the referring source was itself loaded from a file, the search MUST begin in that source file's directory. When the referring source is executing via `-source`, the primary search directory MUST be the current working directory. After local search, the interpreter MUST consult `lib/std/` immediately before `lib/usr/`.
888888
889889
On first import, the module source MUST execute in its own isolated top-level environment. Unqualified identifiers during that execution MUST resolve within the module's own namespace. After execution completes, that namespace MUST be cached and reused by subsequent imports in the same interpreter process. Multiple aliases for the same module MUST provide distinct qualified views into the same cached module instance.
890890
@@ -1126,9 +1126,9 @@
11261126

11271127
The standard library is a set of packages and modules bundled with the interpreter that provide a set of common utilities.
11281128

1129-
Bundled standard-library modules MUST live under `stdlib/`. Module and package search paths used by `IMPORT` and `IMPORT_PATH` MUST consult `stdlib/` immediately before `lib/`, so bundled modules are preferred over legacy or user-installed library copies.
1129+
Bundled standard-library modules MUST live under `lib/std/`. User-installed modules and packages MUST live under `lib/usr/`. Module and package search paths used by `IMPORT` and `IMPORT_PATH` MUST consult `lib/std/` immediately before `lib/usr/`, so bundled modules are preferred over user-installed copies.
11301130

1131-
Bundled extensions shipped with the interpreter MUST live under `stdext/`. Extension search paths MUST consult `stdext/` immediately before `ext/`, so bundled extensions are preferred over user-installed copies with the same name.
1131+
Bundled extensions shipped with the interpreter MUST live under `ext/std/`. User-installed extensions MUST live under `ext/usr/`. Extension search paths MUST consult `ext/std/` immediately before `ext/usr/`, so bundled extensions are preferred over user-installed copies with the same name.
11321132

11331133
At present, the standard library is not defined by the specification, and any reasonable set of standard utilities is acceptable for a conforming implementation. Backwards-incompatible changes to the standard library MUST NOT increment the major version number of the specification, unless the incompatible change is altering a behaviour defined in this specification (NOTE: *At present* none of the stdlib is documented, and the stdlib should be considered unstable.).
11341134

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "../src/prefix_extension.h"
1+
#include "../../src/prefix_extension.h"
22

33
#include <stdio.h>
44
#include <stdlib.h>
@@ -40,7 +40,7 @@ typedef int SOCKET;
4040
#define closesocket close
4141
#endif
4242

43-
#include "../src/interpreter.h"
43+
#include "../../src/interpreter.h"
4444

4545
typedef struct {
4646
int id;

stdext/win32.c renamed to ext/std/win32.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#include <stdlib.h>
44
#include <string.h>
55

6-
#include "../src/prefix_extension.h"
7-
#include "../src/interpreter.h"
8-
#include "../src/value.h"
6+
#include "../../src/prefix_extension.h"
7+
#include "../../src/interpreter.h"
8+
#include "../../src/value.h"
99

1010
// Minimal C implementation of the win32 extension. This implements a
1111
// subset of the convenience operators provided by the Python version.
File renamed without changes.
File renamed without changes.
File renamed without changes.

stdlib/gui/gui.c renamed to lib/std/gui/gui.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "../../src/prefix_extension.h"
2-
#include "../../src/interpreter.h"
3-
#include "../../src/value.h"
1+
#include "../../../src/prefix_extension.h"
2+
#include "../../../src/interpreter.h"
3+
#include "../../../src/value.h"
44

55
#include <stdint.h>
66
#include <stdio.h>

0 commit comments

Comments
 (0)