-
-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
109 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# Origignal script from https://github.com/ziglang/zig/issues/4911 | ||
# Modified to add SILKDOTNET_ paths in response to some issues with SwiftShader | ||
|
||
args="" | ||
for arg in "$@" | ||
do | ||
parg="$arg" | ||
|
||
option=${arg%=*} | ||
target=${arg#*=} | ||
if [[ $option == "-march" || $option == "-mcpu" || $option == "-mtune" ]]; then | ||
moveon=0 | ||
for replace in $SILKDOTNET_ReplaceArchitectureZigCcFlags | ||
do | ||
replacetarget=${replace%=*} | ||
replacement=${replace#*=} | ||
# echo $replacetarget A $replacement B $target END | ||
if [[ $replacetarget == $target ]]; then | ||
if [[ "$replacement" == "" ]]; then | ||
moveon=1 | ||
else | ||
target="$replacement" | ||
fi | ||
fi | ||
done | ||
if [[ $moveon == 1 || "$SILKDOTNET_RemoveAllPotentiallyProblematicZigCcFlags" == "1" ]]; then | ||
continue | ||
else | ||
fixedTarget=${target//-/_} | ||
parg="$option=$fixedTarget" | ||
fi | ||
fi | ||
args="$args $parg" | ||
done |
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,2 @@ | ||
@echo off | ||
zig ar %* |
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,2 @@ | ||
#!/bin/sh | ||
zig ar "$@" |
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,3 @@ | ||
@echo off | ||
: TODO add -march/-mtune handling if necessary | ||
zig c++ %* |
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,3 @@ | ||
#!/bin/bash | ||
. "$(dirname ${BASH_SOURCE[0]})/fudge.sh" $args | ||
zig c++ $args |
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,3 @@ | ||
@echo off | ||
: TODO add -march/-mtune handling if necessary | ||
zig cc %* |
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,3 @@ | ||
#!/bin/bash | ||
. "$(dirname ${BASH_SOURCE[0]})/fudge.sh" $args | ||
zig cc $args |
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,2 @@ | ||
@echo off | ||
zig ranlib %* |
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,2 @@ | ||
#!/bin/sh | ||
zig ranlib "$@" |
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,2 @@ | ||
@echo off | ||
zig rc %* |
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,2 @@ | ||
#!/bin/sh | ||
zig rc "$@" |
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,2 @@ | ||
set(ZIG_TARGET "aarch64-linux-gnu.2.17") | ||
include(${CMAKE_CURRENT_LIST_DIR}/zig-toolchain.cmake) |
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,2 @@ | ||
set(ZIG_TARGET "arm-linux-gnueabihf.2.17") | ||
include(${CMAKE_CURRENT_LIST_DIR}/zig-toolchain.cmake) |
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,2 @@ | ||
set(ZIG_TARGET "x86_64-linux-gnu.2.17") | ||
include(${CMAKE_CURRENT_LIST_DIR}/zig-toolchain.cmake) |
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,40 @@ | ||
include_guard() | ||
|
||
if(CMAKE_GENERATOR MATCHES "Visual Studio") | ||
message(FATAL_ERROR "Visual Studio generator not supported, use: cmake -G Ninja") | ||
endif() | ||
|
||
if(NOT ZIG_TARGET MATCHES "^([a-zZ-Z0-9_]+)-([a-zZ-Z0-9_]+)-([a-zZ-Z0-9_.]+)$") | ||
message(FATAL_ERROR "Expected -DZIG_TARGET=<arch>-<os>-<abi>") | ||
endif() | ||
|
||
set(ZIG_ARCH ${CMAKE_MATCH_1}) | ||
set(ZIG_OS ${CMAKE_MATCH_2}) | ||
set(ZIG_ABI ${CMAKE_MATCH_3}) | ||
|
||
if(ZIG_OS STREQUAL "linux") | ||
set(CMAKE_SYSTEM_NAME "Linux") | ||
elseif(ZIG_OS STREQUAL "windows") | ||
set(CMAKE_SYSTEM_NAME "Windows") | ||
elseif(ZIG_OS STREQUAL "macos") | ||
set(CMAKE_SYSTEM_NAME "Darwin") | ||
else() | ||
message(WARNING "Unknown OS: ${ZIG_OS}") | ||
endif() | ||
|
||
set(CMAKE_SYSTEM_VERSION 1) | ||
set(CMAKE_SYSTEM_PROCESSOR ${ZIG_ARCH}) | ||
|
||
if(WIN32) | ||
set(SCRIPT_SUFFIX ".cmd") | ||
else() | ||
set(SCRIPT_SUFFIX ".sh") | ||
endif() | ||
|
||
# This is working (thanks to Simon for finding this trick) | ||
set(CMAKE_AR "${CMAKE_CURRENT_LIST_DIR}/zig-ar${SCRIPT_SUFFIX}") | ||
set(CMAKE_RANLIB "${CMAKE_CURRENT_LIST_DIR}/zig-ranlib${SCRIPT_SUFFIX}") | ||
set(CMAKE_RC_COMPILER "${CMAKE_CURRENT_LIST_DIR}/zig-rc${SCRIPT_SUFFIX}") | ||
set(CMAKE_ASM_COMPILER "${CMAKE_CURRENT_LIST_DIR}/zig-cc${SCRIPT_SUFFIX}" -target ${ZIG_TARGET}) | ||
set(CMAKE_C_COMPILER "${CMAKE_CURRENT_LIST_DIR}/zig-cc${SCRIPT_SUFFIX}" -target ${ZIG_TARGET}) | ||
set(CMAKE_CXX_COMPILER "${CMAKE_CURRENT_LIST_DIR}/zig-c++${SCRIPT_SUFFIX}" -target ${ZIG_TARGET}) |