Giter Site home page Giter Site logo

luarocks-build-xmake's Introduction

luarocks-build-xmake

A luarocks build module based on xmake

Introduction (中文)

A fork of built-in build system for C++ rocks. Specify "xmake" as build type and "luarocks-build-xmake" as dependency to use it.

About xmake, please see xmake.

Example1 (with xmake.lua)

We can build c/c++ modules if the project contain xmake.lua

├── src
│   ├── test.c
│   └── test.h
└── xmake.lua

xmake.lua

We need to use add_rules("luarocks.module") to add build rules for luarocks modules.

add_rules("mode.debug", "mode.release")

target("example1.hello")
    add_rules("luarocks.module")
    add_files("src/test.c")

rockspec

package = "example1"
version = "1.0-1"
source = {
    url = "git://github.com/xmake-io/luarocks-build-xmake",
    tag = "example1"
}
dependencies = {
    "lua >= 5.1",
    "luarocks-build-xmake"
}
build = {
    type = "xmake",
    copy_directories = {}
}

Example2 (without xmake.lua)

We can use xmake as builtin build type to build c/c++ modules if the project does not contain xmake.lua

├── src
    ├── test.c
    └── test.h

rockspec

package = "example2"
version = "1.0-1"
source = {
    url = "git://github.com/xmake-io/luarocks-build-xmake",
    tag = "example2"
}
dependencies = {
    "lua >= 5.1",
    "luarocks-build-xmake"
}
build = {
    type = "xmake",
    modules = {
        ["example2.hello"] = {
            sources = "src/test.c"
        }
    },
    copy_directories = {}
}

Set special xmake version

dependencies = {
    "lua >= 5.1",
    "luarocks-build-xmake"
}
build = {
    type = "xmake",
    variables = {
        xmake = {
            version = "2.5.1"
        }
    },
    copy_directories = {}
}

Set xmake compilation configuration

dependencies = {
    "lua >= 5.1",
    "luarocks-build-xmake"
}
build = {
    type = "xmake",
    variables = {
        xmake = {
            plat = "mingw",
            arch = "x86_64",
            mode = "debug",
            cflags = "-DTEST1",
            cc = "gcc",
            ld = "gcc",
            ldflags = "...",
            mingw = "mingw sdk path",
            vs = "2019",
            vs_runtime = "MT",
            vs_toolset = "",
            vs_sdkver = "",
        }
    },
    copy_directories = {}
}

luarocks-build-xmake's People

Contributors

waruqi avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

Forkers

russellhaley

luarocks-build-xmake's Issues

luarocks-build-xmake with winlua: "error: invalid argument: (x86)\WinLua\Lua\5.3\include"

Hello Ruki!

I created a little lua module with xmake and tested it. I then created a LuaRocks rockspec and set the build system to xmake. Here is the rockspec:

package = "wltime"
version = "1.0-1"
source = {
    url = "git://github.com/winlua/wltime",
    tag = "time, sleep"
}
dependencies = {
    "lua >= 5.1",
    "luarocks-build-xmake"
}
build = {
    type = "xmake",
    copy_directories = {}
}

I also tried this:

package = "wltime"
version = "1.0-1"
source = {
    url = "git://github.com/winlua/wltime",
    tag = "time, sleep"
}
dependencies = {
    "lua >= 5.1",
    "luarocks-build-xmake"
}
build = {
    type = "xmake",
    copy_directories = {},
    xmake = {
            plat = "mingw",
            arch = "i686",
            mode = "debug",
        }
}

Here is the output when I run luarocks make, which runs a local build (the code is not published to github yet). Note that I was running with 2.3.9 and then run this upgrade, then re-ran my test with the same result

C:\Users\russh\git\xmake [dev ≡ +0 ~1 -0 !]> Invoke-Expression (Invoke-Webrequest 'https://xmake.io/psget.text' -UseBasicParsing).Content
    __  ___ __  __  __ _| | ______                                                                                          \ \/ / |  \/  |/ _  | |/ / __ \                                                                                          >  <  | \__/ | /_| |   <  ___/                                                                                         /_/\_\_|_|  |_|\__ \|_|\_\____| getter


