Skip to content

Commit dc25409

Browse files
committed
[SPEC2DEF] Implement support for debug-only exports
1 parent 93ba586 commit dc25409

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

sdk/cmake/gcc.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,16 @@ function(fixup_load_config _target)
373373
DEPENDS native-pefixup)
374374
endfunction()
375375

376+
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR
377+
CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
378+
set(__spec2def_dbg_arg "--dbg")
379+
endif()
380+
376381
function(generate_import_lib _libname _dllname _spec_file __version_arg)
377382
# Generate the def for the import lib
378383
add_custom_command(
379384
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def
380-
COMMAND native-spec2def ${__version_arg} -n=${_dllname} -a=${ARCH2} ${ARGN} --implib -d=${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
385+
COMMAND native-spec2def ${__version_arg} ${__spec2def_dbg_arg} -n=${_dllname} -a=${ARCH2} ${ARGN} --implib -d=${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
381386
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
382387

383388
# With this, we let DLLTOOL create an import library
@@ -450,7 +455,7 @@ function(spec2def _dllname _spec_file)
450455
# Generate exports def and C stubs file for the DLL
451456
add_custom_command(
452457
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c
453-
COMMAND native-spec2def -n=${_dllname} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${__with_relay_arg} ${__version_arg} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
458+
COMMAND native-spec2def -n=${_dllname} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${__with_relay_arg} ${__version_arg} ${__spec2def_dbg_arg} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
454459
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
455460

456461
# Do not use precompiled headers for the stub file

sdk/cmake/msvc.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ function(fixup_load_config _target)
332332
# msvc knows how to generate a load_config so no hacks here
333333
endfunction()
334334

335+
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR
336+
CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
337+
set(__spec2def_dbg_arg "--dbg")
338+
endif()
339+
335340
function(generate_import_lib _libname _dllname _spec_file __version_arg)
336341

337342
set(_def_file ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_implib.def)
@@ -341,7 +346,7 @@ function(generate_import_lib _libname _dllname _spec_file __version_arg)
341346
# Generate the def, asm stub and alias files
342347
add_custom_command(
343348
OUTPUT ${_asm_stubs_file} ${_def_file} ${_asm_impalias_file}
344-
COMMAND native-spec2def --ms ${__version_arg} -a=${SPEC2DEF_ARCH} --implib -n=${_dllname} -d=${_def_file} -l=${_asm_stubs_file} -i=${_asm_impalias_file} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
349+
COMMAND native-spec2def --ms ${__version_arg} ${__spec2def_dbg_arg} -a=${SPEC2DEF_ARCH} --implib -n=${_dllname} -d=${_def_file} -l=${_asm_stubs_file} -i=${_asm_impalias_file} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
345350
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
346351

347352
# Compile the generated asm stub file
@@ -414,7 +419,7 @@ function(spec2def _dllname _spec_file)
414419
# Generate exports def and C stubs file for the DLL
415420
add_custom_command(
416421
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c
417-
COMMAND native-spec2def --ms -a=${SPEC2DEF_ARCH} -n=${_dllname} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${__with_relay_arg} ${__version_arg} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
422+
COMMAND native-spec2def --ms -a=${SPEC2DEF_ARCH} -n=${_dllname} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${__with_relay_arg} ${__version_arg} ${__spec2def_dbg_arg} ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}
418423
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} native-spec2def)
419424

420425
# Do not use precompiled headers for the stub file

sdk/tools/spec2def/spec2def.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ int gbImportLib = 0;
6767
int gbNotPrivateNoWarn = 0;
6868
int gbTracing = 0;
6969
int giArch = ARCH_X86;
70+
int gbDbgExports = 0;
7071
char *pszArchString = "i386";
7172
char *pszArchString2;
7273
char *pszSourceFileName = NULL;
@@ -1162,6 +1163,13 @@ ParseFile(char* pcStart, FILE *fileDest, unsigned *cExports)
11621163

11631164
} while (*pc == ',');
11641165
}
1166+
else if (CompareToken(pc, "-dbg"))
1167+
{
1168+
if (!gbDbgExports)
1169+
{
1170+
included = 0;
1171+
}
1172+
}
11651173
else if (CompareToken(pc, "-private"))
11661174
{
11671175
exp.uFlags |= FL_PRIVATE;
@@ -1505,6 +1513,7 @@ void usage(void)
15051513
" -s=<file> generate a stub file\n"
15061514
" -i=<file> generate an import alias file\n"
15071515
" --ms MSVC compatibility\n"
1516+
" --dbg Enable debug exports\n"
15081517
" -n=<name> name of the dll\n"
15091518
" --version=<version> Sets the version to create exports for\n"
15101519
" --implib generate a def file for an import library\n"
@@ -1571,6 +1580,10 @@ int main(int argc, char *argv[])
15711580
{
15721581
gbMSComp = 1;
15731582
}
1583+
else if (strcasecmp(argv[i], "--dbg") == 0)
1584+
{
1585+
gbDbgExports = 1;
1586+
}
15741587
else if (strcasecmp(argv[i], "--no-private-warnings") == 0)
15751588
{
15761589
gbNotPrivateNoWarn = 1;

0 commit comments

Comments
 (0)