Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix win scons #359

Merged
merged 46 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
50d8749
fix a link flag
NQNStudios May 30, 2024
2fe8db1
64-bit build
NQNStudios May 30, 2024
eef1318
another hack to find weirdly named libraries
NQNStudios May 30, 2024
a4df5d3
Fix handling VCRedistInstall.exe
NQNStudios Jun 7, 2024
a4ec85f
add src folders to win-scons include paths
NQNStudios May 30, 2024
f8d99fd
changes I don't remember
NQNStudios Jun 7, 2024
f462f8a
don't comment the thing
NQNStudios Jun 7, 2024
4ef0f46
use path.join
NQNStudios Jun 7, 2024
ae2e8c7
more weird library suffixes
NQNStudios May 30, 2024
d7c1670
fix old python syntax in an SConscript file
NQNStudios May 30, 2024
08c410c
find vcpkg libraries and headers
NQNStudios Jun 7, 2024
b46d260
add icon dir to windows include paths
NQNStudios Jun 7, 2024
bc998dc
more include paths
NQNStudios Jun 7, 2024
2cce46e
include string
NQNStudios Jun 7, 2024
5aa7f76
remove non-recursive os.listdir line
NQNStudios Jun 7, 2024
eec7396
remove bad lib paths
NQNStudios Jun 7, 2024
bc17c01
tools build with env["bits"]
NQNStudios Jun 7, 2024
1ef7df0
debug vcpkg path
NQNStudios Jun 10, 2024
089822e
debug more
NQNStudios Jun 10, 2024
a9185fe
hard-code vcvarsall.bat path, with a note
NQNStudios Jun 10, 2024
f4e3fc2
try win-scons without caching
NQNStudios Jun 10, 2024
5c43754
no binary caching (TEMPORARY)
NQNStudios Jun 10, 2024
7e6b140
disable another thing
NQNStudios Jun 10, 2024
434ceea
fix C: path
NQNStudios Jun 10, 2024
84eaa09
Revert "disable another thing"
NQNStudios Jun 10, 2024
26cd6a0
Revert "no binary caching (TEMPORARY)"
NQNStudios Jun 10, 2024
c44da14
Revert "try win-scons without caching"
NQNStudios Jun 10, 2024
722a183
debug print other lib folders
NQNStudios Jun 10, 2024
65079ef
use a backslash to match
NQNStudios Jun 10, 2024
2e4cdf0
pass in other lib paths
NQNStudios Jun 10, 2024
a3e0dcc
remove debug that didn't work
NQNStudios Jun 10, 2024
068aa45
Fix more old python syntax
NQNStudios May 30, 2024
5040b26
fix syntax again
NQNStudios Jun 10, 2024
84f4860
Revert "fix syntax again"
NQNStudios Jun 10, 2024
8c4b8ca
Revert "Fix more old python syntax"
NQNStudios Jun 10, 2024
9a67136
fix syntax without trying to use f-strings
NQNStudios Jun 10, 2024
c1fc69a
disable windows installer packaging for now
NQNStudios Jun 10, 2024
276b91a
actually disable windows installer
NQNStudios Jun 10, 2024
625aac3
more bundled libs on windows
NQNStudios Jun 10, 2024
951c116
add bin folders for windows installation to find dlls
NQNStudios Jun 10, 2024
4400b1b
fix CheckLib stuff
NQNStudios Jun 11, 2024
8925494
revert relative include paths
NQNStudios Jun 11, 2024
94e8292
Pass 86, not 32, where it's required
NQNStudios Jun 11, 2024
0db1557
test scons pass X86 correctly
NQNStudios Jun 11, 2024
5633bde
make 64-bit builds the default for scons
NQNStudios Jun 12, 2024
8769947
add package flag for building installers
NQNStudios Jun 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@
{
name: build and unit test,
run: '.\.github\workflows\scripts\win\scons-build.bat'
}
},

]
},
# win-mingw: {
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/scripts/win/scons-build.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@

setlocal enabledelayedexpansion

