premake / premake-core

Premake
https://premake.github.io/
BSD 3-Clause "New" or "Revised" License
3.13k stars 611 forks source link

Api in _preload.lua inaccessible #2198

Closed Codinablack closed 3 months ago

Codinablack commented 3 months ago

What seems to be the problem? Trying to use things like "enableunitybuild" or "vsprops" doesn't work.

What did you expect to happen? It should generate those visual studio properties and generate no error when running premake

What have you tried so far? I have tried moving to every single scope section of the script, while also trying different formats for the function enableunitybuild "On" enableunitybuild {"On"}

ect ect.

How can we reproduce this? Try to use any of the api that is located in __preload.lua and you get an error about "undefined global" and such. I don't know about any or all, but I know for sure the vsprops and the unity build doesn't work

What version of Premake are you using? premake5.0.0.-beta2

nickclark2016 commented 3 months ago

Can you share the full premake file you're having issues with, as well as how you are running premake?

Codinablack commented 3 months ago

Can you share the full premake file you're having issues with, as well as how you are running premake?

I can. It doesn't change the fact that you can try on any premake.lua file for even the very most basic hello world program and the premake5.exe won't recognize it, but sure I can provide you with the exact script I tried to use it with.


include "packages/conandeps.premake5.lua"

workspace "Titan"
   configurations { "Debug", "Release"}
   platforms { "64", "32"}
   location "./projectfiles"
   editorintegration "On"

   project        "Titan"
      kind        "ConsoleApp"
      language    "C++"
      cppdialect  "C++20"
      targetdir   "build/%{cfg.buildcfg}/bin"
      objdir      "build/%{cfg.buildcfg}/obj"
      location    "./projectfiles"
      files { "src/**.cpp", "src/**.h" }
      flags {"LinkTimeOptimization", "MultiProcessorCompile"}
      vectorextensions {"AVX"}
      enableunitybuild "On"

      filter "configurations:Debug"
         defines { "DEBUG" }
         symbols "On"
         optimize "Debug"
      filter {}

      filter "configurations:Release"
         defines { "NDEBUG" }
         symbols "On"
         optimize "Speed"
      filter {}

      filter "platforms:32"
         architecture "x86"
      filter {}

      filter "platforms:64"
         architecture "amd64"
      filter {}

      filter "system:not windows"
         buildoptions { "-Wall", "-Wextra", "-Wnon-virtual-dtor", "-Wold-style-cast", "-pedantic", "-Werror", "-pipe", "-fvisibility=hidden" }
      filter {}

      filter "system:windows"
         openmp "On"
         characterset "MBCS"
      filter {}

      filter "toolset:gcc"
         buildoptions { "-fno-strict-aliasing" }
      filter {}

      filter "toolset:clang"
         buildoptions { "-Wimplicit-fallthrough", "-Wmove" }
      filter {}

      filter { "system:macosx", "action:gmake" }
         buildoptions { "-fvisibility=hidden" }   
      filter {}

      conan_setup()
      linkoptions {"/IGNORE:4099"}
      --characterset "MBCS"
      intrinsics   "On"

There is my lua file, and the way I call it is by using a python script, with the exe in the same folder, here is the py script

import subprocess

def ConfigureConan():
    subprocess.run(["conan", "profile", "detect"])

def RunConan(buildType):
    subprocess.run(["conan",  "install", ".", "--build=missing", f"--settings=build_type={buildType}"])

def RunPremake(target):
    subprocess.run(["premake5", target])

if __name__ == "__main__" :
    #ConfigureConan()
    RunConan("Debug")
    RunConan("Release")
    RunPremake("vs2022")
samsinsane commented 3 months ago

What version of Premake are you using? premake5.0.0.-beta2

This would be the issue, beta2 was released before those APIs were added. You'll have to use a master build to use those APIs.

Codinablack commented 3 months ago

There is nothing newer than beta-2, so I will have to compile myself to get those features is what you are saying? @samsinsane?

Codinablack commented 3 months ago

I have tried with the latest from the main branch, compiled it and gotten version 5.0.0-dev version instead. Now when I run it, I get an error, and without the line for unitybuild there is no error.

image

Codinablack commented 3 months ago

I was mistaken above, seems the line for the error was with the vectorextensions wrapping its value in {}.