Xmake.sh Save

A script-only build utility like autotools

Project README

xmake.sh

A script-only build utility like autotools

Support this project

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. 🙏

Technical Support

You can also consider sponsoring us to get extra technical support services via the Github sponsor program, This gives you access to the xmake-io/technical-support repository, where you can get more information on consulting.

  • Handling Issues with higher priority
  • One-to-one technical consulting service
  • Review your xmake.lua and provide suggestions for improvement

Introduction

Xmake.sh is a script-only build utility like autotools.

Advantages

  • No any dependencies
  • No installation, only one shell script file
  • Easy, similar configuration syntax to xmake
  • Compatible with autotools, same usage

Supported features

  • Generate makefile
  • Custom toolchains
  • Detect options, code snippets, dependencies, compiler features
  • Support builtin variables

In the future it will support

  • Generate build.ninja
  • Support more xmake features

New project

Copy ./configure script file to your project root directory.

Write project configuration

We just write xmake.sh project file, like this:

#!/bin/sh

set_project "hello"
set_version "1.0.1" "%Y%m%d%H%M"

option "debug" "Enable debug compilation mode." false
option "tests" "Enable tests." true

option "pthread"
    add_links "pthread"
    add_cincludes "pthread.h"
    add_cfuncs "pthread_create"
option_end

option "cxx_constexpr"
    set_languages "c++11"
    add_cxxsnippets "constexpr int k = 0;"
option_end

option "lua"
    add_cfuncs "lua_pushstring"
    add_cincludes "lua.h" "lualib.h" "lauxlib.h"
    before_check "option_find_lua"
option_end

option_find_lua() {
    option "lua"
        add_cxflags `pkg-config --cflags lua5.4 2>/dev/null`
        add_ldflags `pkg-config --libs lua5.4 2>/dev/null`
    option_end
}

set_warnings "all" "error"
set_languages "c99" "c++11"
if is_mode "debug"; then
    set_symbols "debug"
    set_optimizes "none"
else
    set_strip "all"
    set_symbols "hidden"
    set_optimizes "smallest"
fi

target "demo"
    set_kind "binary"
    add_deps "foo" "bar"
    add_files "*.cpp"
    add_includedirs "foo" "bar"
    add_configfiles "config.h.in"
    set_configdir "${buildir}/include"
    add_headerfiles "${buildir}/include/config.h" "hello"
    add_headerfiles "(bar/*.h)" "hello"
    add_headerfiles "foo/(*.h)" "hello"
    add_installfiles "res/(png/**.png)" "share"
    add_options "lua"
    if has_config "debug"; then
        add_defines "DEBUG" "TEST"
    fi
    if is_plat "linux" "macosx"; then
        add_defines "POSIX"
    fi
    if has_config "pthread"; then
        set_configvar "HAS_PTHREAD" 1
    fi
    if has_config "cxx_constexpr"; then
        set_configvar "HAS_CONSTEXPR" 1
    fi

includes "foo" "bar"
if has_config "tests"; then
    includes "tests"
fi

Configure and generate makefile

$ ./configure

Build project

$ make

Install artifacts

$ make install

Run program

$ make run

Supported apis

  • set_project
  • set_version
  • includes
  • is_plat
  • is_arch
  • is_host
  • is_mode
  • is_config
  • has_config
  • set_config
  • target
    • set_kind
    • add_deps
    • add_files
    • set_basename
    • set_extension
    • set_filename
    • set_prefixname
    • set_targetdir
    • set_objectdir
    • add_defines
    • add_undefines
    • add_includedirs
    • add_linkdirs
    • add_rpathdirs
    • add_links
    • add_syslinks
    • set_strip
    • set_symbols
    • set_languages
    • set_warnings
    • set_optmizes
    • add_frameworks
    • add_frameworkdirs
    • add_cflags
    • add_cxflags
    • add_cxxflags
    • add_mflags
    • add_mxflags
    • add_mxxflags
    • add_asflags
    • add_ldflags
    • add_shflags
    • add_arflags
    • set_configdir
    • set_configfiles
    • set_configvar
    • set_installdir
    • add_installfiles
    • add_headerfiles
    • add_options
    • before_install
    • after_install
  • target_end
  • option
    • set_default
    • set_description
    • set_showmenu
    • add_defines
    • add_undefines
    • add_includedirs
    • add_linkdirs
    • add_links
    • add_syslinks
    • add_cflags
    • add_cxflags
    • add_cxxflags
    • add_cfuncs
    • add_cxxfuncs
    • add_cincludes
    • add_cxxincludes
    • add_ctypes
    • add_cxxtypes
    • add_csnippets
    • add_cxxsnippets
  • option_end
  • toolchain
    • set_toolset
    • set_sdkdir
    • set_bindir
    • set_cross
  • toolchain_end

Contacts

Open Source Agenda is not affiliated with "Xmake.sh" Project. README Source: xmake-io/xmake.sh
Stars
48
Open Issues
0
Last Commit
4 months ago
Repository
License
Homepage
Tags

Open Source Agenda Badge

Open Source Agenda Rating