Support external toolchain on Windows for aot compiler (#3911)
allowing custom ARC toolchain on Windows
This commit is contained in:
@ -165,3 +165,53 @@ wa_strdup(const char *s)
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0
|
||||
int
|
||||
bh_system(const char *cmd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#if !(defined(_WIN32) || defined(_WIN32_))
|
||||
ret = system(cmd);
|
||||
#else
|
||||
ret = _spawnlp(_P_WAIT, "cmd.exe", "/c", cmd, NULL);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN32_)
|
||||
errno_t
|
||||
_mktemp_s(char *nameTemplate, size_t sizeInChars);
|
||||
#endif
|
||||
|
||||
bool
|
||||
bh_mkstemp(char *file_name, size_t name_len)
|
||||
{
|
||||
int fd;
|
||||
|
||||
#if !(defined(_WIN32) || defined(_WIN32_))
|
||||
(void)name_len;
|
||||
/* On Linux, it generates a unique temporary filename from template, creates
|
||||
* and opens the file, and returns an open file descriptor for the file. */
|
||||
if ((fd = mkstemp(file_name)) <= 0) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* close and remove temp file */
|
||||
close(fd);
|
||||
unlink(file_name);
|
||||
#else
|
||||
/* On Windows, it generates a unique temporary file name but does not create
|
||||
* or open the file */
|
||||
if (_mktemp_s(file_name, name_len) != 0) {
|
||||
goto fail;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
#endif /* End of WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0 */
|
||||
|
||||
@ -66,6 +66,16 @@ bh_strdup(const char *s);
|
||||
char *
|
||||
wa_strdup(const char *s);
|
||||
|
||||
#if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0
|
||||
/* Executes a system command in bash/cmd.exe */
|
||||
int
|
||||
bh_system(const char *cmd);
|
||||
|
||||
/* Tests whether can create a temporary file with the given name */
|
||||
bool
|
||||
bh_mkstemp(char *filename, size_t name_len);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user