From d7bd51a79d0784d3db809c0c5e82193f79799dc3 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 19 Dec 2014 13:10:30 +0100 Subject: [PATCH] wafsamba: generate an empty.c file if a SAMBA_{LIBRARY,SUBSYSTEM} doesn't have any source files This is better than passing '-' as filename to the compiler/linker. This replaces commit 65743f932b511db009655847e77288c95c0aa525. Bug: https://bugzilla.samba.org/show_bug.cgi?id=9334 Bug: https://bugzilla.samba.org/show_bug.cgi?id=10315 Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme Reviewed-by: Michael Adam --- buildtools/wafsamba/wafsamba.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index 5fef9be3325..82a9d6fcfe9 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -94,6 +94,11 @@ def ADD_INIT_FUNCTION(bld, subsystem, target, init_function): Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION +def generate_empty_file(task): + target_fname = installed_location=task.outputs[0].bldpath(task.env) + target_file = open(installed_location, 'w') + target_file.close() + return 0 ################################################################# def SAMBA_LIBRARY(bld, libname, source, @@ -149,9 +154,15 @@ def SAMBA_LIBRARY(bld, libname, source, source = bld.SUBDIR(subdir, source) # remember empty libraries, so we can strip the dependencies - if ((source == '') or (source == [])) and deps == '' and public_deps == '': - SET_TARGET_TYPE(bld, libname, 'EMPTY') - return + if ((source == '') or (source == [])): + if deps == '' and public_deps == '': + SET_TARGET_TYPE(bld, libname, 'EMPTY') + return + empty_c = libname + '.empty.c' + bld.SAMBA_GENERATOR('%s_empty_c' % libname, + rule=generate_empty_file, + target=empty_c) + source=empty_c if BUILTIN_LIBRARY(bld, libname): obj_target = libname @@ -537,9 +548,15 @@ def SAMBA_SUBSYSTEM(bld, modname, source, return # remember empty subsystems, so we can strip the dependencies - if ((source == '') or (source == [])) and deps == '' and public_deps == '': - SET_TARGET_TYPE(bld, modname, 'EMPTY') - return + if ((source == '') or (source == [])): + if deps == '' and public_deps == '': + SET_TARGET_TYPE(bld, modname, 'EMPTY') + return + empty_c = modname + '.empty.c' + bld.SAMBA_GENERATOR('%s_empty_c' % modname, + rule=generate_empty_file, + target=empty_c) + source=empty_c if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'): return -- 2.34.1