aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-11-29 14:18:07 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-11-29 14:18:07 -0500
commitbb2f890fd470fff3e42698710b56c68164491d85 (patch)
tree13de7c4402037f0b655ddc809fad6e23454501fe
parent6db7b88c930657c38512709f808b422d39484a12 (diff)
Overhaul to versioning system (paths go tov2025-11-29
`/tomo@TOMOVERSION/lib@LIBVERSION` instead of using underscores. Tomo versioning now uses date-based versions.
-rw-r--r--CHANGES.md106
-rw-r--r--Makefile31
-rw-r--r--docs/libraries.md13
-rw-r--r--link_versions.sh16
-rwxr-xr-xlocal-tomo4
-rw-r--r--src/compile/files.c2
-rw-r--r--src/compile/headers.c6
-rw-r--r--src/compile/statements.c4
-rw-r--r--src/modules.c10
-rw-r--r--src/stdlib/stacktrace.c2
-rw-r--r--src/tomo.c22
-rw-r--r--src/typecheck.c4
12 files changed, 113 insertions, 107 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 0bbe387f..212fe54c 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,17 +1,12 @@
# Version History
-## v0.4
-- Tomo libraries are now installed to `$TOMO_PATH/lib/tomo_vX.Y/module_vZ.W`
- instead of `$TOMO_PATH/share/tomo_vX.Y/installed/module_vZ.W`
-- Core libraries are no longer shipped with the compiler, they have moved to
- separate repositories.
-- Library installation has been cleaned up a bit.
-- List indexing now gives an optional value.
-- Added support for inline anonymous enums
-- Accessing a field on an enum now gives an optional value instead of a boolean.
-- Syntax for text literals and inline C code has been simplified somewhat.
+## v2025-11-29
+
+### Syntax changes
+
- Syntax for tables has changed to use colons (`{k: v}`) instead of equals
(`{k=v}`).
+- Syntax for text literals and inline C code has been simplified.
- Added metadata format instead of `_HELP`/`_USAGE`:
```
HELP: "Help text"
@@ -19,6 +14,44 @@
MANPAGE_SYNOPSYS: "Synopsys..."
MANPAGE_DESCRIPTION: (./description.txt)
```
+- **Deprecated:** `extern` keyword for declaring external symbols from C.
+ - Use `C_code` instead.
+- **Deprecated:** postfix `?` to make values optional.
+ - Explicitly optional values can be declared as `my_var : T? = value`.
+- **Deprecated:** `>> ... = ...` form of doctests. They are now called "debug logs"
+ and you can specify multiple values: `>> a, b, c`
+- **Deprecated:** `extend` blocks
+- **Deprecated:** `deserialize` operation and `.serialized()` method call
+ - Instead, convert to and from `[Byte]`
+
+### Versioning and library changes
+
+- Tomo versioning now uses dates instead of semantic versioning.
+- Tomo libraries are now installed to
+ `$TOMO_PATH/lib/tomo@TOMO_VERSION/library@LIBRARY_VERSION` instead of
+ `$TOMO_PATH/share/tomo_TOMO_VERSION/installed/module_LIBRARY_VERSION`
+- Core libraries are no longer shipped with the compiler, they have moved to
+ separate repositories.
+- Library installation has been cleaned up a bit.
+
+### Type Changes
+
+- List indexing now gives an optional value.
+- Added support for inline anonymous enums
+- Accessing a field on an enum now gives an optional value instead of a boolean.
+- **Deprecated**: Sets are no longer a separate type with separate methods.
+ - Instead of sets, use tables with a value type of `{KeyType:Empty}`.
+ - As a shorthand, you can use `{a,b,c}` instead of `{a:Empty(),
+ b:Empty(), c:Empty()}` and the type annotation `{K}` as shorthand for
+ `{K:Empty}`.
+- Added `Empty` for a built-in empty struct type and `EMPTY` for an instance of
+ the empty struct.
+- Struct fields that start with underscores can be accessed again and function
+ arguments that start with underscore can be passed (but only as keyword
+ arguments).
+
+### API changes
+
- Added `Path.lines()`.
- Added `Text.find(text, target, start=1)`.
- Added `at_cleanup()` to register cleanup functions.
@@ -26,29 +59,9 @@
directories if needed.
- `setenv()` now takes an optional parameter for value, which allows for
unsetting environment values.
-- Deprecated:
- - Sets are no longer a separate type with separate methods.
- - Instead of sets, use tables with a value type of `{KeyType:Empty}`.
- - As a shorthand, you can use `{a,b,c}` instead of `{a:Empty(),
- b:Empty(), c:Empty()}` and the type annotation `{K}` as shorthand for
- `{K:Empty}`.
- - Tables now have `and`, `or`, `xor`, and `-` (minus) metamethods.
- - `extern` keyword for declaring external symbols from C.
- - Use `C_code` instead.
- - Postfix `?` to make values optional.
- - Explicitly optional values can be declared as `my_var : T? = value`.
- - `>> ... = ...` form of doctests. They are now called "debug logs" and you
- can specify multiple values: `>> a, b, c`
- - `extend` blocks
- - `deserialize` operation and `.serialized()` method call
- - Instead, convert to and from `[Byte]`
-- Struct fields that start with underscores can be accessed again and function
- arguments that start with underscore can be passed (but only as keyword
- arguments).
+- Tables now have `and`, `or`, `xor`, and `-` (minus) metamethods.
- Added `table.with(other)`, `table.without(other)`,
`table.intersection(other)`, and `table.difference(other)`.
-- Added `Empty` for a built-in empty struct type and `EMPTY` for an instance of
- the empty struct.
- Changed `list.unique()` to return a table with `Empty()` values for each
unique list item.
- Added a `--format` flag to the `tomo` binary that autoformats your code
@@ -57,21 +70,26 @@
- `Text.from_utf8()`/`Text.utf8()`
- `Text.from_utf16()`/`Text.utf16()`
- `Text.from_utf32()`/`Text.utf32()`
+
+### Bug fixes
+
+- `Int.parse()` had a memory bug.
+- Breaking out of a `for line in file.by_line()!` loop would leak file handle
+ resources, which could lead to exhausting the number of open file handles.
+ When that happens, the standard library now forces a GC collection to clean
+ up resources, which can result in file handles being freed up.
+- `&` references failed to propagate when accessing fields like
+ `foo.baz.method()` when `foo` is a `&Foo` and `baz.method()` takes a `&Baz`.
+- Optional paths no longer fail to compile when you check them for `none`.
+- Text replacement no longer infinitely loops when given an empty text to replace.
+- Short CLI flag aliases now no longer use the first letter of the argument.
+- Stack memory was not correctly detected in some cases, leading to potential
+ memory errors.
+
+### Other changes
+
- Added automatic manpage generation.
- Major improvements to robustness of CLI argument parsing.
-- Fixed bugs:
- - `Int.parse()` had a memory bug.
- - Breaking out of a `for line in file.by_line()!` loop would leak file handle
- resources, which could lead to exhausting the number of open file handles.
- When that happens, the standard library now forces a GC collection to clean
- up resources, which can result in file handles being freed up.
- - `&` references failed to propagate when accessing fields like
- `foo.baz.method()` when `foo` is a `&Foo` and `baz.method()` takes a `&Baz`.
- - Optional paths no longer fail to compile when you check them for `none`.
- - Text replacement no longer infinitely loops when given an empty text to replace.
- - Short CLI flag aliases now no longer use the first letter of the argument.
- - Stack memory was not correctly detected in some cases, leading to potential
- memory errors.
## v0.3
diff --git a/Makefile b/Makefile
index ab9096cd..2bfde7a1 100644
--- a/Makefile
+++ b/Makefile
@@ -96,29 +96,30 @@ else
LDLIBS += -ldl
endif
-AR_FILE=libtomo_$(TOMO_VERSION).a
+AR_FILE=libtomo@$(TOMO_VERSION).a
ifeq ($(OS),Darwin)
INCLUDE_DIRS += -I/opt/homebrew/include
LDFLAGS += -L/opt/homebrew/lib
- LIB_FILE=libtomo_$(TOMO_VERSION).dylib
- LIBTOMO_FLAGS += -Wl,-install_name,@rpath/libtomo_$(TOMO_VERSION).dylib
+ LIB_FILE=libtomo@$(TOMO_VERSION).dylib
+ LIBTOMO_FLAGS += -Wl,-install_name,@rpath/libtomo@$(TOMO_VERSION).dylib
else
- LIB_FILE=libtomo_$(TOMO_VERSION).so
- LIBTOMO_FLAGS += -Wl,-soname,libtomo_$(TOMO_VERSION).so
+ LIB_FILE=libtomo@$(TOMO_VERSION).so
+ LIBTOMO_FLAGS += -Wl,-soname,libtomo@$(TOMO_VERSION).so
endif
-EXE_FILE=tomo_$(TOMO_VERSION)
-MODULES_FILE=build/lib/tomo_$(TOMO_VERSION)/modules.ini
+EXE_FILE=tomo@$(TOMO_VERSION)
+MODULES_FILE=build/lib/tomo@$(TOMO_VERSION)/modules.ini
COMPILER_OBJS=$(patsubst %.c,%.o,$(wildcard src/*.c src/compile/*.c src/parse/*.c src/formatter/*.c))
STDLIB_OBJS=$(patsubst %.c,%.o,$(wildcard src/stdlib/*.c))
TESTS=$(patsubst test/%.tm,test/results/%.tm.testresult,$(wildcard test/[!_]*.tm))
API_YAML=$(wildcard api/*.yaml)
API_MD=$(patsubst %.yaml,%.md,$(API_YAML))
+INCLUDE_SYMLINK=build/include/tomo@$(TOMO_VERSION)
-all: config.mk check-c-compiler check-libs build/include/tomo_$(TOMO_VERSION) build/lib/$(LIB_FILE) build/lib/$(AR_FILE) $(MODULES_FILE) build/bin/$(EXE_FILE)
+all: config.mk check-c-compiler check-libs $(INCLUDE_SYMLINK) build/lib/$(LIB_FILE) build/lib/$(AR_FILE) $(MODULES_FILE) build/bin/$(EXE_FILE)
@$(ECHO) "All done!"
-build/include/tomo_$(TOMO_VERSION):
+$(INCLUDE_SYMLINK):
ln -s ../../src/stdlib $@
version:
@@ -143,7 +144,7 @@ build/lib/$(LIB_FILE): $(STDLIB_OBJS)
@$(CC) $^ $(CFLAGS) $(OSFLAGS) $(LDFLAGS) $(LDLIBS) $(LIBTOMO_FLAGS) -o $@
$(MODULES_FILE): modules/core.ini modules/examples.ini
- @mkdir -p build/lib/tomo_$(TOMO_VERSION)
+ @mkdir -p build/lib/tomo@$(TOMO_VERSION)
@cat $^ > $@
build/lib/$(AR_FILE): $(STDLIB_OBJS)
@@ -239,11 +240,11 @@ install-files: build/bin/$(EXE_FILE) build/lib/$(LIB_FILE) build/lib/$(AR_FILE)
exit 0; \
fi; \
mkdir -p -m 755 "$(PREFIX)/man/man1" "$(PREFIX)/man/man3" "$(PREFIX)/bin" \
- "$(PREFIX)/include/tomo_$(TOMO_VERSION)" "$(PREFIX)/lib" "$(PREFIX)/lib/tomo_$(TOMO_VERSION)" "$(PREFIX)/share/licenses/tomo_$(TOMO_VERSION)"; \
- cp src/stdlib/*.h "$(PREFIX)/include/tomo_$(TOMO_VERSION)/"; \
+ "$(PREFIX)/include/tomo@$(TOMO_VERSION)" "$(PREFIX)/lib" "$(PREFIX)/lib/tomo@$(TOMO_VERSION)" "$(PREFIX)/share/licenses/tomo@$(TOMO_VERSION)"; \
+ cp src/stdlib/*.h "$(PREFIX)/include/tomo@$(TOMO_VERSION)/"; \
cp build/lib/$(LIB_FILE) build/lib/$(AR_FILE) "$(PREFIX)/lib/"; \
- cp $(MODULES_FILE) "$(PREFIX)/lib/tomo_$(TOMO_VERSION)"; \
- cp LICENSE.md "$(PREFIX)/share/licenses/tomo_$(TOMO_VERSION)"; \
+ cp $(MODULES_FILE) "$(PREFIX)/lib/tomo@$(TOMO_VERSION)"; \
+ cp LICENSE.md "$(PREFIX)/share/licenses/tomo@$(TOMO_VERSION)"; \
rm -f "$(PREFIX)/bin/$(EXE_FILE)"; \
cp build/bin/$(EXE_FILE) "$(PREFIX)/bin/"; \
cp man/man1/* "$(PREFIX)/man/man1/"; \
@@ -258,7 +259,7 @@ uninstall:
exit 0; \
fi; \
rm -rvf "$(PREFIX)/bin/tomo" "$(PREFIX)/bin/tomo"[0-9]* "$(PREFIX)/bin/tomo_v"* "$(PREFIX)/include/tomo_v"* \
- "$(PREFIX)/lib/libtomo_v*" "$(PREFIX)/lib/tomo_$(TOMO_VERSION)" "$(PREFIX)/share/licenses/tomo_$(TOMO_VERSION)"; \
+ "$(PREFIX)/lib/libtomo_v*" "$(PREFIX)/lib/tomo@$(TOMO_VERSION)" "$(PREFIX)/share/licenses/tomo@$(TOMO_VERSION)"; \
sh link_versions.sh
endif
diff --git a/docs/libraries.md b/docs/libraries.md
index 79477070..fc1eb4ea 100644
--- a/docs/libraries.md
+++ b/docs/libraries.md
@@ -151,8 +151,7 @@ that can be used by other Tomo projects. You can build a library by running
If you additionally add the `-I` flag, Tomo will copy the entire directory
(excluding files and directories that begin with `.` such as `.git`) into
-`~/.local/lib/tomo_vX.Y/` (where `X` and `Y` are the major/minor
-version of the compiler).
+`~/.local/lib/tomo@vTOMO_VERSION/LIBRARY_NAME@LIBRARY_VERSION`.
### Using Shared Libraries
@@ -167,13 +166,13 @@ read from the source files during compilation.
When you build and install a library, its version is determined from a
`CHANGES.md` file at the top level of the library directory (see:
[Versions](versions.md)). The library's version number is added to the file
-path where the library is installed, so if the library `foo` has version
+path where the library is installed, so if the library `mylib` has version
`v1.2`, then it will be installed to
-`~/.local/lib/tomo_vX.Y/foo_v1.2/`. When using a library, you must
+`~/.local/lib/tomo@TOMO_VERSION/mylib@v1.2/`. When using a library, you must
explicitly supply either the exact version in the `use` statement like this:
-`use foo_v1.2`, or provide a `modules.ini` file that lists version information
-and other details about modules being used. For each module, you should provide
-a `[modulename]` section with a `version=` field.
+`use mylib@v1.2`, or provide a `modules.ini` file that lists version
+information and other details about modules being used. For each module, you
+should provide a `[modulename]` section with a `version=` field.
```tomo
# File: foo.tm
diff --git a/link_versions.sh b/link_versions.sh
index 47a70490..8dadbb52 100644
--- a/link_versions.sh
+++ b/link_versions.sh
@@ -1,17 +1,5 @@
#!/bin/sh
TOMO_PREFIX="$(awk -F= '/PREFIX/{print $2}' config.mk)"
cd "$TOMO_PREFIX/bin"
-
-commands="$(ls | awk -F '[v.]' '
- /^tomo_v/{
- if ($2 >= max_major) max_major=$2;
- if ($3 >= max_minor[$2]) max_minor[$2] = $3;
- link_tomo=1
- }
- END {
- for (major in max_minor) {
- if (max_major > 0) print "ln -fs tomo_v"major"."max_minor[major]" tomo"major
- }
- if (link_tomo) print "ln -fs tomo_v"max_major"."max_minor[max_major]" tomo"
- }')"
-eval "$commands"
+top_version="$(printf '%s\n' 'tomo@'* | sort -r | head -1)"
+ln -fs "$top_version" tomo
diff --git a/local-tomo b/local-tomo
index bdf1e0da..76864837 100755
--- a/local-tomo
+++ b/local-tomo
@@ -1,11 +1,11 @@
#!/bin/sh
version=$(awk '/^## / {print $2; exit}' CHANGES.md)
here="$(realpath "$(dirname "$0")")"
-if [ ! -e "$here/build/bin/tomo_$version" ]; then
+if [ ! -e "$here/build/bin/tomo@$version" ]; then
echo "Tomo hasn't been compiled yet! Run \`make\` to compile it!"
exit 1;
fi
PATH="$here/build/bin${PATH:+:$PATH}" \
TOMO_PATH="$here/build" \
-tomo_"$version" "$@"
+tomo@"$version" "$@"
diff --git a/src/compile/files.c b/src/compile/files.c
index b916f23f..03c08bf6 100644
--- a/src/compile/files.c
+++ b/src/compile/files.c
@@ -194,7 +194,7 @@ Text_t compile_file(env_t *env, ast_t *ast) {
const char *name = file_base_name(ast->file->filename);
return Texts(env->do_source_mapping ? Texts("#line 1 ", quoted_str(ast->file->filename), "\n") : EMPTY_TEXT,
"#define __SOURCE_FILE__ ", quoted_str(ast->file->filename), "\n",
- "#include <tomo_" TOMO_VERSION "/tomo.h>\n"
+ "#include <tomo@" TOMO_VERSION "/tomo.h>\n"
"#include \"",
name, ".tm.h\"\n\n", includes, env->code->local_typedefs, "\n", env->code->lambdas, "\n",
env->code->staticdefs, "\n", top_level_code, "public void ",
diff --git a/src/compile/headers.c b/src/compile/headers.c
index f132b312..1dcf7abb 100644
--- a/src/compile/headers.c
+++ b/src/compile/headers.c
@@ -158,7 +158,7 @@ Text_t compile_file_header(env_t *env, Path_t header_path, ast_t *ast) {
Text_t header =
Texts("#pragma once\n",
env->do_source_mapping ? Texts("#line 1 ", quoted_str(ast->file->filename), "\n") : EMPTY_TEXT,
- "#include <tomo_" TOMO_VERSION "/tomo.h>\n");
+ "#include <tomo@" TOMO_VERSION "/tomo.h>\n");
compile_typedef_info_t info = {.env = env, .header = &header, .header_path = header_path};
visit_topologically(Match(ast, Block)->statements, (Closure_t){.fn = (void *)_make_typedefs, &info});
@@ -183,8 +183,8 @@ Text_t compile_statement_type_header(env_t *env, Path_t header_path, ast_t *ast)
case USE_MODULE: {
module_info_t mod = get_used_module_info(ast);
glob_t tm_files;
- const char *folder = mod.version ? String(mod.name, "_", mod.version) : mod.name;
- if (glob(String(TOMO_PATH, "/lib/tomo_" TOMO_VERSION "/", folder, "/[!._0-9]*.tm"), GLOB_TILDE, NULL,
+ const char *folder = mod.version ? String(mod.name, "@", mod.version) : mod.name;
+ if (glob(String(TOMO_PATH, "/lib/tomo@" TOMO_VERSION "/", folder, "/[!._0-9]*.tm"), GLOB_TILDE, NULL,
&tm_files)
!= 0) {
if (!try_install_module(mod, true)) code_err(ast, "Could not find library");
diff --git a/src/compile/statements.c b/src/compile/statements.c
index c6ceccd9..638f1341 100644
--- a/src/compile/statements.c
+++ b/src/compile/statements.c
@@ -196,8 +196,8 @@ static Text_t _compile_statement(env_t *env, ast_t *ast) {
} else if (use->what == USE_MODULE) {
module_info_t mod = get_used_module_info(ast);
glob_t tm_files;
- const char *folder = mod.version ? String(mod.name, "_", mod.version) : mod.name;
- if (glob(String(TOMO_PATH, "/lib/tomo_" TOMO_VERSION "/", folder, "/[!._0-9]*.tm"), GLOB_TILDE, NULL,
+ const char *folder = mod.version ? String(mod.name, "@", mod.version) : mod.name;
+ if (glob(String(TOMO_PATH, "/lib/tomo@" TOMO_VERSION "/", folder, "/[!._0-9]*.tm"), GLOB_TILDE, NULL,
&tm_files)
!= 0) {
if (!try_install_module(mod, true)) code_err(ast, "Could not find library");
diff --git a/src/modules.c b/src/modules.c
index df6bade3..36952ec8 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -28,7 +28,7 @@ const char *get_library_version(Path_t lib_dir) {
Path_t changes_file = Path$child(lib_dir, Text("CHANGES.md"));
OptionalText_t changes = Path$read(changes_file);
if (changes.length <= 0) {
- return "v0.0";
+ return "v0";
}
const char *changes_str = Text$as_c_string(Texts(Text("\n"), changes));
const char *version_line = strstr(changes_str, "\n## ");
@@ -41,7 +41,7 @@ Text_t get_library_name(Path_t lib_dir) {
Text_t name = Path$base_name(lib_dir);
name = Text$without_prefix(name, Text("tomo-"));
name = Text$without_suffix(name, Text("-tomo"));
- Text_t suffix = Texts(Text("_"), Text$from_str(get_library_version(lib_dir)));
+ Text_t suffix = Texts(Text("@"), Text$from_str(get_library_version(lib_dir)));
if (!Text$ends_with(name, suffix, NULL)) name = Texts(name, suffix);
return name;
}
@@ -102,7 +102,7 @@ module_info_t get_used_module_info(ast_t *use) {
const char *name = Match(use, Use)->path;
module_info_t *info = new (module_info_t, .name = name);
Path_t tomo_default_modules =
- Path$from_text(Texts(Text$from_str(TOMO_PATH), "/lib/tomo_" TOMO_VERSION "/modules.ini"));
+ Path$from_text(Texts(Text$from_str(TOMO_PATH), "/lib/tomo@" TOMO_VERSION "/modules.ini"));
read_modules_ini(tomo_default_modules, info);
read_modules_ini(Path$sibling(Path$from_str(use->file->filename), Text("modules.ini")), info);
read_modules_ini(Path$with_extension(Path$from_str(use->file->filename), Text(":modules.ini"), false), info);
@@ -111,8 +111,8 @@ module_info_t get_used_module_info(ast_t *use) {
}
bool try_install_module(module_info_t mod, bool ask_confirmation) {
- Path_t dest = Path$from_text(Texts(Text$from_str(TOMO_PATH), "/lib/tomo_" TOMO_VERSION "/", Text$from_str(mod.name),
- "_", Text$from_str(mod.version)));
+ Path_t dest = Path$from_text(Texts(Text$from_str(TOMO_PATH), "/lib/tomo@" TOMO_VERSION "/", Text$from_str(mod.name),
+ "@", Text$from_str(mod.version)));
if (Path$exists(dest)) return true;
print("No such path: ", dest);
diff --git a/src/stdlib/stacktrace.c b/src/stdlib/stacktrace.c
index b21d0cbc..ea939f62 100644
--- a/src/stdlib/stacktrace.c
+++ b/src/stdlib/stacktrace.c
@@ -98,7 +98,7 @@ void print_stacktrace(FILE *out, int offset) {
cwd[cwd_len++] = '/';
cwd[cwd_len] = '\0';
- const char *install_dir = String(TOMO_PATH, "/lib/tomo_" TOMO_VERSION "/");
+ const char *install_dir = String(TOMO_PATH, "/lib/tomo@" TOMO_VERSION "/");
static void *stack[1024];
int64_t size = (int64_t)backtrace(stack, sizeof(stack) / sizeof(stack[0]));
diff --git a/src/tomo.c b/src/tomo.c
index e1743d47..e086166c 100644
--- a/src/tomo.c
+++ b/src/tomo.c
@@ -91,7 +91,7 @@ static OptionalText_t show_codegen = NONE_TEXT,
" -D_BSD_SOURCE"
#endif
" -DGC_THREADS"),
- ldlibs = Text("-lgc -lm -lgmp -lunistring -ltomo_" TOMO_VERSION), ldflags = Text(""),
+ ldlibs = Text("-lgc -lm -lgmp -lunistring -ltomo@" TOMO_VERSION), ldflags = Text(""),
optimization = Text("2"), cc = Text(DEFAULT_C_COMPILER);
static Text_t config_summary,
@@ -167,7 +167,7 @@ int main(int argc, char *argv[]) {
if (getenv("TOMO_PATH")) TOMO_PATH = getenv("TOMO_PATH");
- cflags = Texts("-I'", TOMO_PATH, "/include' -I'", TOMO_PATH, "/lib/tomo_" TOMO_VERSION "' ", cflags);
+ cflags = Texts("-I'", TOMO_PATH, "/include' -I'", TOMO_PATH, "/lib/tomo@" TOMO_VERSION "' ", cflags);
// Set up environment variables:
const char *PATH = getenv("PATH");
@@ -186,7 +186,7 @@ int main(int argc, char *argv[]) {
// Run a tool:
if ((streq(argv[1], "-r") || streq(argv[1], "--run")) && argc >= 3) {
if (strcspn(argv[2], "/;$") == strlen(argv[2])) {
- const char *program = String("'", TOMO_PATH, "'/lib/tomo_" TOMO_VERSION "/", argv[2], "/", argv[2]);
+ const char *program = String("'", TOMO_PATH, "'/lib/tomo@" TOMO_VERSION "/", argv[2], "/", argv[2]);
execv(program, &argv[2]);
}
print_err("This is not an installed tomo program: ", argv[2]);
@@ -218,7 +218,7 @@ int main(int argc, char *argv[]) {
" --source-mapping|-m <yes|no>: toggle source mapping in generated code\n"
" --changelog: show the Tomo changelog\n"
" --run|-r: run a program from ",
- TOMO_PATH, "/share/tomo_" TOMO_VERSION "/installed\n");
+ TOMO_PATH, "/share/tomo@" TOMO_VERSION "/installed\n");
Text_t help = Texts(Text("\x1b[1mtomo\x1b[m: a compiler for the Tomo programming language"), Text("\n\n"), usage);
cli_arg_t tomo_args[] = {
{"run", &run_files, List$info(&Path$info), .short_flag = 'r'}, //
@@ -292,7 +292,7 @@ int main(int argc, char *argv[]) {
// Uninstall libraries:
for (int64_t i = 0; i < (int64_t)uninstall_libraries.length; i++) {
Text_t *u = (Text_t *)(uninstall_libraries.data + i * uninstall_libraries.stride);
- xsystem(as_owner, "rm -rvf '", TOMO_PATH, "'/lib/tomo_" TOMO_VERSION "/", *u, " '", TOMO_PATH, "'/bin/", *u,
+ xsystem(as_owner, "rm -rvf '", TOMO_PATH, "'/lib/tomo@" TOMO_VERSION "/", *u, " '", TOMO_PATH, "'/bin/", *u,
" '", TOMO_PATH, "'/man/man1/", *u, ".1");
print("Uninstalled ", *u);
}
@@ -509,7 +509,7 @@ void build_library(Path_t lib_dir) {
void install_library(Path_t lib_dir) {
Text_t lib_name = get_library_name(lib_dir);
- Path_t dest = Path$child(Path$from_str(String(TOMO_PATH, "/lib/tomo_" TOMO_VERSION)), lib_name);
+ Path_t dest = Path$child(Path$from_str(String(TOMO_PATH, "/lib/tomo@" TOMO_VERSION)), lib_name);
print("Installing ", lib_dir, " into ", dest);
if (!Path$equal_values(lib_dir, dest)) {
if (verbose) whisper("Clearing out any pre-existing version of ", lib_name);
@@ -529,7 +529,7 @@ void install_library(Path_t lib_dir) {
"' "
">/dev/null 2>/dev/null"));
(void)result;
- print("Installed \033[1m", lib_dir, "\033[m to ", TOMO_PATH, "/lib/tomo_" TOMO_VERSION "/", lib_name);
+ print("Installed \033[1m", lib_dir, "\033[m to ", TOMO_PATH, "/lib/tomo@" TOMO_VERSION "/", lib_name);
}
void compile_files(env_t *env, List_t to_compile, List_t *object_files, List_t *extra_ldlibs, compile_mode_t mode) {
@@ -690,14 +690,14 @@ void build_file_dependency_graph(Path_t path, Table_t *to_compile, Table_t *to_l
}
case USE_MODULE: {
module_info_t mod = get_used_module_info(stmt_ast);
- const char *full_name = mod.version ? String(mod.name, "_", mod.version) : mod.name;
- Text_t lib = Texts("-Wl,-rpath,'", TOMO_PATH, "/lib/tomo_" TOMO_VERSION "/", Text$from_str(full_name),
- "' '", TOMO_PATH, "/lib/tomo_" TOMO_VERSION "/", Text$from_str(full_name), "/lib",
+ const char *full_name = mod.version ? String(mod.name, "@", mod.version) : mod.name;
+ Text_t lib = Texts("-Wl,-rpath,'", TOMO_PATH, "/lib/tomo@" TOMO_VERSION "/", Text$from_str(full_name),
+ "' '", TOMO_PATH, "/lib/tomo@" TOMO_VERSION "/", Text$from_str(full_name), "/lib",
Text$from_str(full_name), SHARED_SUFFIX "'");
Table$set(to_link, &lib, NULL, Table$info(&Text$info, &Void$info));
List_t children =
- Path$glob(Path$from_str(String(TOMO_PATH, "/lib/tomo_" TOMO_VERSION "/", full_name, "/[!._0-9]*.tm")));
+ Path$glob(Path$from_str(String(TOMO_PATH, "/lib/tomo@" TOMO_VERSION "/", full_name, "/[!._0-9]*.tm")));
for (int64_t i = 0; i < (int64_t)children.length; i++) {
Path_t *child = (Path_t *)(children.data + i * children.stride);
Table_t discarded = {.entries = EMPTY_LIST, .fallback = to_compile};
diff --git a/src/typecheck.c b/src/typecheck.c
index b89f7eca..37f4fcab 100644
--- a/src/typecheck.c
+++ b/src/typecheck.c
@@ -231,8 +231,8 @@ static env_t *load_module(env_t *env, ast_t *use_ast) {
case USE_MODULE: {
module_info_t mod = get_used_module_info(use_ast);
glob_t tm_files;
- const char *folder = mod.version ? String(mod.name, "_", mod.version) : mod.name;
- if (glob(String(TOMO_PATH, "/lib/tomo_" TOMO_VERSION "/", folder, "/[!._0-9]*.tm"), GLOB_TILDE, NULL, &tm_files)
+ const char *folder = mod.version ? String(mod.name, "@", mod.version) : mod.name;
+ if (glob(String(TOMO_PATH, "/lib/tomo@" TOMO_VERSION "/", folder, "/[!._0-9]*.tm"), GLOB_TILDE, NULL, &tm_files)
!= 0) {
if (!try_install_module(mod, true)) code_err(use_ast, "Couldn't find or install library: ", folder);
}