small cleanup in src and docs concerning ACME library

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@440 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye
2025-06-19 15:55:22 +00:00
parent 6669fe8b50
commit db020f6607
13 changed files with 66 additions and 23 deletions

View File

@@ -184,11 +184,6 @@ Zeropage pointer wraps around from $ff to $00
Section: Errors during assembly
----------------------------------------------------------------------
"ACME" environment variable not found.
This will be shown if the source code references any files from
the library, but the library location variable wasn't set. This
can only be given on systems using the said variable.
"!cbm" is obsolete; use "!ct pet" instead.
This is given when the now obsolete "!cbm" pseudo opcode is
encountered.
@@ -332,6 +327,14 @@ Invalid hex digit after \x, expected 0-9/a-f.
by two hex digits. If the next two chars are not [0-9a-fA-F], this
error will be generated.
Library path not set. Use --libpath or create an environment variable.
This will be shown if the source code references a file from the
library but ACME does not know where the library is located.
If the ACME binary was compiled with a default path, you will not
see this error.
See the file "Lib.txt" in this directory for info on how to setup
the library path.
Macro already defined.
Macros can only be defined once. If you define a macro twice, ACME
will give an error for the new definition and then output an info

View File

@@ -14,7 +14,19 @@ within ACME sources when using the pseudo opcodes "!source" or
If the file names are given using "..." quoting, ACME will look for
the files in the current directory.
If the file names are given using <...> quoting, ACME will look for
them in the ACME_Lib directory tree however.
them in the library directory.
The actual location of the library directory can be given in several
different ways:
1. a default can be given when compiling the ACME binary.
2. an environment variable called "ACME" overrides this.
3. and the CLI switch "--libpath" overrides even that.
Setting up an environment variable is OS-specific, so for example on
Linux, put this in your .bashrc file:
export ACME="$HOME/.acme/ACME_Lib"
...and of course you will then have to copy the library tree to that
location.
All files in the ACME_Lib directory tree are in the public domain.
They are *NOT* covered by the GNU General Public License, under which

View File

@@ -17,8 +17,9 @@
#define ALTERNATIVE_DIR_SEP ':'
// string containing the prefix for accessing files from the library tree
// (use "--libpath" cli switch to override)
#define PLATFORM_LIBPREFIX "progdir:acme_lib/"
#define PLATFORM_NEEDS_ENV_VAR 0 // no "ACME" environment variable needed
#define PLATFORM_USE_ENV_VAR 0 // no "ACME" environment variable needed/supported
// setting file types of created files
#define PLATFORM_SETFILETYPE_APPLE(a)

View File

@@ -17,8 +17,9 @@
#define ALTERNATIVE_DIR_SEP '\\' // dummy
// string containing the prefix for accessing files from the library tree
// (use "--libpath" cli switch or "ACME" environment variable to set this)
#define PLATFORM_LIBPREFIX NULL
#define PLATFORM_NEEDS_ENV_VAR 1 // library access needs "ACME" environment variable
#define PLATFORM_USE_ENV_VAR 1 // library access needs "ACME" environment variable
// setting file types of created files
#define PLATFORM_SETFILETYPE_APPLE(a)

View File

@@ -20,8 +20,9 @@
#define ALTERNATIVE_DIR_SEP ':'
// string containing the prefix for accessing files from the library tree
// (use "--libpath" cli switch to override)
#define PLATFORM_LIBPREFIX "ACME_Lib:"
#define PLATFORM_NEEDS_ENV_VAR 0 // no "ACME" environment variable needed
#define PLATFORM_USE_ENV_VAR 0 // no "ACME" environment variable needed/supported
// setting file types of created files
#define PLATFORM_SETFILETYPE_APPLE(a) RISCOS_set_filetype(a, 0xffd) // FIXME - wrong value!

View File

@@ -17,8 +17,13 @@
#define ALTERNATIVE_DIR_SEP '/' // dummy
// string containing the prefix for accessing files from the library tree
#define PLATFORM_LIBPREFIX NULL // TODO: package maintainers could use sth like "/usr/share/acme/lib/" here (and put the library files there)
#define PLATFORM_NEEDS_ENV_VAR 1 // library access needs "ACME" environment variable
// (use "--libpath" cli switch or "ACME" environment variable to set this)
#define PLATFORM_LIBPREFIX NULL
#define PLATFORM_USE_ENV_VAR 1 // library access needs "ACME" environment variable
// if you are building an "ACME" package for a linux or bsd distribution, you
// could put the library files at /usr/share/acme/lib/ and use that path instead
// of "NULL" above. the user then only needs the "ACME" environment variable if
// they want to override the default path given here.
// setting the created files' types
#define PLATFORM_SETFILETYPE_APPLE(a)

View File

