diff options
| author | ruki <[email protected]> | 2018-09-26 00:37:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-09-25 21:47:41 +0800 |
| commit | c3aa3d41297c1fda1cf88a10e6e5413fb444949a (patch) | |
| tree | c4dd81de66f19010bea059f7f24af48be3a2323f | |
| parent | ef796135d8e1a46cf7fe0f663315f37147fc2855 (diff) | |
add autoconf package builder
| -rw-r--r-- | xmake/actions/build/trybuild.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/package/builder/autoconf.lua | 59 | ||||
| -rw-r--r-- | xmake/modules/package/builder/cmake.lua | 2 |
3 files changed, 64 insertions, 1 deletions
diff --git a/xmake/actions/build/trybuild.lua b/xmake/actions/build/trybuild.lua index 847aa955d..1776910e8 100644 --- a/xmake/actions/build/trybuild.lua +++ b/xmake/actions/build/trybuild.lua @@ -34,6 +34,9 @@ end -- try building for configure function _build_for_configure(buildfile) + if not os.isfile("configure") and os.isfile("configure.ac") then + os.vrun("autoreconf --install --symlink") + end os.vrun("./configure --prefix=%s", path.absolute("install")) os.vrun("make -j4") os.vrun("make install") @@ -87,6 +90,7 @@ function main(targetname) end table.insert(buildscripts, {"CMakeLists.txt", _build_for_cmakelists}) table.insert(buildscripts, {"configure", _build_for_configure}) + table.insert(buildscripts, {"configure.ac", _build_for_configure}) table.insert(buildscripts, {"[mM]akefile", _build_for_makefile}) -- attempt to build it diff --git a/xmake/modules/package/builder/autoconf.lua b/xmake/modules/package/builder/autoconf.lua new file mode 100644 index 000000000..28b9c2187 --- /dev/null +++ b/xmake/modules/package/builder/autoconf.lua @@ -0,0 +1,59 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015 - 2018, TBOOX Open Source Group. +-- +-- @author ruki +-- @file autoconf.lua +-- + +-- build package +function build(package, configs) + + -- generate configure file + if not os.isfile("configure") and os.isfile("configure.ac") then + os.vrun("autoreconf --install --symlink") + end + + -- inherit require and option configs + local argv = {} + if not configs or not configs.prefix then + table.insert(argv, "--prefix=" .. package:installdir()) + end + for name, value in pairs(configs) do + value = tostring(value):trim() + if type(name) == "number" then + if value ~= "" then + table.insert(argv, value) + end + else + if value:find(" ", 1, true) then + value = '"' .. value .. '"' + end + table.insert(argv, "--" .. name .. "=" .. value) + end + end + os.vrunv("./configure", argv) + os.vrun("make -j4") +end + +-- install package +function install(package) + os.vrun("make install") +end + diff --git a/xmake/modules/package/builder/cmake.lua b/xmake/modules/package/builder/cmake.lua index 42c785fcf..3897e72e2 100644 --- a/xmake/modules/package/builder/cmake.lua +++ b/xmake/modules/package/builder/cmake.lua @@ -27,7 +27,7 @@ import("core.base.option") import("lib.detect.find_file") -- build package -function build(package) +function build(package, configs) os.mkdir("build/install") os.cd("build") os.vrun("cmake -a $(arch) -DCMAKE_INSTALL_PREFIX=\"%s\" ..", path.absolute("install")) |
