Archive: Building CVS with scons


Building CVS with scons
I hope someone can point me in the right direction here...

I've just downloaded + installed Python 2.4, scons 0.96.1, Microsoft SDK (core package), Microsoft Visual C++ Toolkit 2003.

When I attempt to compile using details here:

http://nsis.sourceforge.net/index.ph...D=2&tt_news=22

...this is what I'm getting:

C:\NSIS>scons
scons: Reading SConscript files ...
Using default tools configuration
AttributeError: SConsEnvironment instance has no attribute 'RES':
File "SConstruct", line 94:
target = SConscript(dirs = 'Source/exehead', build_dir = build_dir, duplicat
e = 0, exports = exports)
File "C:\Python24\scons\SCons\Script\SConscript.py", line 581:
return apply(method, args, kw)
File "C:\Python24\scons\SCons\Script\SConscript.py", line 508:
return apply(_SConscript, [self.fs,] + files, {'exports' : exports})
File "C:\Python24\scons\SCons\Script\SConscript.py", line 239:
exec _file_ in stack[-1].globals
File "Source\exehead\SConscript", line 77:
res = env.RES(resources)


and with the mstoolkit parameter

C:\NSIS>scons MSTOOLKIT=yes
scons: Reading SConscript files ...
Using Microsoft tools configuration
Checking for main() in C library gdi32... yes
Checking for main() in C library user32... yes
Checking for main() in C library version... yes
Checking for main() in C library pthread... no
Checking for main() in C library stdc++... no
Checking for main() in C library iconv... no
Checking for main() in C library libiconv... no

scons: *** Multiple ways to build the same target were specified for: AdvSplash.
dll
File "Contrib\AdvSplash\SConscript", line 18, in ?

Try to update your Scons to version 0.96.90 to see if that happens again.


I had already tried that actually, but the 0.96.1 seemed to be the better of the two! Anyway, here's the log from that version

