mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-08 02:53:29 +00:00
Dynamically find radare2 install dir on Windows ##windows
This commit is contained in:
parent
3d4d72a458
commit
ae00b18d0b
@ -55,7 +55,7 @@ build_script:
|
||||
- cmd: if %builder% == vs2017_64_dyn ( set "PATH=C:\mingw\bin;C:\mingw\msys\1.0\bin;%PYTHON%;%PATH%" && call "%VSVARSALLPATH%" x64 && python sys\meson.py --release --shared --install="%DIST_FOLDER%" && 7z a %ARTIFACT_ZIP% %DIST_FOLDER% )
|
||||
|
||||
test_script:
|
||||
- set PATH=%APPVEYOR_BUILD_FOLDER%\%DIST_FOLDER%;%PATH%
|
||||
- set PATH=%APPVEYOR_BUILD_FOLDER%\%DIST_FOLDER%\bin;%PATH%
|
||||
- echo %PATH%
|
||||
- where radare2
|
||||
- radare2 -v
|
||||
|
@ -2720,8 +2720,8 @@ R_API int r_core_config_init(RCore *core) {
|
||||
{
|
||||
char *pfx = r_sys_getenv("R2_PREFIX");
|
||||
#if __WINDOWS__
|
||||
char invoke_dir[MAX_PATH];
|
||||
if (!pfx && r_sys_get_src_dir_w32 (invoke_dir)) {
|
||||
char *invoke_dir = r_sys_prefix (NULL);
|
||||
if (!pfx && invoke_dir) {
|
||||
pfx = strdup (invoke_dir);
|
||||
}
|
||||
#endif
|
||||
|
@ -82,7 +82,7 @@ R_API int r_sys_cmd_str_full(const char *cmd, const char *input, char **output,
|
||||
#define r_sys_conv_win_to_utf8_l(buf, len) r_acp_to_utf8_l (buf, len)
|
||||
#endif
|
||||
R_API os_info *r_sys_get_winver();
|
||||
R_API int r_sys_get_src_dir_w32(char *buf);
|
||||
R_API char *r_sys_get_src_dir_w32();
|
||||
R_API bool r_sys_cmd_str_full_w32(const char *cmd, const char *input, char **output, int *outlen, char **sterr);
|
||||
R_API bool r_sys_create_child_proc_w32(const char *cmdline, HANDLE in, HANDLE out, HANDLE err);
|
||||
#endif
|
||||
|
@ -1141,15 +1141,20 @@ R_API bool r_sys_tts(const char *txt, bool bg) {
|
||||
}
|
||||
|
||||
R_API const char *r_sys_prefix(const char *pfx) {
|
||||
static char prefix[1024] = {0};
|
||||
if (!*prefix) {
|
||||
r_str_ncpy (prefix, R2_PREFIX, sizeof (prefix));
|
||||
static char *prefix = NULL;
|
||||
if (!prefix) {
|
||||
#if __WINDOWS__ && !CUTTER
|
||||
prefix = r_sys_get_src_dir_w32 ();
|
||||
if (!prefix) {
|
||||
prefix = strdup (R2_PREFIX);
|
||||
}
|
||||
#else
|
||||
prefix = strdup (R2_PREFIX);
|
||||
#endif
|
||||
}
|
||||
if (pfx) {
|
||||
if (strlen (pfx) >= sizeof (prefix) - 1) {
|
||||
return NULL;
|
||||
}
|
||||
r_str_ncpy (prefix, pfx, sizeof (prefix) - 1);
|
||||
free (prefix);
|
||||
prefix = strdup (pfx);
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ beach:
|
||||
return info;
|
||||
}
|
||||
|
||||
R_API int r_sys_get_src_dir_w32(char *buf) {
|
||||
R_API char *r_sys_get_src_dir_w32() {
|
||||
int i = 0;
|
||||
TCHAR fullpath[MAX_PATH + 1];
|
||||
TCHAR shortpath[MAX_PATH + 1];
|
||||
@ -77,20 +77,13 @@ R_API int r_sys_get_src_dir_w32(char *buf) {
|
||||
|
||||
if (!GetModuleFileName (NULL, fullpath, MAX_PATH + 1) ||
|
||||
!GetShortPathName (fullpath, shortpath, MAX_PATH + 1)) {
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
path = r_sys_conv_win_to_utf8 (shortpath);
|
||||
memcpy (buf, path, strlen(path) + 1);
|
||||
free (path);
|
||||
i = strlen (buf);
|
||||
while(i > 0 && buf[i-1] != '/' && buf[i-1] != '\\') {
|
||||
buf[--i] = 0;
|
||||
}
|
||||
// Remove the last separator in the path.
|
||||
if(i > 0) {
|
||||
buf[--i] = 0;
|
||||
}
|
||||
return true;
|
||||
char *dir, *tmp = dir = r_file_dirname (path);
|
||||
dir = r_file_dirname (tmp);
|
||||
free (tmp);
|
||||
return dir;
|
||||
}
|
||||
|
||||
R_API bool r_sys_cmd_str_full_w32(const char *cmd, const char *input, char **output, int *outlen, char **sterr) {
|
||||
|
@ -164,14 +164,15 @@ def win_dist(args):
|
||||
PATH_FMT['BUILDDIR'] = builddir
|
||||
|
||||
makedirs(r'{DIST}')
|
||||
copy(r'{BUILDDIR}\binr\*\*.exe', r'{DIST}')
|
||||
makedirs(r'{DIST}\bin')
|
||||
copy(r'{BUILDDIR}\binr\*\*.exe', r'{DIST}\bin')
|
||||
|
||||
r2_bat_fname = args.install + r'\r2.bat'
|
||||
log.debug('create "%s"', r2_bat_fname)
|
||||
with open(r2_bat_fname, 'w') as r2_bat:
|
||||
r2_bat.write('@"%s\\radare2" %%*\n' % os.path.abspath(args.install))
|
||||
r2_bat.write('@"%s\\bin\\radare2" %%*\n' % os.path.abspath(args.install))
|
||||
|
||||
copy(r'{BUILDDIR}\libr\*\*.dll', r'{DIST}')
|
||||
copy(r'{BUILDDIR}\libr\*\*.dll', r'{DIST}\bin')
|
||||
makedirs(r'{DIST}\{R2_LIBDIR}')
|
||||
if args.shared:
|
||||
copy(r'{BUILDDIR}\libr\*\*.lib', r'{DIST}\{R2_LIBDIR}')
|
||||
|
Loading…
Reference in New Issue
Block a user