mirror of
https://github.com/frida/tinycc
synced 2025-01-19 17:59:25 +03:00
default output object filename is basename of input filename (same behaviour as gcc)
This commit is contained in:
parent
066d5e7a84
commit
410fc57ba0
20
tcc.c
20
tcc.c
@ -9323,6 +9323,22 @@ int tcc_set_output_type(TCCState *s, int output_type)
|
|||||||
|
|
||||||
#if !defined(LIBTCC)
|
#if !defined(LIBTCC)
|
||||||
|
|
||||||
|
/* extract the basename of a file */
|
||||||
|
static const char *tcc_basename(const char *name)
|
||||||
|
{
|
||||||
|
const char *p;
|
||||||
|
p = strrchr(name, '/');
|
||||||
|
#ifdef WIN32
|
||||||
|
if (!p)
|
||||||
|
p = strrchr(name, '\\');
|
||||||
|
#endif
|
||||||
|
if (!p)
|
||||||
|
p = name;
|
||||||
|
else
|
||||||
|
p++;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
static int64_t getclock_us(void)
|
static int64_t getclock_us(void)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -9625,8 +9641,10 @@ int main(int argc, char **argv)
|
|||||||
if (output_type != TCC_OUTPUT_MEMORY && !outfile) {
|
if (output_type != TCC_OUTPUT_MEMORY && !outfile) {
|
||||||
if (output_type == TCC_OUTPUT_OBJ && !reloc_output) {
|
if (output_type == TCC_OUTPUT_OBJ && !reloc_output) {
|
||||||
char *ext;
|
char *ext;
|
||||||
|
/* strip path */
|
||||||
|
pstrcpy(objfilename, sizeof(objfilename) - 1,
|
||||||
|
tcc_basename(files[0]));
|
||||||
/* add .o extension */
|
/* add .o extension */
|
||||||
pstrcpy(objfilename, sizeof(objfilename) - 1, files[0]);
|
|
||||||
ext = strrchr(objfilename, '.');
|
ext = strrchr(objfilename, '.');
|
||||||
if (!ext)
|
if (!ext)
|
||||||
goto default_outfile;
|
goto default_outfile;
|
||||||
|
Loading…
Reference in New Issue
Block a user