mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add --win-vs-dirs to override VS detection dirs.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
- Add `enum.from_ordinal` and `fault.from_ordinal`
|
||||
- Deprecate cast-style conversion from integer to enum.
|
||||
- Make deprecation an error in test mode.
|
||||
- Add `--win-vs-dirs` to override VS detection dirs.
|
||||
|
||||
### Fixes
|
||||
- Fix case trying to initialize a `char[*]*` from a String.
|
||||
|
||||
@@ -415,6 +415,7 @@ typedef struct BuildOptions_
|
||||
{
|
||||
const char *sdk;
|
||||
const char *def;
|
||||
const char *vs_dirs;
|
||||
WinCrtLinking crt_linking;
|
||||
} win;
|
||||
struct
|
||||
@@ -661,6 +662,7 @@ typedef struct
|
||||
{
|
||||
const char *sdk;
|
||||
const char *def;
|
||||
const char *vs_dirs;
|
||||
WinCrtLinking crt_linking;
|
||||
bool use_win_subsystem;
|
||||
} win;
|
||||
|
||||
@@ -174,6 +174,7 @@ static void usage(bool full)
|
||||
PRINTF(" --winsdk <dir> - Set the directory for Windows system library files for cross compilation.");
|
||||
PRINTF(" --wincrt=<option> - Windows CRT linking: none, static-debug, static, dynamic-debug (default if debug info enabled), dynamic (default).");
|
||||
PRINTF(" --windef <file> - Use Windows 'def' file for function exports instead of 'dllexport'.");
|
||||
PRINTF(" --win-vs-dirs <dir>;<dir> - Override Windows VS detection.");
|
||||
PRINTF("");
|
||||
PRINTF(" --macossdk <dir> - Set the directory for the MacOS SDK for cross compilation.");
|
||||
PRINTF(" --macos-min-version <ver> - Set the minimum MacOS version to compile for.");
|
||||
@@ -922,6 +923,10 @@ static void parse_option(BuildOptions *options)
|
||||
}
|
||||
if (match_longopt("winsdk"))
|
||||
{
|
||||
if (options->win.vs_dirs)
|
||||
{
|
||||
error_exit("error: --winsdk cannot be combined with --win-vs-dirs.");
|
||||
}
|
||||
if (at_end() || next_is_opt()) error_exit("error: --winsdk needs a directory.");
|
||||
options->win.sdk = check_dir(next_arg());
|
||||
return;
|
||||
@@ -947,6 +952,16 @@ static void parse_option(BuildOptions *options)
|
||||
options->win.crt_linking = (WinCrtLinking)parse_multi_option(argopt, 5, wincrt_linking);
|
||||
return;
|
||||
}
|
||||
if (match_longopt("win-vs-dirs"))
|
||||
{
|
||||
if (options->win.sdk)
|
||||
{
|
||||
error_exit("error: --win-vs-dirs cannot be combined with --winsdk.");
|
||||
}
|
||||
if (at_end() || next_is_opt()) error_exit("error: --win-vs-dirs needs to followed by the directories.");
|
||||
options->win.vs_dirs = next_arg();
|
||||
return;
|
||||
}
|
||||
if ((argopt = match_argopt("sanitize")))
|
||||
{
|
||||
options->sanitize_mode = (SanitizeMode)parse_multi_option(argopt, 4, sanitize_modes);
|
||||
|
||||
@@ -405,6 +405,7 @@ static void update_build_target_from_options(BuildTarget *target, BuildOptions *
|
||||
target->vector_conv = options->vector_conv;
|
||||
if (options->macos.sysroot) target->macos.sysroot = options->macos.sysroot;
|
||||
if (options->win.sdk) target->win.sdk = options->win.sdk;
|
||||
if (options->win.vs_dirs) target->win.vs_dirs = options->win.vs_dirs;
|
||||
if (options->macos.min_version) target->macos.min_version = options->macos.min_version;
|
||||
if (options->macos.sdk_version) target->macos.sdk_version = options->macos.sdk_version;
|
||||
if (options->win.crt_linking != WIN_CRT_DEFAULT) target->win.crt_linking = options->win.crt_linking;
|
||||
|
||||
@@ -334,6 +334,9 @@ static void load_into_build_target(const char *filename, JSONObject *json, const
|
||||
RiscvFloatCapability riscv_float = GET_SETTING(RiscvFloatCapability, "riscvfloat", riscv_capability, "`none`, `float` or `double`.");
|
||||
if (riscv_float != RISCVFLOAT_DEFAULT) target->feature.riscv_float_capability = riscv_float;
|
||||
|
||||
// winsdk
|
||||
target->win.vs_dirs = get_string(filename, target_name, json, "win-vs-dirs", target->win.vs_dirs);
|
||||
|
||||
// winsdk
|
||||
target->win.sdk = get_string(filename, target_name, json, "winsdk", target->win.sdk);
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ static void linker_setup_windows(const char ***args_ref, Linker linker_type, con
|
||||
crt_linking = wincrt;
|
||||
}
|
||||
|
||||
if (!compiler.build.win.sdk)
|
||||
if (!compiler.build.win.sdk && !compiler.build.win.vs_dirs)
|
||||
{
|
||||
const char *path = windows_cross_compile_library();
|
||||
if (path)
|
||||
@@ -131,16 +131,38 @@ static void linker_setup_windows(const char ***args_ref, Linker linker_type, con
|
||||
add_concat_quote_arg("/LIBPATH:", compiler.build.win.sdk);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (compiler.build.win.vs_dirs)
|
||||
{
|
||||
char *c = strstr(compiler.build.win.vs_dirs, ";");
|
||||
int len = c - compiler.build.win.vs_dirs;
|
||||
if (!c || !len) error_exit("''win-vs-dirs' override was invalid.");
|
||||
char *um = str_printf("%.*s\\um\\x64", len, compiler.build.win.vs_dirs);
|
||||
char *ucrt = str_printf("%.*s\\ucrt\\x64", len, compiler.build.win.vs_dirs);
|
||||
c++;
|
||||
if (!file_is_dir(um) || !file_is_dir(ucrt) || !file_is_dir(c))
|
||||
{
|
||||
error_exit("''win-vs-dirs' override paths were not valid.");
|
||||
}
|
||||
add_concat_quote_arg("/LIBPATH:", um);
|
||||
add_concat_quote_arg("/LIBPATH:", ucrt);
|
||||
add_concat_quote_arg("/LIBPATH:", c);
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowsSDK *windows_sdk = windows_get_sdk();
|
||||
if (!windows_sdk) error_exit("Windows applications cannot be cross compiled without --winsdk.");
|
||||
|
||||
if (!file_is_dir(windows_sdk->vs_library_path)) error_exit("Failed to find windows sdk.");
|
||||
|
||||
add_concat_quote_arg("/LIBPATH:", windows_sdk->windows_sdk_um_library_path);
|
||||
add_concat_quote_arg("/LIBPATH:", windows_sdk->windows_sdk_ucrt_library_path);
|
||||
char *um = str_printf("%s\\um\\x64", windows_sdk->windows_sdk_path);
|
||||
char *ucrt = str_printf("%s\\ucrt\\x64", windows_sdk->windows_sdk_path);
|
||||
|
||||
add_concat_quote_arg("/LIBPATH:", um);
|
||||
add_concat_quote_arg("/LIBPATH:", ucrt);
|
||||
add_concat_quote_arg("/LIBPATH:", windows_sdk->vs_library_path);
|
||||
}
|
||||
}
|
||||
|
||||
// Link sanitizer runtime libraries
|
||||
const char *compiler_path = find_executable_path();
|
||||
|
||||
@@ -22,8 +22,7 @@ WindowsSDK get_windows_link_paths()
|
||||
error_exit("Failed to find windows kit root.");
|
||||
}
|
||||
|
||||
out.windows_sdk_um_library_path = str_printf("%s\\um\\x64", path);
|
||||
out.windows_sdk_ucrt_library_path = str_printf("%s\\ucrt\\x64", path);
|
||||
out.windows_sdk_path = path;
|
||||
out.vs_library_path = find_visual_studio();
|
||||
|
||||
return out;
|
||||
@@ -136,7 +135,7 @@ static char *find_windows_kit_root(void)
|
||||
|
||||
free(root);
|
||||
free(best_file);
|
||||
return scratch_buffer_to_string();
|
||||
return scratch_buffer_to_copy();
|
||||
|
||||
SEARCH_FAILED:
|
||||
free(root);
|
||||
|
||||
@@ -38,8 +38,7 @@ typedef struct
|
||||
} MacSDK;
|
||||
|
||||
typedef struct {
|
||||
char* windows_sdk_um_library_path;
|
||||
char* windows_sdk_ucrt_library_path;
|
||||
char* windows_sdk_path;
|
||||
char* vs_library_path;
|
||||
} WindowsSDK;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user