C:\NSIS>scons
scons: Reading SConscript files ...
TypeError: cannot concatenate 'str' and 'NoneType' objects:
File "SConstruct", line 47:
prefix = GetLaunchDir() + os.sep
File "C:\Python24\scons\SCons\Script\SConscript.py", line 532:
env = self.factory()
File "C:\Python24\scons\SCons\Script\SConscript.py", line 512:
default_env = SCons.Defaults.DefaultEnvironment()
File "C:\Python24\scons\SCons\Defaults.py", line 65:
_default_env = apply(SCons.Environment.Environment, args, kw)
File "C:\Python24\scons\SCons\Memoize.py", line 815:
klassdict['__init__'] = lambda self, *args, **kw: newinit(self, args, kw)
File "...\SCons\Memoizer-init-lambda<C:\Python24\scons\SCons\Memoize.py>", lin
e 1:
None
File "C:\Python24\scons\SCons\Memoize.py", line 774:
apply(actual_init, (self,)+args, kw)
File "C:\Python24\scons\SCons\Memoize.py", line 1:
"""Memoizer
File "C:\Python24\scons\SCons\Memoize.py", line 777:
apply(super(cls, self).__init__, args, kw)
File "C:\Python24\scons\SCons\Memoize.py", line 815:
klassdict['__init__'] = lambda self, *args, **kw: newinit(self, args, kw)
File "...\SCons\Memoizer-init-lambda<C:\Python24\scons\SCons\Environment.py>",
line 465:
None
File "C:\Python24\scons\SCons\Memoize.py", line 774:
apply(actual_init, (self,)+args, kw)
File "C:\Python24\scons\SCons\Environment.py", line 511:
apply_tools(self, tools, toolpath)
File "C:\Python24\scons\SCons\Environment.py", line 129:
env.Tool(tool, toolpath)
File "C:\Python24\scons\SCons\Environment.py", line 1055:
tool(self)
File "C:\Python24\scons\SCons\Tool\__init__.py", line 87:
apply(self.generate, ( env, ) + args, kw)
File "C:\Python24\scons\SCons\Tool\default.py", line 40:
for t in SCons.Tool.tool_list(env['PLATFORM'], env):
File "C:\Python24\scons\SCons\Tool\__init__.py", line 382:
c_compiler = FindTool(c_compilers, env) or c_compilers[0]
File "C:\Python24\scons\SCons\Tool\__init__.py", line 301:
if t.exists(env):
File "C:\Python24\scons\SCons\Tool\intelc.py", line 278:
top = get_intel_compiler_top()
File "C:\Python24\scons\SCons\Tool\intelc.py", line 142:
top = get_intel_registry_value('ProductDir', version, abi)
File "C:\Python24\scons\SCons\Tool\intelc.py", line 69:
K = 'Software\\Intel\\Compilers\\C++\\' + version + '\\'+abi.upper()


Same for both with and without the MSTOOLKIT=yes parameter.

If you're using the toolkit you must use MSTOOLKIT=yes. It might not work because it can not find cl.exe in the path. Try running scons using the Visual C++ Toolkit 2003 Command Prompt. The toolkit installs a link to it on the start menu and in its installation directory.


Ok well I finally kinda got it working after a lot of messing around (not knowing what I'm doing!).

MakeLangId wont complile because it cant find AFXRES.H or WINRES.h.

halibut fails to compile because the environment paths aren't set up correctly. The MSTOOLKIT bit is effectivly ignored in the SConscript in its folder as only the default environment is used.

You also need to ensure hhc is installed and its folder added to the 'path' environment variable.

Download it from here:

http://msdn.microsoft.com/library/de...pDownloads.asp

contrib/startmenu also wont compile. Needs afxres.h and winres.h too.


Once all that's out of the way, I'm left with this:

C:\NSIS>scons MSTOOLKIT=yes
scons: Reading SConscript files ...
Using Microsoft tools configuration
Checking for main() in C library gdi32... yes
Checking for main() in C library user32... yes
Checking for main() in C library version... yes
Checking for main() in C library pthread... no
Checking for main() in C library stdc++... no
Checking for main() in C library iconv... no
Checking for main() in C library libiconv... no
Using Microsoft tools configuration
scons: done reading SConscript files.
scons: Building targets ...
scons: *** Source `Contrib\AdvSplash\AdvSplash' not found, needed by target `build\AdvSplash\AdvSplash.map'. Stop.
scons: building terminated because of errors.

It's now also very easy to build NSIS using the free Visual C++ Toolkit 2003 and Platform SDK.
Kichik just forgot to mention about the "HTML Help Workshop" to compile the docs.

Now, about the problem, it's maybe because you only have the core of Platform SDK. I downloaded all packages, and the latest update for WinXP SP2, and the compilation works.

Ok, it seems the beta of scons works ok but the old one wont.

I'm doing this build on a clean install of Windows 2003, so chances are, others will need to do them too.

I expect you lot have already got loads of bits installed which is making life easier for you!

Copying over the missing header files from MakeLangId and StartMenu isn't a big deal but I'd like the 'Documentation' chunk of the SContruct file fixed so that the correct environment variables are set up and it doesn't again complain about not being able to find cl.exe - which obviously it has been able to find ok for the rest of the script before that point.

I ended up changing SConstruct

stub_env = envs[0]
makensis_env = envs[1]
plugin_env = envs[2]
util_env = envs[3]


to

stub_env = envs[0]
makensis_env = envs[1]
help_env = makensis_env.Copy()
plugin_env = envs[2]
util_env = envs[3]


and then

halibut = SConscript(
dirs = 'Docs/src/bin/halibut',
build_dir = build_prefix + 'halibut',
duplicate = 0
)


to

halibut = SConscript(
dirs = 'Docs/src/bin/halibut',
build_dir = build_prefix + 'halibut',
duplicate = 0,
exports = {'env' : help_env.Copy()}
)


I then changed Docs\src\bin\halibut\SConscript

by changing:

env = Environment()


to

Import('env')


It then compile / linked just fine.

I've no idea if what I've done above is ok, but it works... and that's all that matters!

halibut SConscript was indeed using the wrong environment. I've already fixed this in the latest CVS version in a manner similar to what you've suggested.

However, the current CVS can fail building NSIS Update. You can use the -k command line option to keep building anyway.


Ok, I'll keep an eye out for the updated CVS version, it still seems to show the old one on sourceforge.

Can I also point out the makensis.nsi script now fails for 2 reasons (rather than just the 1 it's failed on for a while now).

1. 'bin2h.exe' is still referenced.

2. 'Contrib\Library\LibraryLocal\*.exe' no longer exists because the LibraryLocal.exe is in the 'build\Library\LibraryLocal' folder.


Originally posted by kichik
halibut SConscript was indeed using the wrong environment. I've already fixed this in the latest CVS version in a manner similar to what you've suggested.
Oops, was thinking of something else. It's really fixed in CVS now.

A new problem building the docs:


C:\projects\NSIS>scons -j4 MSTOOLKIT=yes
scons: Reading SConscript files ...
Using Microsoft tools configuration
Checking for main() in C library gdi32... (cached) yes
Checking for main() in C library user32... (cached) yes
Checking for main() in C library version... (cached) yes
Checking for main() in C library pthread... (cached) no
Checking for main() in C library stdc++... (cached) no
Checking for main() in C library iconv... (cached) no
Checking for main() in C library libiconv... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
Copy("C:\projects\NSIS\build\release\Docs", "Docs\src/../style.css")
scons: *** [build\release\Docs\NSIS.chm] Permission denied
scons: building terminated because of errors.


The problem is that the files being copied in the Docs Sconscript file are read-only and that is killing Scons.
So either the destination files should be deleted first or the copy action should force an overwrite.

installed latest python (2.4.1) and scons (0.96.90).
opening console at my nsis root (E:\Programme\NSIS\) and typing "scons" just gives me an error "file or command not found".

what am i doing wrong?

read the news carefully, theres nothing else mentioned.

or do i really need the vcpp toolkit?


Make sure that python, VC toolkit and hhc.exe are in your path.


Can anyone fix it so that the !InstallNSIS.BAT file (and the script it calls) actually works?

It's great that I can now compile the CVS data without any critical errors, but if I then get stuck building the installer, it's not much use ;)

Thanks!


Make sure that python, VC toolkit and hhc.exe are in your path.
that they are in WHICH path?

and why isn't that fact mentioned anywhere in the documentation/news?

if i install python, it installs to "C:\Program Files\Python24" (on english systems), on mine this would be E:\Programme\Python.
scons uses the same dir:
E:\Programme\Python\scons\SCons
(doubled folder may be a bug in the installer of scons - they didnt use nsis :D)

nsis is installed in E:\Programme\NSIS
vctoolkit (which i now downloaded and installed) is in
"E:\Programme\Microsoft VisualC++ 2003 Toolkit"

now, what files do i have to put to which directories manually?

if you type 'set path' from the command prompt, you should see e:\programme\python in there somewhere. If not, you need to add it via the 'properties -> Advanced -> Environment variables' bit when you right click My Computer.

After that, it should just be 'scons MSTOOLKIT=yes' to get it to compile. Scons configures the other path settings it needs. Dont forget you need hhc (help workshop from microsoft) installed too.


thanks, it works!!!
great!
but PLEASE ADD THIS immediately to a faq or similar.


E:\Programme\NSIS>scons -j4 MSTOOLKIT=yes
scons: Reading SConscript files ...

scons: *** Path does not exist for option CPPPATH:
File "SConstruct", line 61, in ?
E:\Programme\NSIS>

Ermm don't know the answer to that one, sorry!

if you type 'set' from the command prompt, do you get a line like:

VCToolkitInstallDir=C:\Program Files\Microsoft Visual C++ Toolkit 2003\

?? (Obviously your path will be different if you changed it from the default)


i do get this path.


ok, still no idea then.

I thought I'd had pretty much every problem is was possible to have. Now it seems I didn't ;)


iceman_k, that's very weird... SCons first tries to copy the file and then set the destination to writable:

def _copy_func(src, dest):
shutil.copy2(src, dest)
st=os.stat(src)
os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)
I'll see if I can find a workaround or if I'm reading this right later.

LIGHTNING UK!, makensis.nsi will be fixed later. I'm not too sure what I want to do with it yet. I'd be great if the SCons script could generate the installer script too so I only have to specify what to install and where only once. For now, you can use NSIS from the build directory or use:
scons PREFIX="C:\Program Files\NSIS" install


Comm@nder21, are you using the latest version from CVS? I don't get any error with CPPPATH and I'm using the same versions of Python and SCons as you. Is anyone else getting this error?

Please don't post every SCons related question or problem in this thread. It'll get pretty huge and hard to follow.

BTW, I've finally managed to get wine to compile on my linux. It only took a night. I've also managed to get the VC Toolkit, Python and SCons to run on it. With some minor changes to everything involved, NSIS builds just fine. All except the CHM which still needs some love. A complete build took only 3 and half hours on my all so powerful Pentium 100. Once it's completely working, it'll be used to create real nightly snapshots.

yep, i updated it just atm.

could you have a look at your environment vars if theres one called CPPPATH ?

i don't have one, that may be the problem.

installed all programs with their native installer programs, though.


I don't have CPPPATH in my environment. CPPPATH is an option which can be used on the command line. It has a default value of None. None should be a "valid" path. Run scons with --debug=stacktrace and attach the stack trace. To get around this, you can try giving it a real path in CPPPATH.


iceman_k, I was looking at the wrong place. It's not the copy function that fails, it's the deletion of the target file before the installation. It does however make some sense as read only files shouldn't be touched. I am willing to accept with this reasonable limitation. If you wish, you can submit a bug report to scons.


updated cvs, which contained a new sconstruct scriptfile, but gave the same error.
then ran with your debug instruction:

SCons error: Warning: stacktrace is not a valid debug type
/edit:
updated scons to 0.96.90, like you posted in the other thread.
now i get other errors, which i think are results of missing platform sdk :)
(this **** microsoft server gives me no more than 10kbit/s, no pausable downloads, not more than 2 connections a time!!!!)

downloaded and installed platform sdk (under admin account).
get the following errors:

E:\Programme\NSIS>scons -j4 MSTOOLKIT=yes
scons: Reading SConscript files ...
TypeError: cannot concatenate 'str' and 'NoneType' objects:
File "SConstruct", line 54:
defenv = Environment()
File "E:\Programme\Python\scons\SCons\Memoize.py", line 815:
klassdict['__init__'] = lambda self, *args, **kw: newinit(self, args, kw)
File "...\SCons\Memoizer-init-lambda<E:\Programme\Python\scons\SCons\Memoize.p
y>", line 1:
None
File "E:\Programme\Python\scons\SCons\Memoize.py", line 774:
apply(actual_init, (self,)+args, kw)
File "E:\Programme\Python\scons\SCons\Memoize.py", line 1:
"""Memoizer
File "E:\Programme\Python\scons\SCons\Memoize.py", line 777:
apply(super(cls, self).__init__, args, kw)
File "E:\Programme\Python\scons\SCons\Memoize.py", line 815:
klassdict['__init__'] = lambda self, *args, **kw: newinit(self, args, kw)
File "...\SCons\Memoizer-init-lambda<E:\Programme\Python\scons\SCons\Environme
nt.py>", line 465:
None
File "E:\Programme\Python\scons\SCons\Memoize.py", line 774:
apply(actual_init, (self,)+args, kw)
File "E:\Programme\Python\scons\SCons\Environment.py", line 511:
apply_tools(self, tools, toolpath)
File "E:\Programme\Python\scons\SCons\Environment.py", line 129:
env.Tool(tool, toolpath)
File "E:\Programme\Python\scons\SCons\Environment.py", line 1055:
tool(self)
File "E:\Programme\Python\scons\SCons\Tool\__init__.py", line 87:
apply(self.generate, ( env, ) + args, kw)
File "E:\Programme\Python\scons\SCons\Tool\default.py", line 40:
for t in SCons.Tool.tool_list(env['PLATFORM'], env):
File "E:\Programme\Python\scons\SCons\Tool\__init__.py", line 382:
c_compiler = FindTool(c_compilers, env) or c_compilers[0]
File "E:\Programme\Python\scons\SCons\Tool\__init__.py", line 301:
if t.exists(env):
File "E:\Programme\Python\scons\SCons\Tool\intelc.py", line 278:
top = get_intel_compiler_top()
File "E:\Programme\Python\scons\SCons\Tool\intelc.py", line 142:
top = get_intel_registry_value('ProductDir', version, abi)
File "E:\Programme\Python\scons\SCons\Tool\intelc.py", line 69:
K = 'Software\\Intel\\Compilers\\C++\\' + version + '\\'+abi.upper()
E:\Programme\NSIS>
system:
- windows xp sp2
- psdk for sp2
- vc toolkit 2003
- python 2.41
- scons 0.96.90