Start downloading https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=master&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+x64 ..
Start installation... Hope your antivirus doesn't trouble
Install to C:\Program Files (x86)\WinLua\XMake\bin
Adding to PATH... almost done
xmake v2.5.1+202102110353, A cross-platform build utility based on Lua
    __  ___ __  __  __ _| | ______
    \ \/ / |  \/  |/ _  | |/ / __ \
     >  <  | \__/ | /_| |   <  ___/
    /_/\_\_|_|  |_|\__ \|_|\_\____|

    👉  Manual: https://xmake.io/#/getting_started
    🙏  Donate: https://xmake.io/#/sponsor


Tab completion service
Would you like to install tab completion service of xmake to your profile?
[A] For all users  [M] Just for me  [H] Just for this host  [N] No  [?] Help (default is "M"): M
Tab completion installed
C:\Users\russh\git\xmake [dev ≡ +0 ~1 -0 !]> xmake --version
xmake v2.5.1+202102110353, A cross-platform build utility based on Lua
Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io
                         _
    __  ___ __  __  __ _| | ______
    \ \/ / |  \/  |/ _  | |/ / __ \
     >  <  | \__/ | /_| |   <  ___/
    /_/\_\_|_|  |_|\__ \|_|\_\____|
                         by ruki, xmake.io

    👉  Manual: https://xmake.io/#/getting_started
    🙏  Donate: https://xmake.io/#/sponsor

C:\Users\russh\git\xmake [dev ≡ +0 ~1 -0 !]> cd C:\temp\timer\
C:\temp\timer> xmake
checking for mingw directory ... C:\Program Files (x86)\WinLua\WLC
[ 25%]: compiling.release src\wltime.c
[ 50%]: linking.release wltime.dll
[100%]: build ok!
C:\temp\timer> luarocks make .\rockspec\wltime-1.0-1.rockspec

wltime 1.0-1 depends on lua >= 5.1 (5.3-1 provided by VM)
wltime 1.0-1 depends on luarocks-build-xmake (1.0-28 installed)
xmake v2.5.1+202102110353, A cross-platform build utility based on Lua
Copyright (C) 2015-present Ruki Wang, tboox.org, xmake.io
                         _
    __  ___ __  __  __ _| | ______
    \ \/ / |  \/  |/ _  | |/ / __ \
     >  <  | \__/ | /_| |   <  ___/
    /_/\_\_|_|  |_|\__ \|_|\_\____|
                         by ruki, xmake.io

    👉  Manual: https://xmake.io/#/getting_started
    🙏  Donate: https://xmake.io/#/sponsor


Usage: $xmake config|f [options] [target]

Configure the project.

Common options:
    -q, --quiet                            Quiet operation.
    -y, --yes                              Input yes by default if need user confirm.
        --confirm=CONFIRM                  Input the given result if need user confirm.
                                               - yes
                                               - no
                                               - def
    -v, --verbose                          Print lots of verbose information for users.
        --root                             Allow to run xmake as root.
    -D, --diagnosis                        Print lots of diagnosis information (backtrace, check info ..) only for
                                           developers.
                                           And we can append -v to get more whole information.
                                               e.g. $ xmake -vD
        --version                          Print the version number and exit.
    -h, --help                             Print this help message and exit.

    -F FILE, --file=FILE                   Read a given xmake.lua file.
    -P PROJECT, --project=PROJECT          Change to the given project directory.
                                           Search priority:
                                               1. The Given Command Argument
                                               2. The Envirnoment Variable: XMAKE_PROJECT_DIR
                                               3. The Current Directory

