-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a basic implementation for the Zig port with proper testings (#478)
* Add a basic implementation for the Zig port with proper testings * Fix an accidental change in Rust tests * Update FindZig.cmake * Update CMakeLists.txt * Update metacall-configure.ps1 * Update metacall-configure.sh * Update CMakeLists.txt --------- Co-authored-by: Vicente Eduardo Ferrer Garcia <[email protected]>
- Loading branch information
1 parent
1570031
commit d70f10a
Showing
12 changed files
with
3,005 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# | ||
# CMake Find Zig by Parra Studios | ||
# CMake script to find Zig compiler and tools. | ||
# | ||
# Copyright (C) 2016 - 2024 Vicente Eduardo Ferrer Garcia <[email protected]> | ||
# | ||
# 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. | ||
# | ||
|
||
# Find Zig executables and paths | ||
# | ||
# Zig_FOUND - True if Zig was found | ||
# Zig_COMPILER_EXECUTABLE - Zig compiler executable path | ||
|
||
# Options | ||
# | ||
# Zig_CMAKE_DEBUG - Print the debug information and all constants values | ||
|
||
option(Zig_CMAKE_DEBUG "Show full output of the Zig related commands for debugging." OFF) | ||
|
||
find_program(Zig_COMPILER_EXECUTABLE zig | ||
) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args(Zig | ||
FOUND_VAR Zig_FOUND | ||
) | ||
|
||
mark_as_advanced( | ||
Zig_FOUND | ||
Zig_COMPILER_EXECUTABLE | ||
) | ||
|
||
if(Zig_CMAKE_DEBUG) | ||
message(STATUS "Zig_COMPILER_EXECUTABLE: ${Zig_COMPILER_EXECUTABLE}") | ||
endif() |
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,6 @@ | ||
# Zig cache and binary directories | ||
zig-cache | ||
zig-out | ||
|
||
# Python loader cache in testings | ||
src/tests/__pycache__ |
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,47 @@ | ||
# Check if this port is enabled | ||
if(NOT OPTION_BUILD_PORTS OR NOT OPTION_BUILD_PORTS_ZIG) | ||
return() | ||
endif() | ||
|
||
# | ||
# Port name and options | ||
# | ||
|
||
find_package(Zig) | ||
|
||
if(NOT Zig_FOUND) | ||
message(SEND_ERROR "Zig not found") | ||
return() | ||
endif() | ||
|
||
# Target name | ||
set(target zig_port) | ||
|
||
# Exit here if required dependencies are not met | ||
message(STATUS "Port ${target}") | ||
|
||
# Generate bindings | ||
add_custom_target(TARGET ${target} | ||
COMMAND ${Zig_COMPILER_EXECUTABLE} translate-c metacall.h > metacall-bindings.zig -lc -I ${CMAKE_SOURCE_DIR}/source/metacall/include -I ${CMAKE_BINARY_DIR}/source/metacall/include -I ${CMAKE_BINARY_DIR}/source/include | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
# | ||
# Define test | ||
# | ||
|
||
add_test(NAME ${target} | ||
COMMAND ${Zig_COMPILER_EXECUTABLE} build test | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
set_property(TEST ${target} | ||
PROPERTY LABELS ${target} | ||
) | ||
|
||
include(TestEnvironmentVariables) | ||
|
||
test_environment_variables(${target} | ||
"" | ||
${TESTS_ENVIRONMENT_VARIABLES} | ||
) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.