all installed without errors.

Make sure to register the PSDK paths.
c:\program files\microsoft sdk\setenv.bat


i did


i now probably know, why scons makes so much problems.

running it from cmd.exe gives me the last reported errors.

running it from the vc toolkit prompt brings me the error, that it couldn't find the psdk.
so, at first it doesnt find the vc toolkit.

the psdk is properly installed, and registered, but the scons script searches the wrong registry values.
i searched through the scons script, which contains the following lines:
mstoolkit.py

PlatformSDKDir = ""
try:
PlatformSDKDir = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\MicrosoftSDK\Directories\Install Dir')[0]
PlatformSDKDir = str(PlatformSDKDir)
except SCons.Util.RegError:
raise SCons.Errors.InternalError, "The Platform SDK directory was not found in the registry."
it searches in HKLM\SOFTWARE\Microsoft\MicrosoftSDK\Directories\Install Dir
this is wrong.
on my system (see above for details) the install dir is stored in the key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\B44C7E10-89BD-4A32-A3BF-D9D0BC4C9A05
as value:
Install Dir

changing this solves the problem with the psdk.

well, it now compiles (with -k) but has lots of troubles.
it always tries to run
"E:\Programme\Microsoft Platform SDK\\bin\Win64\link.exe"
which of course doesn't exist.