@@ -69,6 +69,7 @@ static const char arg_vicelabels[] = "VICE labels filename";
#define OPTION_STRICT "strict"
#define OPTION_LIBPATH "libpath"
#define OPTION_DIALECT "dialect"
#define OPTION_PLEASE "please"
#define OPTION_DEBUGLEVEL "debuglevel"
#define OPTION_TEST "test"
// options for "-W"
@@ -728,9 +729,11 @@ static const char *long_option(const char *string)
else if (strcmp(string, OPTION_STRICT) == 0)
config.all_warnings_are_errors = TRUE;
else if (strcmp(string, OPTION_LIBPATH) == 0)
config.platform_lib_prefix = cliargs_safe_get_next("path to library");
platform_set_lib_path(cliargs_safe_get_next("path to library"));
else if (strcmp(string, OPTION_DIALECT) == 0)
set_dialect(cliargs_get_next()); // NULL is ok (handled like unknown)
else if (strcmp(string, OPTION_PLEASE) == 0)
++config.politeness;
else if (strcmp(string, OPTION_DEBUGLEVEL) == 0)
config.debuglevel = string_to_number(cliargs_safe_get_next("debug level"));
else if (strcmp(string, OPTION_TEST) == 0) {

View File

@@ -122,6 +122,7 @@ void config_default(struct config *conf)
conf->all_warnings_are_errors = FALSE; // enabled by --strict
conf->test_new_features = FALSE; // enabled by --test
conf->dialect = V__CURRENT_VERSION; // changed by --dialect
conf->politeness = 0; // changed by --please
conf->debuglevel = DEBUGLEVEL_DEBUG; // changed by --debuglevel, used by "!debug"
conf->platform_lib_prefix = PLATFORM_LIBPREFIX;
conf->initial_cpu_type = NULL;
@@ -600,7 +601,7 @@ void throw_warning(const char msg[])
// output an error (something is wrong, no output file will be generated).
// the assembler will try to go on with the assembly, so the user gets to know
// about more than one of his typos at a time.
// about more than one of their typos at a time.
void throw_error(const char msg[])
{
if (error_is_in_cli_args)

View File

@@ -89,6 +89,7 @@ struct config {
boolean all_warnings_are_errors; // FALSE, enabled by --strict
boolean test_new_features; // FALSE, enabled by --test
enum dialect dialect; // set by --dialect (and --test --test)
int politeness; // incremented by --please
int debuglevel; // set by --debuglevel, used by "!debug"
const char *platform_lib_prefix; // default value depends on platform
const struct cpu_type *initial_cpu_type;
@@ -223,7 +224,7 @@ extern void throw_warning(const char msg[]);
// output an error (something is wrong, no output file will be generated).
// the assembler will try to go on with the assembly, so the user gets to know
// about more than one of his typos at a time.
// about more than one of their typos at a time.
extern void throw_error(const char msg[]);
// output a serious error (assembly stops, for example if outbuffer overruns).

View File

@@ -1104,9 +1104,9 @@ static void library_path_to_pathbuf(void)
dynabuf_clear(pathbuf);
// CAUTION: the second part of the condition below implies the first part,
// so the first part seems useless. but the first part allows for the
// compiler removing the check completely on some platforms.
if ((PLATFORM_NEEDS_ENV_VAR) && (config.platform_lib_prefix == NULL)) {
throw_error("\"ACME\" environment variable not found."); // FIXME - change to sth like "library path not set, use --libpath or set ACME env var"
// compiler to remove the check completely on some platforms.
if ((PLATFORM_USE_ENV_VAR) && (config.platform_lib_prefix == NULL)) {
throw_error("Library path not set. Use --libpath or create an environment variable.");
} else {
dynabuf_add_string(pathbuf, config.platform_lib_prefix);
}

View File

@@ -4,6 +4,7 @@
//
// Platform specific stuff
#include "platform.h"
#include "global.h" // for config
// Amiga
@@ -29,19 +30,30 @@
#endif
// set or change library path
void platform_set_lib_path(const char new_path[])
{
if (config.platform_lib_prefix) {
// this is mostly for debugging so people can check if their env var setup works:
printf("Changing library path from \"%s\" to \"%s\".\n", config.platform_lib_prefix, new_path);
fflush(stdout); // force output before any subsequent errors
}
config.platform_lib_prefix = new_path;
}
// stuff shared by some, but not all platforms:
#if PLATFORM_NEEDS_ENV_VAR
#if PLATFORM_USE_ENV_VAR
#include <stdlib.h> // for getenv()
#include "dynabuf.h"
#include "global.h" // for config
// function to setup pointer to library tree from env var
void platform_read_env_var(void)
{
char *env_var;
// Find out the path of ACME's library
// find out the path of ACME's library
env_var = getenv("ACME");
// if environment variable was found, make a copy
if (env_var) {
@@ -49,7 +61,7 @@ void platform_read_env_var(void)
// copy environment variable to global dynamic buffer
dynabuf_add_string(GlobalDynaBuf, env_var);
dynabuf_append(GlobalDynaBuf, '\0'); // add terminator
config.platform_lib_prefix = dynabuf_get_copy(GlobalDynaBuf);
platform_set_lib_path(dynabuf_get_copy(GlobalDynaBuf));
}
}

View File

@@ -42,8 +42,11 @@
// longer than the input string!
extern void platform_convert_path(boolean *is_absolute, char *p);
// set or change library path
extern void platform_set_lib_path(const char new_path[]);
// stuff shared by some, but not all platforms:
#if PLATFORM_NEEDS_ENV_VAR
#if PLATFORM_USE_ENV_VAR
// function to setup pointer to library tree from env var
extern void platform_read_env_var(void);

View File

@@ -9,7 +9,7 @@
#define RELEASE "0.97" // update before release FIXME
#define CODENAME "Zem" // update before release
#define CHANGE_DATE "16 Jun" // update before release FIXME
#define CHANGE_DATE "17 Jun" // update before release FIXME
#define CHANGE_YEAR "2025" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME