Giter VIP home page Giter VIP logo

xmake.sh's Introduction

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
  • 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

xmake.sh's People

Contributors

daviwil avatar waruqi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xmake.sh's Issues

如果xmake.sh和configure在同一级目录,脚本卡死

Xmake 版本

xmake.sh v1.0.1

操作系统版本和架构

Ubuntu 18.04.6 LTS

描述问题

项目结构

.
├── configure
├── test1.cpp
└── xmake.sh

test1.cpp

#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    cout << "test1" << endl;
    return 0;
}

xmake.sh

#!/bin/sh

target "test1"
    set_kind "binary"
    add_files "test1.cpp"

执行./configure, 程序卡死

期待的结果

脚本自动退出并生成Makefile

工程配置

No response

附加信息和错误日志

bash --version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

尝试添加了一些log,发现卡在_path_relative

# get relative path, e.g `_path_relative ${rootdir} ${absolute_path}`
_path_relative() {
    local source=$1
    local target=$2

    local common_part=$source
    local result=""
    echo target=${target} >> output.txt
    echo common_part=${common_part} >> output.txt
    while _test_eq "${target#$common_part}" "${target}"; do
        # no match, means that candidate common part is not correct
        # go up one level (reduce common part)
        common_part="$(dirname -- $common_part)"
        # and record that we went back, with correct / handling
        if _test_z $result; then
            result=".."
        else
            result="../$result"
        fi
        echo common_part=${common_part} >> output.txt
    done

output.txt

target=test1.cpp
common_part=/home/sdb/zhuyu/xmake.sh/tests
common_part=/home/sdb/zhuyu/xmake.sh
common_part=/home/sdb/zhuyu
common_part=/home/sdb
common_part=/home
common_part=/
common_part=/
common_part=/
common_part=/
common_part=/
common_part=/
common_part=/
common_part=/
common_part=/
common_part=/
common_part=/
common_part=/
common_part=/
common_part=/
common_part=/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.