From f41ba95babba96e2bee88c398390fc1610ff63e7 Mon Sep 17 00:00:00 2001 From: pabs3 Date: Wed, 4 Feb 2009 14:05:48 +0000 Subject: [PATCH] fix bug #2497148 - allow out of tree builds on POSIX platforms git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5921 212acab6-be3b-0410-9dea-997c60f758d6 --- Docs/src/SConscript | 4 ++-- SCons/Config/default | 8 ++++++++ SCons/Config/gnu | 11 +++++++++-- SCons/Config/hpc++ | 8 ++++++++ SCons/Config/ms | 8 ++++++++ SConstruct | 24 +++++++++++++++--------- Source/build.cpp | 4 ++-- Source/exehead/config.h | 2 +- Source/lang.cpp | 2 +- Source/makenssi.cpp | 2 +- Source/manifest.cpp | 2 +- Source/script.cpp | 2 +- 12 files changed, 57 insertions(+), 20 deletions(-) diff --git a/Docs/src/SConscript b/Docs/src/SConscript index 6133ccc4..8468280b 100644 --- a/Docs/src/SConscript +++ b/Docs/src/SConscript @@ -81,7 +81,7 @@ if build_chm: Copy(build_dir, '${SOURCE.dir}/../style.css'), Copy(build_dir, '${SOURCE.dir}/chmlink.js'), Copy(build_dir, '${SOURCE.dir}/nsis.hhp'), - Action('cd "%s" && "%s" ${SOURCES.abspath}' % (build_dir, halibut[0].abspath)), + Action('cd "%s" && "%s" ${SOURCES.abspath}' % (build_dir, halibut[0].rfile())), hhc_action ] ) @@ -110,7 +110,7 @@ else: html_builder = Builder( action = [ Copy(build_dir, '${SOURCE.dir}/../style.css'), - Action('cd "%s" && "%s" ${SOURCES.abspath}' % (build_dir, halibut[0].abspath)) + Action('cd "%s" && "%s" ${SOURCES.abspath}' % (build_dir, halibut[0].rfile())) ] ) diff --git a/SCons/Config/default b/SCons/Config/default index f010cbe0..e0809334 100644 --- a/SCons/Config/default +++ b/SCons/Config/default @@ -23,10 +23,14 @@ defenv.Append(CPPDEFINES = [('NSISCALL', '$STDCALL')]) stub_env = defenv.Clone() +stub_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + ### makensis environment makensis_env = defenv.Clone() +makensis_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + ### plugin environment plugin_env = defenv.Clone(no_import_lib = 1) @@ -39,10 +43,14 @@ util_env = defenv.Clone() cp_util_env = util_env.Clone() +cp_util_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + ### test environment test_env = defenv.Clone() +test_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + # return Return('stub_env makensis_env plugin_env util_env cp_util_env test_env') diff --git a/SCons/Config/gnu b/SCons/Config/gnu index 7df95c2a..83cf004b 100644 --- a/SCons/Config/gnu +++ b/SCons/Config/gnu @@ -10,7 +10,7 @@ Import('FlagsConfigure') def cross_env(env): if env['PLATFORM'] != 'win32': - env.Tool('crossmingw', toolpath = ['../Tools']) + env.Tool('crossmingw', toolpath = [Dir('../Tools').rdir()]) ### flags @@ -66,6 +66,8 @@ if defenv['DEBUG']: stub_env = defenv.Clone() cross_env(stub_env) +stub_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + if not defenv['DEBUG']: stub_env.Append(CCFLAGS = ['-Os']) # optimize for size stub_env.Append(CCFLAGS = ['-Wall']) # all warnings @@ -84,6 +86,8 @@ stub_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file makensis_env = defenv.Clone() +makensis_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + if not defenv['DEBUG']: makensis_env.Append(CCFLAGS = ['-O2']) # optimize makensis_env.Append(CCFLAGS = ['-Wall']) # all warnings @@ -117,6 +121,8 @@ plugin_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file cp_util_env = defenv.Clone() +cp_util_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + if not defenv['DEBUG']: cp_util_env.Append(CCFLAGS = ['-O2']) # optimize cp_util_env.Append(CCFLAGS = ['-Wall']) # all warnings @@ -151,6 +157,7 @@ conf.Finish() ### test environment test_env = defenv.Clone() +test_env.Append(CPPPATH = ['#$BUILD_CONFIG']) conf = FlagsConfigure(test_env) conf.CheckCompileFlag('-m32') conf.CheckLinkFlag('-m32') @@ -168,7 +175,7 @@ conf.Finish() # sure the sections will be written in the correct order. # -stub_env.Append(LINKFLAGS = '-T %s' % File('linker_script').abspath) +stub_env.Append(LINKFLAGS = ['-T', File('linker_script').rfile()]) # # GCC requires some functions from the CRT to be present, if certain diff --git a/SCons/Config/hpc++ b/SCons/Config/hpc++ index 558f0e7b..a6b5a158 100644 --- a/SCons/Config/hpc++ +++ b/SCons/Config/hpc++ @@ -23,10 +23,14 @@ defenv.Append(CPPDEFINES = [('NSISCALL', '$STDCALL')]) stub_env = defenv.Clone() +stub_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + ### makensis environment makensis_env = defenv.Clone() +makensis_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + ### use "$CXX -Ae" as the "$CC" compiler to build makensis makensis_env['CC'] = makensis_env['CXX'] @@ -111,10 +115,14 @@ util_env = defenv.Clone() cp_util_env = util_env.Clone() +cp_util_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + ### test environment test_env = defenv.Clone() +test_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + # return Return('stub_env makensis_env plugin_env util_env cp_util_env test_env') diff --git a/SCons/Config/ms b/SCons/Config/ms index 064222c0..3386b17c 100644 --- a/SCons/Config/ms +++ b/SCons/Config/ms @@ -81,6 +81,8 @@ conf.Finish() stub_env = defenv.Clone() +stub_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + if not defenv['DEBUG']: stub_env.Append(CCFLAGS = ['/O1']) # optimize for size stub_env.Append(CCFLAGS = ['/W3']) # level 3 warnings @@ -96,6 +98,8 @@ stub_env.Append(CCFLAGS = ['/Fa${TARGET}.lst']) # listing file name makensis_env = defenv.Clone() +makensis_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + if not defenv['DEBUG']: makensis_env.Append(CCFLAGS = ['/O2']) # optimize for speed makensis_env.Append(CCFLAGS = ['$EXCEPTION_FLAG']) # enable exceptions @@ -130,10 +134,14 @@ util_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file cp_util_env = util_env.Clone() +cp_util_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + ### test environment test_env = defenv.Clone() +test_env.Append(CPPPATH = ['#$BUILD_CONFIG']) + ### weird compiler requirements def check_requirement(ctx, func, trigger): diff --git a/SConstruct b/SConstruct index 9eacb09e..510b5f47 100644 --- a/SConstruct +++ b/SConstruct @@ -178,11 +178,22 @@ if 'NSIS_CONFIG_CONST_DATA_PATH' in defenv['NSIS_CPPDEFINES']: defenv.Append(NSIS_CPPDEFINES = [('PREFIX_CONF', '"%s"' % defenv.subst('$PREFIX_CONF'))]) defenv.Append(NSIS_CPPDEFINES = [('PREFIX_DATA', '"%s"' % defenv.subst('$PREFIX_DATA'))]) +# Need this early for the config header files to be placed in +if defenv['DEBUG']: + defenv.Replace(BUILD_PREFIX = 'build/debug') +else: + defenv.Replace(BUILD_PREFIX = 'build/release') + +defenv.Replace(BUILD_CONFIG = defenv.subst('$BUILD_PREFIX/config')) + +# ensure the config directory exists +defenv.Execute(Mkdir(defenv.Dir('#$BUILD_CONFIG'))) + # write configuration into sconf.h and defines.h -sconf_h = open(File('#Source/exehead/sconf.h').abspath, 'w') +sconf_h = open(defenv.File('#$BUILD_CONFIG/nsis-sconf.h').abspath, 'w') sconf_h.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n') -defines_h = open(File('#Source/defines.h').abspath, 'w') +defines_h = open(defenv.File('#$BUILD_CONFIG/nsis-defines.h').abspath, 'w') defines_h.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n') for i in defenv['NSIS_CPPDEFINES']: @@ -199,7 +210,7 @@ sconf_h.close() defines_h.close() # write version into version.h -f = open(File('#Source/version.h').abspath, 'w') +f = open(defenv.File('#$BUILD_CONFIG/nsis-version.h').abspath, 'w') f.write('// This file is automatically generated by SCons\n// DO NOT EDIT THIS FILE\n') f.write('#define NSIS_VERSION "v%s"\n' % defenv['VERSION']) f.close() @@ -322,13 +333,8 @@ defenv.TestScript = TestScript ####### Environments ### ###################################################################### -if defenv['DEBUG']: - defenv.Replace(BUILD_PREFIX = 'build/debug') -else: - defenv.Replace(BUILD_PREFIX = 'build/release') - if defenv['MSTOOLKIT']: - defenv.Tool('mstoolkit', toolpath = ['SCons/Tools']) + defenv.Tool('mstoolkit', toolpath = [Dir('SCons/Tools').rdir()]) defenv.Append(CCFLAGS = Split('$APPEND_CCFLAGS')) defenv.Append(LINKFLAGS = Split('$APPEND_LINKFLAGS')) diff --git a/Source/build.cpp b/Source/build.cpp index 29cc4463..2df3e3df 100644 --- a/Source/build.cpp +++ b/Source/build.cpp @@ -18,7 +18,7 @@ #include #include "exehead/config.h" -#include "version.h" +#include #include "build.h" #include "util.h" @@ -112,7 +112,7 @@ CEXEBuild::CEXEBuild() : definedlist.add("NSIS_VERSION", NSIS_VERSION); // automatically generated header file containing all defines -#include "defines.h" +#include // no longer optional definedlist.add("NSIS_SUPPORT_STANDARD_PREDEFINES"); diff --git a/Source/exehead/config.h b/Source/exehead/config.h index 128df73e..2c86cf85 100644 --- a/Source/exehead/config.h +++ b/Source/exehead/config.h @@ -19,7 +19,7 @@ #ifndef APSTUDIO_INVOKED // keep msdev's resource editor from mangling the .rc file -#include "sconf.h" +#include #ifndef NSIS_CONFIG_VISIBLE_SUPPORT #ifdef NSIS_CONFIG_LICENSEPAGE diff --git a/Source/lang.cpp b/Source/lang.cpp index baa1220b..ac684b74 100644 --- a/Source/lang.cpp +++ b/Source/lang.cpp @@ -21,7 +21,7 @@ #include "util.h" #include "DialogTemplate.h" #include "exehead/resource.h" -#include "version.h" +#include using namespace std; diff --git a/Source/makenssi.cpp b/Source/makenssi.cpp index 7624f85d..63410269 100644 --- a/Source/makenssi.cpp +++ b/Source/makenssi.cpp @@ -27,7 +27,7 @@ #include "build.h" #include "util.h" -#include "version.h" +#include using namespace std; diff --git a/Source/manifest.cpp b/Source/manifest.cpp index de5a558a..9d1789f4 100644 --- a/Source/manifest.cpp +++ b/Source/manifest.cpp @@ -16,7 +16,7 @@ #include "Platform.h" #include "manifest.h" -#include "version.h" +#include namespace manifest { diff --git a/Source/script.cpp b/Source/script.cpp index 5274246c..dc9c7fc2 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -25,7 +25,7 @@ #include "DialogTemplate.h" #include "lang.h" #include "dirreader.h" -#include "version.h" +#include #include "icon.h" #include "exehead/api.h" #include "exehead/resource.h"