Command options (config):
    -c, --clean                            Clean the cached configure and configure all again.
        --menu                             Configure project with a menu-driven user interface.

    -p PLAT, --plat=PLAT                   Compile for the given platform. (default: auto)
                                               - android
                                               - bsd
                                               - cross
                                               - cygwin
                                               - iphoneos
                                               - linux
                                               - macosx
                                               - mingw
                                               - msys
                                               - wasm
                                               - watchos
                                               - windows
    -a ARCH, --arch=ARCH                   Compile for the given architecture. (default: auto)
                                               - android: armeabi armeabi-v7a arm64-v8a x86 x86_64 mips mip64
                                               - bsd: i386 x86_64
                                               - cross: i386 x86_64 arm arm64 mips mips64 riscv riscv64 s390x ppc ppc64
                                           sh4
                                               - cygwin: i386 x86_64
                                               - iphoneos: arm64 armv7 armv7s i386 x86_64
                                               - linux: i386 x86_64 armv7 armv7s arm64-v8a mips mips64 mipsel mips64el
                                               - macosx: i386 x86_64 arm64
                                               - mingw: i386 x86_64 arm arm64
                                               - msys: i386 x86_64
                                               - wasm: wasm32
                                               - watchos: armv7k i386
                                               - windows: x86 x64
    -m MODE, --mode=MODE                   Compile for the given mode. (default: release)
    -k KIND, --kind=KIND                   Compile for the given target kind. (default: static)
                                               - static
                                               - shared
                                               - binary
        --host=HOST                        Set the current host environment. (default: windows)

        --require=REQUIRE                  Require all dependent packages?
                                               - y: force to enable
                                               - n: disable
        --pkg_searchdirs=PKG_SEARCHDIRS    The search directories of the remote package.
                                               e.g.
                                               - xmake f --pkg_searchdirs=/dir1;/dir2

        --cross=CROSS                      Set cross toolchains prefix
                                           e.g.
                                               - i386-mingw32-
                                               - arm-linux-androideabi-
        --target_os=TARGET_OS              Set target os only for cross-complation
        --bin=BIN                          Set cross toolchains bin directory
                                           e.g.
                                               - sdk/bin (/arm-linux-gcc ..)
        --sdk=SDK                          Set cross SDK directory
                                           e.g.
                                               - sdk/bin
                                               - sdk/lib
                                               - sdk/include
        --toolchain=TOOLCHAIN              Set toolchain name
                                           e.g.
                                               - xmake f --toolchain=clang
                                               - xmake f --toolchain=[cross|llvm|sdcc ..] --sdk=/xxx
                                               - run `xmake show -l toolchains` to get all toolchains

        --cu=CU                            The Cuda Compiler
        --cu-ccbin=CU-CCBIN                The Cuda Host C++ Compiler
        --culd=CULD                        The Cuda Linker

        --cuflags=CUFLAGS                  The Cuda Compiler Flags
        --culdflags=CULDFLAGS              The Cuda Linker Flags

        --links=LINKS                      The Link Libraries
        --syslinks=SYSLINKS                The System Link Libraries
        --linkdirs=LINKDIRS                The Link Search Directories
        --includedirs=INCLUDEDIRS          The Include Search Directories

        --sc=SC                            The Swift Compiler

        --scld=SCLD                        The Swift Linker
        --scsh=SCSH                        The Swift Shared Library Linker

        --frameworks=FRAMEWORKS            The Frameworks
        --frameworkdirs=FRAMEWORKDIRS      The Frameworks Search Directories

        --fc=FC                            The Fortran Compiler

        --fcld=FCLD                        The Fortran Linker
        --fcsh=FCSH                        The Fortran Shared Library Linker

        --cc=CC                            The C Compiler
        --cxx=CXX                          The C++ Compiler
        --cpp=CPP                          The C Preprocessor

        --ld=LD                            The Linker
        --ar=AR                            The Static Library Linker
        --sh=SH                            The Shared Library Linker
        --ranlib=RANLIB                    The Static Library Index Generator

        --cflags=CFLAGS                    The C Compiler Flags
        --cxflags=CXFLAGS                  The C/C++ compiler Flags
        --cxxflags=CXXFLAGS                The C++ Compiler Flags

        --ldflags=LDFLAGS                  The Binary Linker Flags
        --arflags=ARFLAGS                  The Static Library Linker Flags
        --shflags=SHFLAGS                  The Shared Library Linker Flags

        --go=GO                            The Golang Compiler

        --gcld=GCLD                        The Golang Linker
        --go-ar=GO-AR                      The Golang Static Library Linker

        --mm=MM                            The Objc Compiler
        --mxx=MXX                          The Objc++ Compiler

        --mflags=MFLAGS                    The Objc Compiler Flags
        --mxflags=MXFLAGS                  The Objc/c++ Compiler Flags
        --mxxflags=MXXFLAGS                The Objc++ Compiler Flags

        --as=AS                            The Assembler

        --asflags=ASFLAGS                  The Assembler Flags

        --rc=RC                            The Rust Compiler

        --rcld=RCLD                        The Rust Linker
        --rcar=RCAR                        The Rust Static Library Archiver
        --rcsh=RCSH                        The Rust Shared Library Linker

        --zc=ZC                            The Zig Compiler

        --zcld=ZCLD                        The Zig Linker
        --zcar=ZCAR                        The Zig Static Library Archiver
        --zcsh=ZCSH                        The Zig Shared Library Linker

        --mrc=MRC                          The Microsoft Resource Compiler

        --mrcflags=MRCFLAGS                The Microsoft Resource Flags

        --dc=DC                            The Dlang Compiler

        --dcld=DCLD                        The Dlang Linker
        --dcar=DCAR                        The Dlang Static Library Archiver
        --dcsh=DCSH                        The Dlang Shared Library Linker

        --ndk=NDK                          The NDK Directory
        --ndk_sdkver=NDK_SDKVER            The SDK Version for NDK (default: auto)
        --android_sdk=ANDROID_SDK          The Android SDK Directory
        --build_toolver=BUILD_TOOLVER      The Build Tool Version of Android SDK
        --ndk_stdcxx=[y|n]                 Use stdc++ library for NDK (default: y)
        --ndk_cxxstl=NDK_CXXSTL            The stdc++ stl library for NDK
                                               - c++_static
                                               - c++_shared
                                               - gnustl_static
                                               - gnustl_shared
                                               - stlport_shared
                                               - stlport_static

        --cuda=CUDA                        The Cuda SDK Directory (default: auto)

        --qt=QT                            The Qt SDK Directory (default: auto)
        --qt_sdkver=QT_SDKVER              The Qt SDK Version (default: auto)

        --vcpkg=VCPKG                      The Vcpkg Directory (default: auto)

        --mingw=MINGW                      The MingW SDK Directory

        --vs=VS                            The Microsoft Visual Studio (default: auto)
                                             e.g. --vs=2017
        --vs_toolset=VS_TOOLSET            The Microsoft Visual Studio Toolset Version
                                             e.g. --vs_toolset=14.0
        --vs_sdkver=VS_SDKVER              The Windows SDK Version of Visual Studio
                                             e.g. --vs_sdkver=10.0.15063.0
        --vs_runtime=VS_RUNTIME            The Runtime library of Visual Studio
                                               - MT
                                               - MTd
                                               - MD
                                               - MDd

        --wdk=WDK                          The WDK Directory (default: auto)
        --wdk_sdkver=WDK_SDKVER            The WDK Version (default: auto)
        --wdk_winver=WDK_WINVER            The WDK Windows Version (default: auto)
                                               - win10[|_rs3]
                                               - win81
                                               - win8
                                               - win7[|_sp1|_sp2|_sp3]

        --debugger=DEBUGGER                Set debugger (default: auto)
                                           e.g.
                                               - xmake f --trybuild=auto; xmake
                                               - xmake f --trybuild=autotools -p android --ndk=xxx; xmake

                                           the third-party buildsystems:
                                               - auto
                                               - make
                                               - autotools
                                               - cmake
                                               - scons
                                               - meson
                                               - bazel
                                               - ninja
                                               - msbuild
                                               - xcodebuild
                                               - ndkbuild
        --tryconfigs=TRYCONFIGS            Set the extra configurations of the third-party buildsystem for the try-
                                           build mode.
                                           e.g.
                                               - xmake f --trybuild=autotools --tryconfigs='--enable-shared=no'
    -o BUILDIR, --buildir=BUILDIR          Set build directory. (default: build)

          target                           Configure for the given target.
                                               - wltime
