Skip to content

Commit 38aa691

Browse files
ret2libcradare
authored andcommitted
Fix build on windows
* DWORD was not found on windows * tmp_ptr had the wrong type * generating both libspp and spp executable in the same build dir caused an error because on windows both things generate a spp.lib file. To solve this issue, move the spp executable to a separate `bin` directory
1 parent 4eef0c3 commit 38aa691

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include config.mk
33
PWD=$(shell pwd)
44
PREFIX?=/usr
55
BINDIR=${DESTDIR}${PREFIX}/bin
6-
OBJ=spp.o main.o
6+
OBJ=spp.o bin/main.o
77
# r_api.o
88
ODF=$(subst .o,.d,$(OBJ))
99
BIN=spp

main.c bin/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* MIT pancake <[email protected]> (C) 2009-2020 */
22

3-
#include "spp.h"
4-
#include "r_api.h"
3+
#include "../spp.h"
4+
#include "../r_api.h"
55

66
extern struct Proc *procs[];
77
extern struct Proc *proc;

bin/meson.build

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
spp_exe = executable('spp', ['main.c', '../spp.c'],
2+
include_directories: ['.', '..'],
3+
dependencies: spp_dep,
4+
install: true)

meson.build

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
project('spp', 'c')
2-
spp_version = '1.0.0'
2+
spp_version = '1.2.0'
33

44
configure_file(input: 'config.def.h',
55
output: 'config.h',
66
copy: true)
77

88
spp_files = [
99
'spp.c',
10-
's_api.c'
1110
]
1211

1312
libspp_static = static_library('spp', spp_files,
@@ -38,9 +37,5 @@ pkgconfig_mod.generate(libspp,
3837

3938
if not meson.is_subproject()
4039
install_headers('spp.h')
41-
42-
spp_exe = executable('spp', ['main.c'],
43-
dependencies: spp_dep,
44-
install: true
45-
)
40+
subdir('bin')
4641
endif

r_api.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/* radare2 - LGPL - Copyright 2013-2020 - pancake */
22

3+
#if __UNIX__
34
#include <unistd.h>
5+
#elif __WINDOWS__
6+
#include <windows.h>
7+
#endif
48
#include "spp.h"
59
#include "r_api.h"
610

@@ -117,13 +121,13 @@ int r_sys_setenv(const char *key, const char *value) {
117121
char *r_sys_getenv(const char *key) {
118122
#if __WINDOWS__
119123
DWORD dwRet;
120-
char *envbuf = NULL, tmp_ptr;
124+
char *envbuf = NULL, *tmp_ptr;
121125
char *val = NULL;
122126
const int TMP_BUFSIZE = 4096;
123127
if (!key) {
124128
return NULL;
125129
}
126-
envbuf = (envbuf)malloc (sizeof (envbuf) * TMP_BUFSIZE);
130+
envbuf = malloc (sizeof (envbuf) * TMP_BUFSIZE);
127131
if (!envbuf) {
128132
goto err_r_sys_get_env;
129133
}
@@ -133,7 +137,7 @@ char *r_sys_getenv(const char *key) {
133137
goto err_r_sys_get_env;
134138
}
135139
} else if (TMP_BUFSIZE < dwRet) {
136-
tmp_ptr = (char *)realloc (envbuf, dwRet);
140+
tmp_ptr = realloc (envbuf, dwRet);
137141
if (!tmp_ptr) {
138142
goto err_r_sys_get_env;
139143
}

0 commit comments

Comments
 (0)