1. theres a \ too much
2. i'm running win32 not 64.

is there ANYONE out there who has a WORKING script?


found the link.exe after some searching:
it's not provided with the psdk.
it's provided with the vc-toolkit:
E:\Programme\Microsoft Visual C++ Toolkit 2003\bin\link.exe

why does scons use that ****** paths?


Install the PSDK for Windows 2003 server and it should work. See this thread for more information.


finally got it working.
some more problems:
the environment vars still don't work.
with latest cvs (updated today) it still does not find the vc++ toolkit itself, even if the vars are set correctly.
the environment code for scons is simply wrong, there were already solutions posted, you may also find one at this link:
http://www.scons.org/faq.php#SS_4_3
plz update the sconstruct file in cvs.

also, theres still the wrong registry path set in the mstoolkit.py:

SOFTWARE\Microsoft\MicrosoftSDK\Directories\Install Dir
this is your one. its wrong. i tried it both with the xpsp2 sdk and the 2003sp1 one.
for the 2003sp1 one (the only one really working) it must be:
SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3\Install Dir
pls fix that too.
thanks.

mstoolkit.py adds the bin directory of the toolkit to the path, there's no need to add the entire os path to scons' path. I have updated it to give up if it can't find VCToolkitInstallDir in the environment instead of trying "C:\Program Files\Microsoft Visual C++ Toolkit 2003".