for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -find **/Auxiliary/Build/vcvarsall.bat`) do (
call "%%i" x86_amd64
)
REM This for loop takes a long time to find vcvarsall.bat,
REM so I hard-coded the path in. When Github Runner versions change,
REM the for loop might be needed again to discover the right path.

scons
REM for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -find **/Auxiliary/Build/vcvarsall.bat`) do (
REM @echo "%%i"
REM call "%%i" x86_amd64
REM )

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64

scons bits=64
62 changes: 44 additions & 18 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,25 @@ if platform == "darwin":
break
elif platform == "win32":
if 'msvc' in env['TOOLS']:
vcpkg_prefix = (os.environ['HOME'] if 'HOME' in os.environ else 'C:') + f'/vcpkg/installed/x{env["bits"]}-windows'
vcpkg_prefix = path.join((os.environ['HOME'] if 'HOME' in os.environ else 'C:\\'), 'vcpkg')
vcpkg_installed = path.join(vcpkg_prefix, 'installed', f'x{env["bits"]}-windows')
vcpkg_other_packages = Glob(path.join(vcpkg_prefix, 'packages', f'**x{env["bits"]}-windows'))
vcpkg_other_includes = [path.join(d.get_abspath(), 'include') for d in vcpkg_other_packages]
vcpkg_other_includes = list(filter(path.exists, vcpkg_other_includes))
vcpkg_other_libs = [path.join(d.get_abspath(), 'lib') for d in vcpkg_other_packages]
vcpkg_other_libs = list(filter(path.exists, vcpkg_other_libs))
vcpkg_other_bins = [path.join(d.get_abspath(), 'bin') for d in vcpkg_other_packages]
vcpkg_other_bins = list(filter(path.exists, vcpkg_other_bins))
project_includes = []
for (root, dirs, files) in os.walk('src'):
project_includes.append(path.join(os.getcwd(), root))

