Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
ecb651c0
Commit
ecb651c0
authored
Jan 25, 2023
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: Add a common helper to get the argv0 directory.
parent
a0a3c25e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
77 deletions
+38
-77
tools.h
tools/tools.h
+26
-0
widl.c
tools/widl/widl.c
+5
-20
winegcc.c
tools/winegcc/winegcc.c
+1
-19
wmc.c
tools/wmc/wmc.c
+3
-19
wrc.c
tools/wrc/wrc.c
+3
-19
No files found.
tools/tools.h
View file @
ecb651c0
...
...
@@ -30,6 +30,9 @@
#include <fcntl.h>
#include <time.h>
#include <errno.h>
#ifdef HAVE_SYS_SYSCTL_H
# include <sys/sysctl.h>
#endif
#ifdef _WIN32
# include <direct.h>
...
...
@@ -603,6 +606,29 @@ static inline struct target init_argv0_target( const char *argv0 )
}
static
inline
char
*
get_argv0_dir
(
const
char
*
argv0
)
{
#ifndef _WIN32
char
*
dir
=
NULL
;
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
dir
=
realpath
(
"/proc/self/exe"
,
NULL
);
#elif defined (__FreeBSD__) || defined(__DragonFly__)
static
int
pathname
[]
=
{
CTL_KERN
,
KERN_PROC
,
KERN_PROC_PATHNAME
,
-
1
};
size_t
path_size
=
PATH_MAX
;
char
*
path
=
xmalloc
(
path_size
);
if
(
!
sysctl
(
pathname
,
ARRAY_SIZE
(
pathname
),
path
,
&
path_size
,
NULL
,
0
))
dir
=
realpath
(
path
,
NULL
);
free
(
path
);
#endif
if
(
!
dir
&&
!
(
dir
=
realpath
(
argv0
,
NULL
)))
return
NULL
;
return
get_dirname
(
dir
);
#else
return
get_dirname
(
argv0
);
#endif
}
/* output buffer management */
extern
unsigned
char
*
output_buffer
;
...
...
tools/widl/widl.c
View file @
ecb651c0
...
...
@@ -31,9 +31,6 @@
#include <signal.h>
#include <limits.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SYSCTL_H
# include <sys/sysctl.h>
#endif
#include "widl.h"
#include "utils.h"
...
...
@@ -482,23 +479,11 @@ void write_id_data(const statement_list_t *stmts)
static
void
init_argv0_dir
(
const
char
*
argv0
)
{
#ifndef _WIN32
char
*
dir
=
NULL
;
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
dir
=
realpath
(
"/proc/self/exe"
,
NULL
);
#elif defined (__FreeBSD__) || defined(__DragonFly__)
static
int
pathname
[]
=
{
CTL_KERN
,
KERN_PROC
,
KERN_PROC_PATHNAME
,
-
1
};
size_t
path_size
=
PATH_MAX
;
char
*
path
=
xmalloc
(
path_size
);
if
(
!
sysctl
(
pathname
,
ARRAY_SIZE
(
pathname
),
path
,
&
path_size
,
NULL
,
0
))
dir
=
realpath
(
path
,
NULL
);
free
(
path
);
#endif
if
(
!
dir
&&
!
(
dir
=
realpath
(
argv0
,
NULL
)))
return
;
includedir
=
strmake
(
"%s/%s"
,
get_dirname
(
dir
),
BIN_TO_INCLUDEDIR
);
dlldir
=
strmake
(
"%s/%s"
,
get_dirname
(
dir
),
BIN_TO_DLLDIR
);
#endif
char
*
dir
=
get_argv0_dir
(
argv0
);
if
(
!
dir
)
return
;
includedir
=
strmake
(
"%s/%s"
,
dir
,
BIN_TO_INCLUDEDIR
);
dlldir
=
strmake
(
"%s/%s"
,
dir
,
BIN_TO_DLLDIR
);
}
static
void
option_callback
(
int
optc
,
char
*
optarg
)
...
...
tools/winegcc/winegcc.c
View file @
ecb651c0
...
...
@@ -98,9 +98,6 @@
#include <ctype.h>
#include <limits.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SYSCTL_H
# include <sys/sysctl.h>
#endif
#include "utils.h"
...
...
@@ -646,24 +643,9 @@ static char *get_lib_dir( struct options *opts )
static
void
init_argv0_dir
(
const
char
*
argv0
)
{
#ifndef _WIN32
char
*
dir
=
NULL
;
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
dir
=
realpath
(
"/proc/self/exe"
,
NULL
);
#elif defined (__FreeBSD__) || defined(__DragonFly__)
static
int
pathname
[]
=
{
CTL_KERN
,
KERN_PROC
,
KERN_PROC_PATHNAME
,
-
1
};
size_t
path_size
=
PATH_MAX
;
char
*
path
=
xmalloc
(
path_size
);
if
(
!
sysctl
(
pathname
,
ARRAY_SIZE
(
pathname
),
path
,
&
path_size
,
NULL
,
0
))
dir
=
realpath
(
path
,
NULL
);
free
(
path
);
#endif
if
(
!
dir
&&
!
(
dir
=
realpath
(
argv0
,
NULL
)))
return
;
bindir
=
get_dirname
(
dir
);
if
(
!
(
bindir
=
get_argv0_dir
(
argv0
)))
return
;
includedir
=
strmake
(
"%s/%s"
,
bindir
,
BIN_TO_INCLUDEDIR
);
libdir
=
strmake
(
"%s/%s"
,
bindir
,
BIN_TO_LIBDIR
);
#endif
}
static
void
compile
(
struct
options
*
opts
,
const
char
*
lang
)
...
...
tools/wmc/wmc.c
View file @
ecb651c0
...
...
@@ -26,9 +26,6 @@
#include <signal.h>
#include <limits.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SYSCTL_H
# include <sys/sysctl.h>
#endif
#include "wmc.h"
#include "utils.h"
...
...
@@ -149,24 +146,11 @@ static void exit_on_signal( int sig )
static
void
init_argv0_dir
(
const
char
*
argv0
)
{
#ifndef _WIN32
char
*
dir
=
NULL
;
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
dir
=
realpath
(
"/proc/self/exe"
,
NULL
);
#elif defined (__FreeBSD__) || defined(__DragonFly__)
static
int
pathname
[]
=
{
CTL_KERN
,
KERN_PROC
,
KERN_PROC_PATHNAME
,
-
1
};
size_t
path_size
=
PATH_MAX
;
char
*
path
=
xmalloc
(
path_size
);
if
(
!
sysctl
(
pathname
,
ARRAY_SIZE
(
pathname
),
path
,
&
path_size
,
NULL
,
0
))
dir
=
realpath
(
path
,
NULL
);
free
(
path
);
#endif
if
(
!
dir
&&
!
(
dir
=
realpath
(
argv0
,
NULL
)))
return
;
dir
=
get_dirname
(
dir
);
char
*
dir
=
get_argv0_dir
(
argv0
);
if
(
!
dir
)
return
;
if
(
strendswith
(
dir
,
"/tools/wmc"
))
nlsdirs
[
0
]
=
strmake
(
"%s/../../nls"
,
dir
);
else
nlsdirs
[
0
]
=
strmake
(
"%s/%s"
,
dir
,
BIN_TO_NLSDIR
);
#endif
}
static
void
option_callback
(
int
optc
,
char
*
optarg
)
...
...
tools/wrc/wrc.c
View file @
ecb651c0
...
...
@@ -29,9 +29,6 @@
#include <signal.h>
#include <limits.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SYSCTL_H
# include <sys/sysctl.h>
#endif
#include "../tools.h"
#include "wrc.h"
...
...
@@ -294,25 +291,12 @@ static int load_file( const char *input_name, const char *output_name )
static
void
init_argv0_dir
(
const
char
*
argv0
)
{
#ifndef _WIN32
char
*
dir
=
NULL
;
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
dir
=
realpath
(
"/proc/self/exe"
,
NULL
);
#elif defined (__FreeBSD__) || defined(__DragonFly__)
static
int
pathname
[]
=
{
CTL_KERN
,
KERN_PROC
,
KERN_PROC_PATHNAME
,
-
1
};
size_t
path_size
=
PATH_MAX
;
char
*
path
=
xmalloc
(
path_size
);
if
(
!
sysctl
(
pathname
,
ARRAY_SIZE
(
pathname
),
path
,
&
path_size
,
NULL
,
0
))
dir
=
realpath
(
path
,
NULL
);
free
(
path
);
#endif
if
(
!
dir
&&
!
(
dir
=
realpath
(
argv0
,
NULL
)))
return
;
dir
=
get_dirname
(
dir
);
char
*
dir
=
get_argv0_dir
(
argv0
);
if
(
!
dir
)
return
;
includedir
=
strmake
(
"%s/%s"
,
dir
,
BIN_TO_INCLUDEDIR
);
if
(
strendswith
(
dir
,
"/tools/wrc"
))
nlsdirs
[
0
]
=
strmake
(
"%s/../../nls"
,
dir
);
else
nlsdirs
[
0
]
=
strmake
(
"%s/%s"
,
dir
,
BIN_TO_NLSDIR
);
#endif
}
static
void
option_callback
(
int
optc
,
char
*
optarg
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment