danielga / garrysmod_common

A repository of common bits for compilation projects based on Garry's Mod.
https://github.com/danielga/garrysmod_common
Other
115 stars 38 forks source link

Premake5 /usr/bin/bitmap:1: unexpected symbol near '<\127>' #82

Closed dankmolot closed 2 years ago

dankmolot commented 2 years ago

Enviroment

OS - Debian GNU/Linux 10 (buster) Premake5 - premake5 (Premake Build Script Generator) 5.0.0-beta1 garrysmod_common - master branch 72f62b4bb2ee33e05bfbc3ea79e48ba54e952904

Premake script

-- premake5.lua
PROJECT_GENERATOR_VERSION = 3

newoption {
    trigger = "gmcommon",
    description = "Sets the path to the garrysmod_common (https://github.com/danielga/garrysmod_common) directory",
    value = "path to garrysmod_common directory"
} 

gmcommon = _OPTIONS.gmcommon or os.getenv "GARRYSMOD_COMMON"
assert(gmcommon, "You didn't provide a path to your garrysmod_common (https://github.com/danielga/garrysmod_common) directory.")

include(gmcommon)

CreateWorkspace { name = "network" }
    CreateProject { serverside = true }
        IncludeHelpersExtended()
        IncludeSDKTier0()
        IncludeSDKTier1()
        IncludeSDKCommon()
        IncludeDetouring()

        includedirs "third-party/lua_threading"

Output

runner@runner-1:~/gmsv_network$ premake5 gmake --gmcommon="$HOME/garrysmod_common"
Selected version 3 of the project generator
Error: /usr/bin/bitmap:1: unexpected symbol near '<\127>'

How to fix

Delete or move /usr/bin/bitmap, so premake5 can't find it:

runner@runner-1:~/gmsv_network$ premake5 gmake --gmcommon="$HOME/garrysmod_common"
Selected version 3 of the project generator
Error: /usr/bin/bitmap:1: unexpected symbol near '<\127>'
runner@runner-1:~/gmsv_network$ sudo mv /usr/bin/bitmap /usr/bin/bitmap.old
runner@runner-1:~/gmsv_network$ premake5 gmake --gmcommon="$HOME/garrysmod_common"
Selected version 3 of the project generator
Building configurations...
Running action 'gmake'...
Generated projects/linux/gmake/Makefile...
Generated projects/linux/gmake/gmsv_network.make...
Generated ../garrysmod_common/projects/linux/gmake/helpers.make...
Generated ../garrysmod_common/projects/linux/gmake/helpers_extended.make...
Generated ../garrysmod_common/scanning/projects/linux/gmake/Makefile...
Generated ../garrysmod_common/sourcesdk-minimal/projects/linux/gmake/tier1.make...
Generated ../garrysmod_common/sourcesdk-minimal/projects/linux/gmake/LZMA.make...
Generated ../garrysmod_common/detouring/projects/linux/gmake/detouring.make...
Generated ../garrysmod_common/detouring/projects/linux/gmake/hde.make...
Generated ../garrysmod_common/detouring/projects/linux/gmake/minhook.make...
Done (684ms).

Also found simillar issue: https://github.com/hoelzro/linotify/issues/18 Alternatively, change the package.cpath (maybe works, not tested)

Current package.path

/usr/local/share/lua/5.3/?.lua;/usr/local/share/lua/5.3/?/init.lua;/usr/local/lib/lua/5.3/?.lua;/usr/local/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua

Current package.cpath

/usr/local/lib/lua/5.3/?.so;/usr/local/lib/lua/5.3/loadall.so;./?.so;/usr/bin/?.so

But there must be another way. These options are a little hacky, maybe something in garrysmod_common is the problem? (exactly in it, but where?)

danielga commented 2 years ago

Hmm, this is a weird one. I have an idea that I'd appreciate you try, without any other changes. Replace include("bitmap") at the bottom of garrysmod_common/sourcesdk-minimal/premake5.lua with include("./bitmap"). It's weird that include is trying to open /usr/bin/bitmap but it's possible it's a premake-core bug. I'd expect it to search locally before using PATH.

dankmolot commented 2 years ago

Changed to include('./bitmap'), but it didn't help. It also tries to load /usr/bin/bitmap. Cloned again garrysmod_common and changed include, nothing changed. Now I will try to use the alpha version of premake5.

dankmolot commented 2 years ago

It looks like this is a problem with the beta release of premake5. With premake5 alpha 16, everything works fine. I will open an issue.

dankmolot commented 2 years ago

Here issue on premake repository premake/premake-core#1783

dankmolot commented 2 years ago

Interesting fact. The problem is not with the premake5 version, but with the location of the binary. If premake5 is in /usr/bin, it will search /usr/bin first.

danielga commented 2 years ago

Good find. This is definitely a premake-core bug because, even if you do include("./bitmap"), the error occurs. And that one should definitely search from the current working directory.

danielga commented 2 years ago

That also explains why I never got (or could reproduce) the issue. I always have user installed binaries in a user directory added to the PATH variable.

danielga commented 2 years ago

I'll close this off as a third-party issue.