-
-
Notifications
You must be signed in to change notification settings - Fork 817
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3318 from xmake-io/dlang
Improve dlang toolchains
- Loading branch information
Showing
14 changed files
with
267 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--!A cross-platform build utility based on Lua | ||
-- | ||
-- Licensed 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-present, TBOOX Open Source Group. | ||
-- | ||
-- @author ruki | ||
-- @file xmake.lua | ||
-- | ||
|
||
toolchain("dmd") | ||
set_homepage("https://dlang.org/") | ||
set_description("D Programming Language Compiler") | ||
|
||
on_check(function (toolchain) | ||
import("lib.detect.find_tool") | ||
if find_tool("dmd") then | ||
return true | ||
end | ||
end) | ||
|
||
on_load(function (toolchain) | ||
local cross = toolchain:cross() or "" | ||
toolchain:add("toolset", "dc", "dmd") | ||
toolchain:add("toolset", "dcld", "dmd") | ||
toolchain:add("toolset", "dcsh", "dmd") | ||
toolchain:add("toolset", "dcar", "dmd") | ||
|
||
local march | ||
if toolchain:is_arch("x86_64", "x64") then | ||
march = "-m64" | ||
elseif toolchain:is_arch("i386", "x86") then | ||
march = "-m32" | ||
end | ||
toolchain:add("dcflags", march or "") | ||
toolchain:add("dcshflags", march or "") | ||
toolchain:add("dcldflags", march or "") | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--!A cross-toolchain build utility based on Lua | ||
-- | ||
-- Licensed 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-present, TBOOX Open Source Group. | ||
-- | ||
-- @author ruki | ||
-- @file check.lua | ||
-- | ||
|
||
-- imports | ||
import("core.project.config") | ||
import("lib.detect.find_tool") | ||
import("detect.sdks.find_cross_toolchain") | ||
|
||
function main(toolchain) | ||
|
||
-- we attempt to find gdc in $PATH | ||
if find_tool("gdc") then | ||
return true | ||
end | ||
|
||
-- we need find gdc2 in the given toolchain sdk directory | ||
local sdkdir = toolchain:sdkdir() | ||
local bindir = toolchain:bindir() | ||
local cross = toolchain:cross() | ||
if not sdkdir and not bindir and not cross then | ||
return | ||
end | ||
|
||
-- find cross toolchain | ||
local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir, cross = cross}) | ||
if cross_toolchain then | ||
toolchain:config_set("cross", cross_toolchain.cross) | ||
toolchain:config_set("bindir", cross_toolchain.bindir) | ||
toolchain:config_set("sdkdir", cross_toolchain.sdkdir) | ||
toolchain:configs_save() | ||
else | ||
raise("cross toolchain not found!") | ||
end | ||
return cross_toolchain | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--!A cross-platform build utility based on Lua | ||
-- | ||
-- Licensed 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-present, TBOOX Open Source Group. | ||
-- | ||
-- @author ruki | ||
-- @file xmake.lua | ||
-- | ||
|
||
-- define toolchain | ||
toolchain("gdc") | ||
set_homepage("https://gdcproject.org/") | ||
set_description("The GNU D Compiler (GDC).") | ||
|
||
on_check("check") | ||
|
||
on_load(function (toolchain) | ||
local cross = toolchain:cross() or "" | ||
toolchain:add("toolset", "dc", cross .. "gdc") | ||
toolchain:add("toolset", "dcld", cross .. "gdc") | ||
toolchain:add("toolset", "dcsh", cross .. "gdc") | ||
toolchain:add("toolset", "dcar", cross .. "gcc-ar") | ||
|
||
local march | ||
if toolchain:is_arch("x86_64", "x64") then | ||
march = "-m64" | ||
elseif toolchain:is_arch("i386", "x86") then | ||
march = "-m32" | ||
end | ||
toolchain:add("dcflags", march or "") | ||
toolchain:add("dcshflags", march or "") | ||
toolchain:add("dcldflags", march or "") | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--!A cross-toolchain build utility based on Lua | ||
-- | ||
-- Licensed 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-present, TBOOX Open Source Group. | ||
-- | ||
-- @author ruki | ||
-- @file check.lua | ||
-- | ||
|
||
-- imports | ||
import("core.project.config") | ||
import("lib.detect.find_tool") | ||
import("detect.sdks.find_cross_toolchain") | ||
|
||
function main(toolchain) | ||
|
||
-- we attempt to find ldc2 in $PATH | ||
if find_tool("ldc2") then | ||
return true | ||
end | ||
|
||
-- we need find ldc2 in the given toolchain sdk directory | ||
local sdkdir = toolchain:sdkdir() | ||
local bindir = toolchain:bindir() | ||
local cross = toolchain:cross() | ||
if not sdkdir and not bindir and not cross then | ||
return | ||
end | ||
|
||
-- find cross toolchain | ||
local cross_toolchain = find_cross_toolchain(sdkdir, {bindir = bindir, cross = cross}) | ||
if cross_toolchain then | ||
toolchain:config_set("cross", cross_toolchain.cross) | ||
toolchain:config_set("bindir", cross_toolchain.bindir) | ||
toolchain:config_set("sdkdir", cross_toolchain.sdkdir) | ||
toolchain:configs_save() | ||
else | ||
raise("cross toolchain not found!") | ||
end | ||
return cross_toolchain | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--!A cross-platform build utility based on Lua | ||
-- | ||
-- Licensed 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-present, TBOOX Open Source Group. | ||
-- | ||
-- @author ruki | ||
-- @file xmake.lua | ||
-- | ||
|
||
-- define toolchain | ||
toolchain("ldc") | ||
set_homepage("https://github.com/ldc-developers/ldc") | ||
set_description("The LLVM-based D Compiler.") | ||
|
||
on_check("check") | ||
|
||
on_load(function (toolchain) | ||
toolchain:add("toolset", "dc", "ldc2") | ||
toolchain:add("toolset", "dcld", "ldc2") | ||
toolchain:add("toolset", "dcsh", "ldc2") | ||
toolchain:add("toolset", "dcar", "ldc2") | ||
|
||
local march | ||
if toolchain:is_arch("x86_64", "x64") then | ||
march = "-m64" | ||
elseif toolchain:is_arch("i386", "x86") then | ||
march = "-m32" | ||
end | ||
toolchain:add("dcflags", march or "") | ||
toolchain:add("dcshflags", march or "") | ||
toolchain:add("dcldflags", march or "") | ||
end) |