mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Deprecate *-add settings, use without -add. Updated CI.
This commit is contained in:
21
.github/workflows/main.yml
vendored
21
.github/workflows/main.yml
vendored
@@ -10,6 +10,7 @@ env:
|
||||
LLVM_RELEASE_VERSION_WINDOWS: 18
|
||||
LLVM_RELEASE_VERSION_MAC: 18
|
||||
LLVM_RELEASE_VERSION_LINUX: 18
|
||||
LLVM_DEV_VERSION: 20
|
||||
jobs:
|
||||
|
||||
build-msvc:
|
||||
@@ -209,7 +210,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build_type: [Release, Debug]
|
||||
llvm_version: [17, 18, 19]
|
||||
llvm_version: [17, 18, 20]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -228,7 +229,7 @@ jobs:
|
||||
lld-${{matrix.llvm_version}} liblld-${{matrix.llvm_version}}-dev libmlir-${{matrix.llvm_version}} \
|
||||
libmlir-${{matrix.llvm_version}}-dev mlir-${{matrix.llvm_version}}-tools
|
||||
else
|
||||
if [[ "${{matrix.llvm_version}}" < 19 ]]; then
|
||||
if [[ "${{matrix.llvm_version}}" < "${{env.LLVM_DEV_VERSION}}" ]]; then
|
||||
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{matrix.llvm_version}} main"
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y -t llvm-toolchain-focal-${{matrix.llvm_version}} libpolly-${{matrix.llvm_version}}-dev \
|
||||
@@ -242,7 +243,7 @@ jobs:
|
||||
fi
|
||||
fi
|
||||
- name: CMake
|
||||
if: matrix.llvm_version != 18
|
||||
if: matrix.llvm_version < 18 || matrix.llvm_version == env.LLVM_DEV_VERSION
|
||||
run: |
|
||||
cmake -B build \
|
||||
-G Ninja \
|
||||
@@ -256,7 +257,7 @@ jobs:
|
||||
-DC3_LLVM_VERSION=${{matrix.llvm_version}}
|
||||
cmake --build build
|
||||
- name: CMake18
|
||||
if: matrix.llvm_version == 18
|
||||
if: matrix.llvm_version >= 18 && matrix.llvm_version != env.LLVM_DEV_VERSION
|
||||
run: |
|
||||
cmake -B build \
|
||||
-G Ninja \
|
||||
@@ -267,7 +268,7 @@ jobs:
|
||||
-DCMAKE_OBJCOPY=llvm-objcopy-${{matrix.llvm_version}} \
|
||||
-DCMAKE_STRIP=llvm-strip-${{matrix.llvm_version}} \
|
||||
-DCMAKE_DLLTOOL=llvm-dlltool-${{matrix.llvm_version}} \
|
||||
-DC3_LLVM_VERSION=18.1
|
||||
-DC3_LLVM_VERSION=${{matrix.llvm_version}}.1
|
||||
cmake --build build
|
||||
|
||||
- name: Compile and run some examples
|
||||
@@ -356,7 +357,7 @@ jobs:
|
||||
- name: Install Clang ${{matrix.llvm_version}}
|
||||
run: |
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||
if [[ "${{matrix.llvm_version}}" < 19 ]]; then
|
||||
if [[ "${{matrix.llvm_version}}" < "${{env.LLVM_DEV_VERSION}}" ]]; then
|
||||
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{matrix.llvm_version}} main"
|
||||
else
|
||||
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main"
|
||||
@@ -366,7 +367,7 @@ jobs:
|
||||
sudo apt-get install -y libmlir-${{matrix.llvm_version}} libmlir-${{matrix.llvm_version}}-dev mlir-${{matrix.llvm_version}}-tools
|
||||
sudo apt-get install -y libpolly-${{matrix.llvm_version}}-dev
|
||||
- name: CMake Old
|
||||
if: matrix.llvm_version < 18
|
||||
if: matrix.llvm_version < 18 || matrix.llvm_version == env.LLVM_DEV_VERSION
|
||||
run: |
|
||||
cmake -B build \
|
||||
-G Ninja \
|
||||
@@ -380,7 +381,7 @@ jobs:
|
||||
-DC3_LLVM_VERSION=${{matrix.llvm_version}}
|
||||
cmake --build build
|
||||
- name: CMake
|
||||
if: matrix.llvm_version >= 18
|
||||
if: matrix.llvm_version >= 18 && matrix.llvm_version != env.LLVM_DEV_VERSION
|
||||
run: |
|
||||
cmake -B build \
|
||||
-G Ninja \
|
||||
@@ -477,12 +478,12 @@ jobs:
|
||||
echo "CPATH=$TMP_PATH" >> $GITHUB_ENV
|
||||
|
||||
- name: CMake
|
||||
if: matrix.llvm_version != 18
|
||||
if: matrix.llvm_version < 18
|
||||
run: |
|
||||
cmake -B build -G Ninja -DC3_LLVM_VERSION=${{matrix.llvm_version}} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
cmake --build build
|
||||
- name: CMake18
|
||||
if: matrix.llvm_version == 18
|
||||
if: matrix.llvm_version >= 18
|
||||
run: |
|
||||
cmake -B build -G Ninja -DC3_LLVM_VERSION=${{matrix.llvm_version}}.1 -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
cmake --build build
|
||||
|
||||
@@ -81,7 +81,7 @@ if (NOT WIN32)
|
||||
find_package(CURL)
|
||||
endif()
|
||||
if (NOT C3_LLVM_VERSION STREQUAL "auto")
|
||||
if (${C3_LLVM_VERSION} VERSION_LESS 15 OR ${C3_LLVM_VERSION} VERSION_GREATER 19)
|
||||
if (${C3_LLVM_VERSION} VERSION_LESS 17 OR ${C3_LLVM_VERSION} VERSION_GREATER 20)
|
||||
message(FATAL_ERROR "LLVM ${C3_LLVM_VERSION} is not supported!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
- Scalar -> vector not implicit in call or assign.
|
||||
- Added `--vector-conv` to enable the old scalar->vector conversion behaviour.
|
||||
- Added "weak" type aliases `def Foo = my_foo::Foo @weak;`
|
||||
- `*-add` keys in targets in `manifest.json` and `project.json` are deprecated.
|
||||
- Made "add" the default for things like `sources`, `dependencies` and other keys in project and library files.
|
||||
|
||||
### Fixes
|
||||
None
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
},
|
||||
"macos-aarch64" : {},
|
||||
"linux-x64" : {
|
||||
"cflags-override": "-fPIE"
|
||||
"cflags": "-fPIE"
|
||||
},
|
||||
"windows-x64" : { }
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"hello_world": {
|
||||
"type": "executable",
|
||||
"cc" : "cc",
|
||||
"c-sources-override": [
|
||||
"c-sources": [
|
||||
"./csource/**"
|
||||
],
|
||||
"reloc": "PIE",
|
||||
@@ -34,7 +34,7 @@
|
||||
"hello_world_lib": {
|
||||
"type": "static-lib",
|
||||
"cc" : "cc",
|
||||
"c-sources-override": [
|
||||
"c-sources": [
|
||||
"./csource/**"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -104,4 +104,4 @@ const char *get_cflags(const char *file, const char *target, JSONObject *json, c
|
||||
void get_list_append_strings(const char *file, const char *target, JSONObject *json, const char ***list_ptr,
|
||||
const char *base, const char *override, const char *add);
|
||||
int get_valid_string_setting(const char *file, const char *target, JSONObject *json, const char *key, const char** values, int first_result, int count, const char *expected);
|
||||
void check_json_keys(const char* valid_keys[][2], size_t key_count, JSONObject *json, const char *target_name, const char *option);
|
||||
void check_json_keys(const char* valid_keys[][2], size_t key_count, const char* deprecated_keys[], size_t deprecated_key_count, JSONObject *json, const char *target_name, const char *option);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "build_internal.h"
|
||||
#include "utils/common.h"
|
||||
|
||||
void check_json_keys(const char* valid_keys[][2], size_t key_count, JSONObject *json, const char *target_name, const char *option)
|
||||
void check_json_keys(const char* valid_keys[][2], size_t key_count, const char* deprecated_keys[], size_t deprecated_key_count, JSONObject *json, const char *target_name, const char *option)
|
||||
{
|
||||
static bool failed_shown = false;
|
||||
bool failed = false;
|
||||
@@ -10,7 +10,15 @@ void check_json_keys(const char* valid_keys[][2], size_t key_count, JSONObject *
|
||||
const char *key = json->keys[i];
|
||||
for (size_t j = 0; j < key_count; j++)
|
||||
{
|
||||
if (strcmp(key, valid_keys[j][0]) == 0) goto OK;
|
||||
if (str_eq(key, valid_keys[j][0])) goto OK;
|
||||
}
|
||||
for (size_t j = 0; j < deprecated_key_count; j++)
|
||||
{
|
||||
if (str_eq(key, deprecated_keys[j]))
|
||||
{
|
||||
eprintf("'%s' is using the deprecated parameter '%s'", target_name, key);
|
||||
goto OK;
|
||||
}
|
||||
}
|
||||
eprintf("WARNING: Unknown parameter '%s' in '%s'.\n", key, target_name);
|
||||
failed = true;
|
||||
@@ -101,11 +109,18 @@ const char *get_cflags(const char *file, const char *target, JSONObject *json, c
|
||||
{
|
||||
// CFlags
|
||||
const char *cflags = get_optional_string(file, target, json, target ? "cflags-override" : "cflags");
|
||||
const char *cflags_add = target ? get_optional_string(file, target, json, "cflags-add") : NULL;
|
||||
const char *cflags_add = target ? get_optional_string(file, target, json, "cflags") : NULL;
|
||||
if (cflags && cflags_add)
|
||||
{
|
||||
error_exit("In file '%s': '%s' is combining both 'cflags' and 'cflags-override', only one may be used.", file, target);
|
||||
}
|
||||
if (target && !cflags_add) cflags_add = get_optional_string(file, target, json, "cflags-add");
|
||||
if (cflags && cflags_add)
|
||||
{
|
||||
// TODO remove in 0.7
|
||||
error_exit("In file '%s': '%s' is combining both 'cflags-add' and 'cflags-override', only one may be used.", file, target);
|
||||
}
|
||||
|
||||
if (cflags) original_flags = cflags;
|
||||
if (!cflags_add) return original_flags;
|
||||
if (original_flags)
|
||||
@@ -124,9 +139,15 @@ void get_list_append_strings(const char *file, const char *target, JSONObject *j
|
||||
const char *base, const char *override, const char *add)
|
||||
{
|
||||
const char **value = get_optional_string_array(file, target, json, target ? override : base);
|
||||
const char **add_value = target ? get_optional_string_array(file, target, json, add) : NULL;
|
||||
const char **add_value = target ? get_optional_string_array(file, target, json, base) : NULL;
|
||||
if (value && add_value)
|
||||
{
|
||||
error_exit("In file '%s': '%s' is combining both '%s' and '%s', only one may be used.", file, target, override, base);
|
||||
}
|
||||
if (!add_value && target) add_value = get_optional_string_array(file, target, json, add);
|
||||
if (value && add_value)
|
||||
{
|
||||
// TODO remove in 0.7
|
||||
error_exit("In file '%s': '%s' is combining both '%s' and '%s', only one may be used.", file, target, override, add);
|
||||
}
|
||||
if (value) *list_ptr = value;
|
||||
|
||||
@@ -16,21 +16,25 @@ const char *manifest_default_keys[][2] = {
|
||||
const int manifest_default_keys_count = ELEMENTLEN(manifest_default_keys);
|
||||
|
||||
const char *manifest_target_keys[][2] = {
|
||||
{"c-sources-add", "Additional C sources to be compiled for the target."},
|
||||
{"c-sources", "Additional C sources to be compiled for the target."},
|
||||
{"c-sources-override", "C sources to be compiled, overriding global settings."},
|
||||
{"cc", "Set C compiler (defaults to 'cc')."},
|
||||
{"cflags-add", "Additional C compiler flags for the target."},
|
||||
{"cflags", "Additional C compiler flags for the target."},
|
||||
{"cflags-override", "C compiler flags for the target, overriding global settings."},
|
||||
{"dependencies", "List of C3 libraries to also include for this target."},
|
||||
{"exec", "Scripts to also run for the target."},
|
||||
{"linked-libraries", "Libraries linked by the linker for this target, overriding global settings."},
|
||||
{"linked-libs", "Libraries linked by the linker for this target, overriding global settings - deprecated."},
|
||||
{"link-args", "Linker arguments for this target."},
|
||||
{"linkflags", "Linker arguments for this target - deprecated."},
|
||||
};
|
||||
|
||||
|
||||
const int manifest_target_keys_count = ELEMENTLEN(manifest_target_keys);
|
||||
|
||||
const char *manifest_deprecated_target_keys[] = {
|
||||
"c-sources-add", "cflags-add", "linkflags", "linked-libs" };
|
||||
|
||||
const int manifest_deprecated_target_key_count = ELEMENTLEN(manifest_deprecated_target_keys);
|
||||
|
||||
static inline void parse_library_target(Library *library, LibraryTarget *target, const char *target_name,
|
||||
JSONObject *object);
|
||||
|
||||
@@ -43,7 +47,7 @@ static inline void parse_library_type(Library *library, LibraryTarget ***target_
|
||||
JSONObject *member = object->members[i];
|
||||
const char *key = object->keys[i];
|
||||
if (member->type != J_OBJECT) error_exit("Expected a list of properties for a target in %s.", library->dir);
|
||||
check_json_keys(manifest_target_keys, manifest_target_keys_count, member, key, "--list-library-properties");
|
||||
check_json_keys(manifest_target_keys, manifest_target_keys_count, manifest_deprecated_target_keys, manifest_deprecated_target_key_count, member, key, "--list-library-properties");
|
||||
LibraryTarget *library_target = CALLOCS(LibraryTarget);
|
||||
library_target->parent = library;
|
||||
ArchOsTarget target = arch_os_target_from_string(key);
|
||||
@@ -88,7 +92,7 @@ static inline void parse_library_target(Library *library, LibraryTarget *target,
|
||||
|
||||
static Library *add_library(JSONObject *object, const char *dir)
|
||||
{
|
||||
check_json_keys(manifest_default_keys, manifest_default_keys_count, object, "library", "--list-library-properties");
|
||||
check_json_keys(manifest_default_keys, manifest_default_keys_count, NULL, 0, object, "library", "--list-library-properties");
|
||||
Library *library = CALLOCS(Library);
|
||||
library->dir = dir;
|
||||
const char *provides = get_mandatory_string(dir, NULL, object, "provides");
|
||||
|
||||
@@ -64,30 +64,34 @@ const char *project_default_keys[][2] = {
|
||||
|
||||
const int project_default_keys_count = ELEMENTLEN(project_default_keys);
|
||||
|
||||
const char* project_deprecated_target_keys[] = {
|
||||
"c-source-add", "cflags-add", "dependencies-add", "dependency-search-paths-add", "exec-add",
|
||||
"linked-libraries", "linker-search-paths", "link-args-add", "sources-add"
|
||||
};
|
||||
const char* project_target_keys[][2] = {
|
||||
{"benchfn", "Override the benchmark function."},
|
||||
{"c-sources-add", "Additional C sources to be compiled for the target."},
|
||||
{"c-sources", "Additional C sources to be compiled for the target."},
|
||||
{"c-sources-override", "C sources to be compiled, overriding global settings."},
|
||||
{"cc", "Set C compiler (defaults to 'cc')."},
|
||||
{"cflags-add", "Additional C compiler flags for the target."},
|
||||
{"cflags", "Additional C compiler flags for the target."},
|
||||
{"cflags-override", "C compiler flags for the target, overriding global settings."},
|
||||
{"cpu", "CPU name, used for optimizations in the compiler backend."},
|
||||
{"debug-info", "Debug level: none, line-tables, full."},
|
||||
{"dependencies-add", "Additional C3 library dependencies for the target."},
|
||||
{"dependencies", "Additional C3 library dependencies for the target."},
|
||||
{"dependencies-override", "C3 library dependencies for this target, overriding global settings."},
|
||||
{"dependency-search-paths-add", "Additional C3 library search paths for the target."},
|
||||
{"dependency-search-paths", "Additional C3 library search paths for the target."},
|
||||
{"dependency-search-paths-override", "C3 library search paths for this target, overriding global settings."},
|
||||
{"exec-add", "Additional scripts to run for the target."},
|
||||
{"exec", "Additional scripts to run for the target."},
|
||||
{"exec-override", "Scripts to run for this target, overriding global settings."},
|
||||
{"features", "Features enabled for all targets."},
|
||||
{"fp-math", "Set math behaviour: `strict`, `relaxed` or `fast`."},
|
||||
{"langrev", "Version of the C3 language used."},
|
||||
{"linked-libraries-add", "Additional libraries linked by the linker for the target."},
|
||||
{"linked-libraries", "Additional libraries linked by the linker for the target."},
|
||||
{"linked-libraries-override", "Libraries linked by the linker for this target, overriding global settings."},
|
||||
{"linker", "'builtin' for the builtin linker, 'cc' for the system linker or <path> to a custom compiler."},
|
||||
{"linker-search-paths-add", "Additional linker search paths for the target."},
|
||||
{"linker-search-paths", "Additional linker search paths for the target."},
|
||||
{"linker-search-paths-override", "Linker search paths for this target, overriding global settings."},
|
||||
{"link-args-add", "Additional linker arguments for the target."},
|
||||
{"link-args", "Additional linker arguments for the target."},
|
||||
{"link-args-override", "Linker arguments for this target, overriding global settings."},
|
||||
{"link-libc", "Link libc (default: true)."},
|
||||
{"macossdk", "Set the directory for the MacOS SDK for cross compilation."},
|
||||
@@ -104,7 +108,7 @@ const char* project_target_keys[][2] = {
|
||||
{"script-dir", "The directory where 'exec' is run."},
|
||||
{"single-module", "Compile all modules together, enables more inlining."},
|
||||
{"soft-float", "Output soft-float functions."},
|
||||
{"sources-add", "Additional paths to project sources for the target."},
|
||||
{"sources", "Additional paths to project sources for the target."},
|
||||
{"sources-override", "Paths to project sources for this target, overriding global settings."},
|
||||
{"strip-unused", "Strip unused code and globals from the output. (default: true)"},
|
||||
{"symtab", "Sets the preferred symtab size."},
|
||||
@@ -125,6 +129,7 @@ const char* project_target_keys[][2] = {
|
||||
|
||||
const int project_target_keys_count = ELEMENTLEN(project_target_keys);
|
||||
|
||||
const int project_deprecated_target_keys_count = ELEMENTLEN(project_deprecated_target_keys);
|
||||
|
||||
long get_valid_integer(JSONObject *table, const char *key, const char *category, bool mandatory)
|
||||
{
|
||||
@@ -149,11 +154,11 @@ static void load_into_build_target(JSONObject *json, const char *target_name, Bu
|
||||
{
|
||||
if (target_name)
|
||||
{
|
||||
check_json_keys(project_target_keys, project_target_keys_count, json, target_name, "--list-project-properties");
|
||||
check_json_keys(project_target_keys, project_target_keys_count, project_deprecated_target_keys, project_deprecated_target_keys_count, json, target_name, "--list-project-properties");
|
||||
}
|
||||
else
|
||||
{
|
||||
check_json_keys(project_default_keys, project_default_keys_count, json, "default target", "--list-project-properties");
|
||||
check_json_keys(project_default_keys, project_default_keys_count, NULL, 0, json, "default target", "--list-project-properties");
|
||||
}
|
||||
target->cc = get_string(PROJECT_JSON, target_name, json, "cc", target->cc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user