include_paths=[path.join(vcpkg_installed, 'include')] + vcpkg_other_includes + project_includes
env.Append(
LINKFLAGS=['/SUBSYSTEM:WINDOWS','/ENTRY:mainCRTStartup','/MACHINE:X86'],
LINKFLAGS=['/SUBSYSTEM:WINDOWS','/ENTRY:mainCRTStartup',f'/MACHINE:X{env["bits"]}'],
CXXFLAGS=['/EHsc','/MD','/FIglobal.hpp'],
INCLUDEPATH=vcpkg_prefix + '/include',
LIBPATH=vcpkg_prefix + '/lib',
CPPPATH=include_paths,
LIBPATH=[path.join(vcpkg_installed, 'lib')] + vcpkg_other_libs + vcpkg_other_bins,
LIBS=Split("""
kernel32
user32
Expand Down Expand Up @@ -269,6 +282,8 @@ env.Append(CPPPATH=Split("""

env['CONFIGUREDIR'] = '#build/conf'
env['CONFIGURELOG'] = '#build/conf/config.log'

bundled_libs = []
if not env.GetOption('clean'):
conf = Configure(env)

Expand All @@ -280,15 +295,14 @@ if not env.GetOption('clean'):
print('zlib must be installed!')
Exit(1)

def check_lib(lib, disp, suffixes=[], versions=[]):
if platform == "win32" and lib.startswith("boost"):
lib = "lib" + lib
def check_lib(lib, disp, suffixes=[], versions=[], msvc_versions=[]):
if "mingw" in env["TOOLS"] and lib.startswith("sfml"):
lib = "lib" + lib
possible_names = [lib]
if platform == "win32":
if 'msvc' in env['TOOLS']:
vc_suffix = '-vc' + env['MSVC_VERSION'].replace('.','')
msvc_version = env['MSVC_VERSION'].replace('.','')
vc_suffix = '-vc' + msvc_version
possible_names.append(lib + vc_suffix)
n = len(possible_names)
for i in range(n):
Expand All @@ -312,8 +326,8 @@ if not env.GetOption('clean'):
print(" If you're sure it's installed, try passing INCLUDEPATH=...")
Exit(1)

boost_versions = ['-1_54', '-1_55', '-1_56', '-1_57', '-1_58'] # This is a bit of a hack. :(
bundled_libs = []
boost_versions = ['-1_84'] # This is a bit of a hack. :(
suffixes = ['-mt', f'-mt-x{env["bits"]}']


check_header('boost/lexical_cast.hpp', 'Boost.LexicalCast')
Expand All @@ -322,8 +336,8 @@ if not env.GetOption('clean'):
check_header('boost/any.hpp', 'Boost.Any')
check_header('boost/math_fwd.hpp', 'Boost.Math')
check_header('boost/spirit/include/classic.hpp', 'Boost.Spirit.Classic')
check_lib('boost_system', 'Boost.System', ['-mt'], boost_versions)
check_lib('boost_filesystem', 'Boost.Filesystem', ['-mt'], boost_versions)
check_lib('boost_system', 'Boost.System', suffixes, boost_versions)
check_lib('boost_filesystem', 'Boost.Filesystem', suffixes, boost_versions)
check_lib('sfml-system', 'SFML-system')
check_lib('sfml-window', 'SFML-window')
check_lib('sfml-audio', 'SFML-audio')
Expand Down Expand Up @@ -362,6 +376,8 @@ env.Append(CPPDEFINES=["TIXML_USE_TICPP"])
if platform == "win32":
# For the *resource.h headers
env.Append(CPPPATH=["#rsrc/menus"])
# Icons
env.Append(CPPPATH=["#rsrc/icons/win"])

if platform == "darwin":
env.Append(LIBS=Split("""
Expand Down Expand Up @@ -422,14 +438,23 @@ if platform == "darwin":
binary = path.join(install_dir, targ + '.app', 'Contents/MacOS', targ)
env.Command(Dir(target_dir), binary, [Delete(target_dir), bundle_libraries_for])
elif platform == "win32":
bundled_libs = Split("""
bundled_libs += Split("""
libsndfile-1
openal32
sfml-audio-2
sfml-graphics-2
sfml-system-2
sfml-window-2
zlib1
freetype
vorbis
vorbisfile
vorbisenc
ogg
FLAC
bz2
brotlidec
brotlicommon
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something seems to be wrong here. What on earth is "brotli", and why is bz2 being bundled when we don't use it?

I don't think we use vorbis/ogg/FLAC, either, though it wouldn't hurt to include it for use by mods someday. Including freetype is fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it seems wrong, but the Visual Studio build outputs all of those DLLs, and the scons build won't launch without them bundled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean it "outputs" all of those DLLs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're all in the build directory Visual Studio outputs, and if you rename one of them to something else, the binary won't launch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So then the question is, what exactly is causing them to be required? They shouldn't be required, since we don't use them anywhere. Are they transitive dependencies of something else? If so, the something else should be built in a way that doesn't require them.

""")
target_dirs = ["#build/Blades of Exile", "#build/test"]
for lib in bundled_libs:
Expand All @@ -447,22 +472,23 @@ elif platform == "win32":
break
# Extra: Microsoft redistributable libraries installer
if 'msvc' in env["TOOLS"]:
if path.exists("dep/VCRedistInstall.exe"):
if path.exists("deps/VCRedistInstall.exe"):
env.Install("build/Blades of Exile/", "dep/VCRedistInstall.exe")
else:
print("WARNING: Cannot find installer for the MSVC redistributable libraries for your version of Visual Studio.")
print("Please download it from Microsoft's website and place it at:")
print(" dep/VCRedistInstall.exe")
print(" deps/VCRedistInstall.exe")
# Create it so its lack doesn't cause makensis to break
# (Because the installer is an optional component.)
os.makedirs("build/Blades of Exile", exist_ok=True)
open("build/Blades of Exile/VCRedistInstall.exe", 'w').close()

if platform == "darwin":
env.VariantDir("#build/pkg", "pkg/mac")
SConscript("build/pkg/SConscript")
elif platform == "win32" and subprocess.call(['where', '/Q', 'makensis']) == 0:
env.VariantDir("#build/pkg", "pkg/win")
SConscript("build/pkg/SConscript")
#elif platform == "win32" and subprocess.call(['where', '/Q', 'makensis']) == 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be uncommented or otherwise fixed before I can merge it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The installer part is having weird problems. I didn't want to deal with it because I think an auto-updating deployment target like Itch or Steam is preferable to having an installer at all.

Copy link
Member

@CelticMinstrel CelticMinstrel Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting it on Itch or Steam is fine, but we should support a standalone installer build as well for the benefit of people who don't like using services like Itch or Steam. What kind of weird problems was it having? Maybe there's an issue of using deprecated NSIS stuff or something…

# env.VariantDir("#build/pkg", "pkg/win")
# SConscript("build/pkg/SConscript")

# Cleanup

Expand Down
2 changes: 1 addition & 1 deletion pkg/win/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import os.path as path
Import("env platform")

if str(platform) != "win32":
print "Error: Building for", str(platform), "but trying to create a Windows installer package"
print(f"Error: Building for {platform}, but trying to create a Windows installer package")

env.Depends("data.nsi", ["gen-data.py", "#build/Blades of Exile/data"])

Expand Down
4 changes: 2 additions & 2 deletions pkg/win/gen-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
}

for path, pattern in files.items():
print 'SetOutPath', '"' + makepath("$INSTDIR/" + path + '/') + '"'
print('SetOutPath "' + makepath('$INSTDIR/' + path + '/') + '"')
if type(pattern) == list:
check_files = [root + '/' + path + '/' + x for x in pattern]
else:
check_files = glob(makepath(root + '/' + path + '/' + pattern))
for fname in check_files:
print 'File', '"' + makepath(fname.replace(root, '${RELEASE_DIR}')) + '"'
print('File "' + makepath(fname.replace(root, '${RELEASE_DIR}')) + '"')

10 changes: 5 additions & 5 deletions src/game/boe.menus.win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#include <sstream>
#include <SFML/Graphics/RenderWindow.hpp>
#include "boeresource.h"
#include "universe.hpp"
#include "../universe/universe.hpp"
#include "boe.party.hpp"
#include "boe.infodlg.hpp"
#include "boe.consts.hpp"
#include "spell.hpp"
#include "winutil.hpp"
#include "menu_accel.win.hpp"
#include "../tools/winutil.hpp"
#include "../tools/menu_accel.win.hpp"

// Include this last because some #defines in the Windows headers cause compile errors in my headers.
// Fortunately they're on symbols not used in this file, so this should work.
Expand Down Expand Up @@ -287,7 +287,7 @@ void showMenuBar() {
DrawMenuBar(mainPtr.getSystemHandle());
}

#include "cursors.hpp"
#include "../tools/cursors.hpp"

LRESULT CALLBACK menuProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) {
MSG msg = {handle, message, wParam, lParam};
Expand All @@ -313,7 +313,7 @@ LRESULT CALLBACK menuProc(HWND handle, UINT message, WPARAM wParam, LPARAM lPara
return CallWindowProc(reinterpret_cast<WNDPROC>(mainProc), handle, message, wParam, lParam);
}

#include "fileio.hpp"
#include "../fileio/fileio.hpp"
#include "boe.graphics.hpp"
#include "boe.actions.hpp"
#include "boe.fileio.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/spell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define BoE_DATA_SPELL_HPP

#include <map>
#include <string>
#include "skills_traits.hpp"

// This controls how a spell is cast in combat; YES means it's the same as in town, IMMED means it has a special implementation in town, and TARGET / FANCY both mean it requires target selection.
Expand Down
2 changes: 1 addition & 1 deletion test/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_sources = Glob("""*.cpp""") + Split("""
""")

if str(platform) == "win32" and 'msvc' in env["TOOLS"]:
test = env.Program("#build/bin/boe_test", party_classes + common_sources + test_sources, LINKFLAGS='/nologo /SUBSYSTEM:CONSOLE /MACHINE:X86')
test = env.Program("#build/bin/boe_test", party_classes + common_sources + test_sources, LINKFLAGS=f'/nologo /SUBSYSTEM:CONSOLE /MACHINE:X{env["bits"]}')
else:
test = env.Program("#build/bin/boe_test", test_sources + party_classes + common_sources)

Expand Down
Loading