error: invalid argument: (x86)\WinLua\Lua\5.3\include

Error: Build error: Failed configuring.
C:\temp\timer> xmake clean
C:\temp\timer> xmake
[ 25%]: compiling.release src\wltime.c
[ 50%]: linking.release wltime.dll
[100%]: build ok!
C:\temp\timer>

I'm not sure how to run xmake -v -D when the system is invoked using luarocks? Here is my luarocks config:

C:\temp\timer> luarocks config
accept_unknown_fields = false
arch = "win32-x86"
cache = {
   luajit_version_checked = true
}
cache_fail_timeout = 86400
cache_timeout = 60
check_certificates = false
cmake_generator = "MinGW Makefiles"
config_files = {
   nearest = "C:/Program Files (x86)/WinLua/LuaRocks//config-5.3.lua",
   system = {
      file = "C:/Program Files (x86)/WinLua/LuaRocks//config-5.3.lua",
      found = true
   },
   user = {
      file = "C:/Users/russh/AppData/Roaming/luarocks/config-5.3.lua",
      found = false
   }
}
connection_timeout = 30
deploy_bin_dir = "C:/Users/russh/AppData/Roaming/luarocks/bin"
deploy_lib_dir = "C:/Users/russh/AppData/Roaming/luarocks/lib/lua/5.3"
deploy_lua_dir = "C:/Users/russh/AppData/Roaming/luarocks/share/lua/5.3"
deps_mode = "one"
disabled_servers = {}
export_path_separator = ";"
external_deps_dirs = {
   "C:\\Program Files (x86)\\WinLua\\WLC\\i686-w64-mingw32/",
   "c:/mingw",
   "c:/windows/system32"
}
external_deps_patterns = {
   bin = {
      "?.exe",
      "?.bat"
   },
   include = {
      "?.h"
   },
   lib = {
      "?.lib",
      "lib?.lib",
      "lib?.a",
      "lib?.dll.a",
      "?.dll.a",
      "?.dll",
      "?.lib"
   }
}
external_deps_subdirs = {
   bin = "bin",
   include = "include",
   lib = {
      "",
      "lib",
      "bin"
   }
}
external_lib_extension = "lib"
fs_use_modules = true
home = "C:\\Users\\russh\\AppData\\Roaming"
home_tree = "C:\\Users\\russh\\AppData\\Roaming/luarocks"
homeconfdir = "C:\\Users\\russh\\AppData\\Roaming/luarocks"
hooks_enabled = true
is_binary = true
lib_extension = "dll"
lib_modules_path = "/lib/lua/5.3"
link_lua_explicitly = true
local_by_default = true
local_cache = "C:\\Users\\russh\\AppData\\Local/LuaRocks/Cache"
lua_extension = "lua"
lua_found = {
   lua_bindir = "C:\\Program Files (x86)\\WinLua\\Lua\\5.3\\bin",
   lua_dir = "C:\\Program Files (x86)\\WinLua\\Lua\\5.3\\bin",
   lua_interpreter = "lua.exe",
   lua_version = "5.3"
}
lua_interpreter = "luarocks.exe"
lua_modules_path = "/share/lua/5.3"
lua_version = "5.3"
major_version = "3.4"
makefile = "Makefile"
no_manifest = false
obj_extension = "o"
processor = "x86"
program_series = "3.4"
program_version = "3.4.0"
rocks_dir = "C:/Users/russh/AppData/Roaming/luarocks/lib/luarocks/rocks-5.3"
rocks_servers = {
   {
      "https://luarocks.org",
      "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/",
      "https://luafr.org/luarocks/",
      "http://luarocks.logiceditor.com/rocks"
   }
}
rocks_subdir = "/lib/luarocks/rocks-5.3"
rocks_trees = {
   {
      name = "user",
      root = "C:\\Users\\russh\\AppData\\Roaming\\\\luarocks"
   },
   {
      name = "system",
      root = "C:\\Program Files (x86)\\WinLua\\Lua\\5.3"
   }
}
runtime_external_deps_patterns = {
   bin = {
      "?.exe",
      "?.bat"
   },
   include = {
      "?.h"
   },
   lib = {
      "cyg?.dll",
      "?.dll",
      "lib?.dll"
   }
}
runtime_external_deps_subdirs = {
   bin = "bin",
   include = "include",
   lib = {
      "",
      "lib",
      "bin"
   }
}
static_lib_extension = "a"
sysconfdir = "C:\\Program Files (x86)\\WinLua\\LuaRocks\\"
target_cpu = "x86"
upload = {
   api_version = "1",
   server = "https://luarocks.org",
   tool_version = "1.0.0"
}
user_agent = "LuaRocks/3.4.0 win32-x86"
variables = {
   AR = "ar",
   BUNZIP2 = "bunzip2",
   CC = "wlc32.exe",
   CFLAGS = "-O2",
   CHMOD = "chmod",
   CMAKE = "cmake",
   CP = "cp",
   CURL = "curl",
   CURLNOCERTFLAG = "-k",
   CVS = "cvs",
   FIND = "find",
   GIT = "git",
   GPG = "gpg",
   GUNZIP = "gunzip",
   HG = "hg",
   ICACLS = "icacls",
   LD = "wlc32.exe",
   LIBFLAG = "-shared",
   LIB_EXTENSION = "dll",
   LS = "ls",
   LUA = "C:\\Program Files (x86)\\WinLua\\LuaRocks\\bin/luarocks.exe",
   LUALIB = "lua53.lib",
   LUA_BINDIR = "C:\\Program Files (x86)\\WinLua\\LuaRocks\\bin",
   LUA_DIR = "C:\\Program Files (x86)\\WinLua\\Lua\\5.3\\bin",
   LUA_INCDIR = "C:\\Program Files (x86)\\WinLua\\Lua\\5.3\\include",
   LUA_LIBDIR = "C:\\Program Files (x86)\\WinLua\\Lua\\5.3\\bin",
   LUA_LIBDIR_FILE = "lua53.lib",
   MAKE = "mingw32-make",
   MD5 = "md5",
   MD5SUM = "md5sum",
   MKDIR = "mkdir",
   MKTEMP = "mktemp",
   MT = "mt",
   OBJ_EXTENSION = "o",
   OPENSSL = "openssl",
   PWD = "pwd",
   RANLIB = "ranlib",
   RC = "windres",
   RM = "rm",
   RMDIR = "rmdir",
   ROCKS_TREE = "C:/Users/russh/AppData/Roaming/luarocks/lib/luarocks/rocks-5.3",
   RSYNC = "rsync",
   RSYNCFLAGS = "--exclude=.git -Oavz",
   SCP = "scp",
   SCRIPTS_DIR = "C:/Users/russh/AppData/Roaming/luarocks/bin",
   SEVENZ = "7z",
   SSCM = "sscm",
   SVN = "svn",
   TAR = "tar",
   TOUCH = "touch",
   UNZIP = "unzip -n",
   WGET = "wget",
   WGETNOCERTFLAG = "--no-check-certificate",
   ZIP = "zip"
}
verbose = false
web_browser = "start"
wrapper_suffix = ".bat"

Thanks!
Russ

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.