disable generation after shards install for Windows
mswieboda opened this issue · comments
Can we disable the generation via the Makefile for Windows, or maybe not run make
for windows after shards install
?
I have been successful at running a crsfml game on Windows using crystal 1.5.1
by mainly following your linked video in the README, thanks! However, some of the artifacts from crystal GH actions are no longer available, but regardless I think the make
would still fail after shards install
. make
failing means that none of the shards are included in the lib
folder, of any dependent libraries using crsfml
. (I'm only including crsfml, or a shard that includes only crsfml, so not sure if it affects any other added shards).
Here's the error, but it's clearly because the generation/Makefile was meant for non-Windows (no complaints there, not asking for work towards that effort!)
D:\code\cr\shoot>shards install
Resolving dependencies
Fetching https://github.com/mswieboda/game_sf.git
Fetching https://github.com/oprypin/crsfml.git
Installing crsfml (2.5.2)
Postinstall of crsfml: make
Failed postinstall of crsfml on make:
g++ -Wno-deprecated-declarations -I '/usr/include' -o src/system/ext.o -c src/system/ext.cpp
process_begin: CreateProcess(NULL, g++ -Wno-deprecated-declarations -I /usr/include -o src/system/ext.o -c src/system/ext.cpp, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:21: src/system/ext.o] Error 2
Here's the workaround I do:
{% if flag?(:win32) %}
require "../../crsfml/src/crsfml"
require "../../crsfml/src/audio"
{% else %}
require "crsfml"
require "crsfml/audio"
{% end %}
Instead of the normal require "crsfml"
I require the source from the checked out crsfml
repo, side by side with the project including crsfml
. This works, but ideally I'd like to not to have to do that, because I can't use a wrapper shard dependent on crsfml
as it won't install in lib
when on Windows. I realize the generation won't work on Windows, and I'm not expecting changes, or work towards that manner, I just would like to be able to successfully shards install
, so I don't need the workaround, and could successfully include a wrapper shard using crsfml
internally.
I'm going to try to fork the repo, and try to disable the make
for Windows on shards install
, or worst-case do-so from within the Makefile
. Not sure if that's the best approach, but figured it's in the right direction. Just thought I'd post here for history, and if others have similar interests of doing this on Windows too (it's been working great on a mac, and linux). I realize I'm probably in the minority here, but I love crystal, and want to use it for game jams, and unfortunately that requires something runnable on Windows.
... holy shit. I didn't realize there's a
shards install --skip-postinstall
option, seems like that will work, gonna close this. At least others might find that helpful
Here's the workaround I do:
{% if flag?(:win32) %} require "../../crsfml/src/crsfml" require "../../crsfml/src/audio"
That particular part is not necessary, you can just manually put it into the lib
folder.
As for the overall issue, that's
okay, I'll try moving it to the lib
folder. That worked thanks a bunch!
Without moving the folder manually it does fail, although crsfml
was in the lib
folder after shards install --skip-postinstall
, but it must have been missing something
crystal build src/shoot.cr -o build/shoot_test.o --error-trace
LINK : fatal error LNK1181: cannot open input file 'D:\code\cr\shoot\lib\crsfml\src\audio\ext.obj'
Error: execution of command failed with code: 2: `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe" /nologo _main.obj U-I-nt32.obj E-xception5858C-allS-tack.obj A-rray40S-tring41.obj P-ointer40S-tring41.obj I-nt32.obj F-loat64.obj I-nt64.obj A-rgumentE-rror.obj P-ointer40L-ibC-5858C-O-N-T-E-X-T-41.obj A-rray40P-ointer40V-oid4141.obj P-ointer40P-ointer40V-oid4141.obj E-N-V-.obj C-rystal5858S-ystem5858E-nv.obj S-tring.obj P-ointer40U-I-nt841.obj T-uple40S-tring4432S-tring4432S-tring41.obj E-numerable5858R-eflect40I-nt3241.obj G-C-.obj U-I-nt64.obj S-taticA-rray40U-I-nt16443225641.obj S-lice40T-41.obj S-lice40U-I-nt1641.obj W-inE-rror.obj S-lice40U-I-nt841.obj P-ointer40U-I-nt1641.obj I-ndexE-rror.obj C-har5858R-eader.obj E-xc
...
D:\code\cr\shoot\lib\crsfml\src\graphics\ext.obj sfml-graphics.lib D:\code\cr\shoot\lib\crsfml\src\window\ext.obj sfml-window.lib D:\code\cr\shoot\lib\crsfml\src\system\ext.obj sfml-system.lib pcre.lib gc.lib /ENTRY:wmainCRTStartup iconv.lib advapi32.lib Kernel32.lib shell32.lib ole32.lib WS2_32.lib legacy_stdio_definitions.lib DbgHelp.lib libcmt.lib`
make: *** [Makefile:20: build_test] Error 2