I have tried installing a fresh copy of PSDK on a fresh computer and indeed the registry key read in mstoolkit.py was not there. Seems like they're removed it in one of the latest versions. I have updated mstoolkit.py to look in the MSSDK environment variable. I have also made it search that registry key with the GUID, even though it's probably a bad idea. It doesn't exist on the older versions, so it'll probably change in the future.

So now you must have two envrionment variables:


Thanks for the information.

I have tried building on another with system which has just the toolkit and the Platform SDK and I got an error resulting from this bug. It can be easily identified by the last place in the stack trace which is intelc.py.

This bug has already been fixed in the latest CVS version of SCons. However, no versions were released since 0.96.90. Until version 0.97 is released you can use this build I made from CVS today. Note that unlike 0.96.*, it doesn't install scons.bat in the main Python directory but in a subdirectory called Scripts. So if you want to change your PATH environment variable so you can just type 'scons' and not C:\Python\Scripts\scons.bat, don't forget to add C:\Python\Scripts.


This is very off topic but it is nice to see LIGHTING UK! on the forums after the fall of dvd decrypter.


Kickhik:
Any idea about what could be causing this problem:

C:\projects\NSIS\Development>scons MSTOOLKIT=yes
scons: Reading SConscript files ...
Delete("nsis-27-Jul-2005.cvs")
Delete(".instdist")
Delete(".test")
Using Microsoft tools configuration
Checking for main() in C library gdi32... (cached) yes
Checking for main() in C library user32... (cached) yes
Checking for main() in C library version... (cached) yes
Checking for main() in C library pthread... (cached) no
Checking for main() in C library stdc++... (cached) no
Checking for main() in C library iconv... (cached) no
Checking for main() in C library libiconv... (cached) no
Checking for main() in C++ library cppunit... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
Copy("C:\projects\NSIS\Development\build\release\Docs\chm", "Docs\src/../style.css")
scons: *** [build\release\Docs\chm\NSIS.chm] Permission denied
scons: building terminated because of errors.
I don't get it with a clean build, but I still get it when I try rebuilding. Is there some verbose mode I can enable to get more details?

