当前位置: 首页 > 工具软件 > Premake > 使用案例 >

代码构建 premake4 例子

关学
2023-12-01

Building the Source Code
//构建代码
Premake can be built in either "release" (the default) or "debug" modes. If you are using Makefiles (as opposed to an IDE), you can choose which configuration to build with the config argument:
//构建模式 1.release版本 2.debug版本

make               # build in release mode, both versions
make config=debug  # build in debug mode, when generated with Premake 4.x
make CONFIG=Debug  # build in debug mode, when generated with Premake 3.x
//如果make 直接release版本
//make config=**选择要构建的版本 例如:make config=debug

If you do not supply a config argument, release mode will be used
//如果不设置一个配置方式 默认是release版本

Makefile

all: debug

debug:
    premake4 --os=linux --platform=x64 gmake
    @if [ -d allmake ]; then config=debug $(MAKE) -j$(COUNT) -C allmake; fi

premake4.lua

solution "MyApplication1"
location "allmake"   --生成的makefile .make 存储路径 不会覆盖
language "C++"  --语言
objdir "Intermediate" --中间的 各个版本生成中间目录.o .d ...
configurations { "Debug", "Release" } --版本

configuration "Debug"
defines { "DEBUG" }
flags { "Symbols" }

configuration "Release"
defines { "NDEBUG" }
flags { "Optimize" }

--A project defines one build target
project "MyProject1" 
kind "ConsoleApp"
files
{
    "./Project/Project1/**.h", 
    "./Project/Project1/**.cpp"
}
targetdir("./Project/Project1/") --生成的可执行文件目录
includedirs       --包含的目录
{
    "./Project/include/"
}
links { "pthread" }
linkoptions { "-rdynamic" }
buildoptions { "-x c++" }

project "MyProject2"
kind "ConsoleApp"
files
{
    "./Project/Project2/**.h",
    "./Project/Project2/**.cpp"
}
targetdir("./Project/Project2/")

--[[includedirs
{

}
--
libdirs
{

}
--]]

--buildoptions {"-std=c++11 -Wall"}

整个代码地址,直接make即可

https://github.com/jingsia/test_premake4

 类似资料: