Skip to content

Commit 2334785

Browse files
committed
Replace getopt and aspritf implementations
The new code is licensed under BSD
1 parent 6113b15 commit 2334785

File tree

7 files changed

+37
-314
lines changed

7 files changed

+37
-314
lines changed

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "deps/getopt_port"]
2+
path = deps/getopt_port
3+
url = https://github.com/kimgr/getopt_port.git
4+
[submodule "deps/asprintf"]
5+
path = deps/asprintf
6+
url = https://github.com/eiszapfen2000/asprintf.git

CMakeLists.txt

+26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ set(SOURCE_FILES
77
extract-xiso.c
88
)
99

10+
set(DEPS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps)
11+
set(GETOPT_DIR ${DEPS_DIR}/getopt_port)
12+
set(ASPRINTF_DIR ${DEPS_DIR}/asprintf)
13+
1014
if(MSVC)
1115
set(CMAKE_C_FLAGS_RELEASE_INIT "/O2")
1216
add_compile_options(/W4 /utf-8)
@@ -21,6 +25,7 @@ else()
2125
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
2226
add_compile_options(-Wall -Wextra -Wpedantic -Wno-comment)
2327
endif()
28+
2429
add_executable(extract-xiso ${SOURCE_FILES})
2530
target_compile_definitions(extract-xiso PRIVATE ${TARGET_OS})
2631
if(CMAKE_C_BYTE_ORDER MATCHES "^$")
@@ -29,4 +34,25 @@ endif()
2934
target_compile_definitions(extract-xiso PRIVATE CMAKE_ENDIANNESS=${CMAKE_C_BYTE_ORDER})
3035
set_property(TARGET extract-xiso PROPERTY C_STANDARD 99)
3136
set_property(TARGET extract-xiso PROPERTY C_EXTENSIONS OFF)
37+
38+
if(WIN32)
39+
add_library(getopt STATIC ${GETOPT_DIR}/getopt.c)
40+
target_sources(getopt PUBLIC ${GETOPT_DIR}/getopt.h)
41+
target_include_directories(getopt PUBLIC ${GETOPT_DIR})
42+
set_property(TARGET getopt PROPERTY C_STANDARD 99)
43+
set_property(TARGET getopt PROPERTY C_EXTENSIONS OFF)
44+
45+
target_link_libraries(extract-xiso getopt)
46+
endif()
47+
48+
if(MSVC)
49+
add_library(asprintf STATIC ${ASPRINTF_DIR}/asprintf.c)
50+
target_sources(asprintf PUBLIC ${ASPRINTF_DIR}/asprintf.h)
51+
target_include_directories(asprintf PUBLIC ${ASPRINTF_DIR})
52+
set_property(TARGET asprintf PROPERTY C_STANDARD 99)
53+
set_property(TARGET asprintf PROPERTY C_EXTENSIONS OFF)
54+
55+
target_link_libraries(extract-xiso asprintf)
56+
endif()
57+
3258
install(TARGETS extract-xiso RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")

deps/asprintf

Submodule asprintf added at 29fe98d

deps/getopt_port

Submodule getopt_port added at 6ad8cc1

extract-xiso.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,18 @@
281281
#endif
282282

283283
#if defined(_WIN32)
284+
#include <io.h>
284285
#include <direct.h>
285286
#include "win32/dirent.c"
286-
#include "win32/getopt.c"
287+
#include <getopt.h> /* Provided by CMake */
287288
#else
288289
#include <dirent.h>
289290
#include <limits.h>
290291
#include <unistd.h>
291292
#endif
292293

293294
#if defined(_MSC_VER)
294-
#include "win32/asprintf.c"
295+
#include <asprintf.h> /* Provided by CMake */
295296
#include <BaseTsd.h>
296297
#else
297298
#include <strings.h>

win32/asprintf.c

-79
This file was deleted.

win32/getopt.c

-233
This file was deleted.

0 commit comments

Comments
 (0)