Did you put the HTML Help compiler is your path?


It works fine if I do a clean build- it builds the CHM and everything. However, if I delete build\release\Docs\chm\NSIS.chm and run Scons again, it fails.
The reason it fails is that the Copy() commands below do not change the readonly attribute of the files.


chm_builder = Builder(
action = [
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)),
hhc_action
]
)

Since I have configured my CVS with watch/edit enabled, non-edited files have the readonly attribute set. If the build directory is empty, these are copied over without a problem.
However, the next time I run Scons, the copy fails because the target files are readonly.
This is in spite of the _copy_func definition ostensibly changing the status to writeable:

def _copy_func(src, dest):
shutil.copy2(src, dest)
st=os.stat(src)
os.chmod(dest, stat.S_IMODE(st[stat.ST_MODE]) | stat.S_IWRITE)


So, eventually, my work around was to create a build.bat file which fixes the readonly attribute for me:

setlocal
set MSSDK=C:\Program Files\Microsoft SDK
set VCToolkitInstallDir=C:\Program Files\Microsoft Visual C++ Toolkit 2003
path %path%;c:\python;c:\Program Files\HTML Help Workshop
call scons MSTOOLKIT=yes > build.log 2>&1
if exist build\release\Docs\chm (
pushd build\release\Docs\chm
if exist style.css attrib -r -s -h -a style.css
if exist chmlink.js attrib -r -s -h -a chmlink.js
if exist nsis.hhp attrib -r -s -h -a nsis.hhp
popd
)
if exist build\release\Docs\html (
pushd build\release\Docs\html
if exist style.css attrib -r -s -h -a style.css
popd
)
call scons MSTOOLKIT=yes PREFIX="C:\Projects\NSIS" install >> build.log 2>&1
endlocal