mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
Merge branch 'master' of https://github.com/odin-lang/Odin
This commit is contained in:
@@ -6,8 +6,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Download LLVM
|
- name: Download LLVM, botan
|
||||||
run: sudo apt-get install llvm-11 clang-11 llvm
|
run: sudo apt-get install llvm-11 clang-11 llvm libbotan-2-dev botan
|
||||||
- name: build odin
|
- name: build odin
|
||||||
run: make release
|
run: make release
|
||||||
- name: Odin version
|
- name: Odin version
|
||||||
@@ -30,13 +30,18 @@ jobs:
|
|||||||
cd tests/core
|
cd tests/core
|
||||||
make
|
make
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
- name: Vendor library tests
|
||||||
|
run: |
|
||||||
|
cd tests/vendor
|
||||||
|
make
|
||||||
|
timeout-minutes: 10
|
||||||
build_macOS:
|
build_macOS:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Download LLVM and setup PATH
|
- name: Download LLVM, botan and setup PATH
|
||||||
run: |
|
run: |
|
||||||
brew install llvm@11
|
brew install llvm@11 botan
|
||||||
echo "/usr/local/opt/llvm@11/bin" >> $GITHUB_PATH
|
echo "/usr/local/opt/llvm@11/bin" >> $GITHUB_PATH
|
||||||
TMP_PATH=$(xcrun --show-sdk-path)/user/include
|
TMP_PATH=$(xcrun --show-sdk-path)/user/include
|
||||||
echo "CPATH=$TMP_PATH" >> $GITHUB_ENV
|
echo "CPATH=$TMP_PATH" >> $GITHUB_ENV
|
||||||
@@ -57,6 +62,16 @@ jobs:
|
|||||||
- name: Odin run -debug
|
- name: Odin run -debug
|
||||||
run: ./odin run examples/demo/demo.odin -debug
|
run: ./odin run examples/demo/demo.odin -debug
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
- name: Core library tests
|
||||||
|
run: |
|
||||||
|
cd tests/core
|
||||||
|
make
|
||||||
|
timeout-minutes: 10
|
||||||
|
- name: Vendor library tests
|
||||||
|
run: |
|
||||||
|
cd tests/vendor
|
||||||
|
make
|
||||||
|
timeout-minutes: 10
|
||||||
build_windows:
|
build_windows:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -97,6 +112,13 @@ jobs:
|
|||||||
cd tests\core
|
cd tests\core
|
||||||
call build.bat
|
call build.bat
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
- name: Vendor library tests
|
||||||
|
shell: cmd
|
||||||
|
run: |
|
||||||
|
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat
|
||||||
|
cd tests\vendor
|
||||||
|
call build.bat
|
||||||
|
timeout-minutes: 10
|
||||||
- name: core:math/big tests
|
- name: core:math/big tests
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -115,12 +115,16 @@ cleanpath_strip_prefix :: proc(buf: []u16) -> []u16 {
|
|||||||
}
|
}
|
||||||
buf = buf[:N]
|
buf = buf[:N]
|
||||||
|
|
||||||
if len(buf) >= 4 {
|
if len(buf) >= 4 && buf[0] == '\\' && buf[1] == '\\' && buf[2] == '?' && buf[3] == '\\' {
|
||||||
if buf[0] == '\\' &&
|
buf = buf[4:]
|
||||||
buf[1] == '\\' &&
|
|
||||||
buf[2] == '?' &&
|
/*
|
||||||
buf[3] == '\\' {
|
NOTE(Jeroen): Properly handle UNC paths.
|
||||||
buf = buf[4:]
|
We need to turn `\\?\UNC\synology.local` into `\\synology.local`.
|
||||||
|
*/
|
||||||
|
if len(buf) >= 3 && buf[0] == 'U' && buf[1] == 'N' && buf[2] == 'C' {
|
||||||
|
buf = buf[2:]
|
||||||
|
buf[0] = '\\'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf
|
return buf
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ foreign ws2_32 {
|
|||||||
g: GROUP,
|
g: GROUP,
|
||||||
dwFlags: DWORD,
|
dwFlags: DWORD,
|
||||||
) -> SOCKET ---
|
) -> SOCKET ---
|
||||||
|
socket :: proc(
|
||||||
|
af: c_int,
|
||||||
|
type: c_int,
|
||||||
|
protocol: c_int,
|
||||||
|
) -> SOCKET ---
|
||||||
|
|
||||||
ioctlsocket :: proc(s: SOCKET, cmd: c_long, argp: ^c_ulong) -> c_int ---
|
ioctlsocket :: proc(s: SOCKET, cmd: c_long, argp: ^c_ulong) -> c_int ---
|
||||||
closesocket :: proc(socket: SOCKET) -> c_int ---
|
closesocket :: proc(socket: SOCKET) -> c_int ---
|
||||||
@@ -76,10 +81,10 @@ foreign ws2_32 {
|
|||||||
listen :: proc(socket: SOCKET, backlog: c_int) -> c_int ---
|
listen :: proc(socket: SOCKET, backlog: c_int) -> c_int ---
|
||||||
connect :: proc(socket: SOCKET, address: ^SOCKADDR, len: c_int) -> c_int ---
|
connect :: proc(socket: SOCKET, address: ^SOCKADDR, len: c_int) -> c_int ---
|
||||||
getaddrinfo :: proc(
|
getaddrinfo :: proc(
|
||||||
node: ^c_char,
|
node: cstring,
|
||||||
service: ^c_char,
|
service: cstring,
|
||||||
hints: ^ADDRINFOA,
|
hints: ^ADDRINFOA,
|
||||||
res: ^ADDRINFOA,
|
res: ^^ADDRINFOA,
|
||||||
) -> c_int ---
|
) -> c_int ---
|
||||||
freeaddrinfo :: proc(res: ^ADDRINFOA) ---
|
freeaddrinfo :: proc(res: ^ADDRINFOA) ---
|
||||||
select :: proc(
|
select :: proc(
|
||||||
|
|||||||
@@ -2003,6 +2003,21 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv,
|
|||||||
constraints = gb_string_appendc(constraints, "}");
|
constraints = gb_string_appendc(constraints, "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The SYSCALL instruction stores the address of the
|
||||||
|
// following instruction into RCX, and RFLAGS in R11.
|
||||||
|
//
|
||||||
|
// RSP is not saved, but at least on Linux it appears
|
||||||
|
// that the kernel system-call handler does the right
|
||||||
|
// thing.
|
||||||
|
//
|
||||||
|
// Some but not all system calls will additionally
|
||||||
|
// clobber memory.
|
||||||
|
//
|
||||||
|
// TODO: FreeBSD is different and will also clobber
|
||||||
|
// R8, R9, and R10. Additionally CF is used to
|
||||||
|
// indicate an error instead of -errno.
|
||||||
|
constraints = gb_string_appendc(constraints, ",~{rcx},~{r11},~{memory}");
|
||||||
|
|
||||||
inline_asm = llvm_get_inline_asm(func_type, make_string_c(asm_string), make_string_c(constraints));
|
inline_asm = llvm_get_inline_asm(func_type, make_string_c(asm_string), make_string_c(constraints));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+4
-1
@@ -1,7 +1,7 @@
|
|||||||
ODIN=../../odin
|
ODIN=../../odin
|
||||||
PYTHON=$(shell which python3)
|
PYTHON=$(shell which python3)
|
||||||
|
|
||||||
all: download_test_assets image_test compress_test strings_test hash_test
|
all: download_test_assets image_test compress_test strings_test hash_test crypto_test
|
||||||
|
|
||||||
download_test_assets:
|
download_test_assets:
|
||||||
$(PYTHON) download_assets.py
|
$(PYTHON) download_assets.py
|
||||||
@@ -17,3 +17,6 @@ strings_test:
|
|||||||
|
|
||||||
hash_test:
|
hash_test:
|
||||||
$(ODIN) run hash -out=test_hash -o:speed -no-bounds-check
|
$(ODIN) run hash -out=test_hash -o:speed -no-bounds-check
|
||||||
|
|
||||||
|
crypto_test:
|
||||||
|
$(ODIN) run crypto -out=crypto_hash -o:speed -no-bounds-check
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
ODIN=../../odin
|
||||||
|
|
||||||
|
all: botan_test
|
||||||
|
|
||||||
|
botan_test:
|
||||||
|
$(ODIN) run botan -out=botan_hash -o:speed -no-bounds-check
|
||||||
Vendored
+5
@@ -6,3 +6,8 @@ echo ---
|
|||||||
echo Running vendor:botan tests
|
echo Running vendor:botan tests
|
||||||
echo ---
|
echo ---
|
||||||
%PATH_TO_ODIN% run botan %COMMON%
|
%PATH_TO_ODIN% run botan %COMMON%
|
||||||
|
|
||||||
|
echo ---
|
||||||
|
echo Running vendor:glfw tests
|
||||||
|
echo ---
|
||||||
|
%PATH_TO_ODIN% run glfw %COMMON%
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
package test_vendor_glfw
|
||||||
|
|
||||||
|
import "core:testing"
|
||||||
|
import "core:fmt"
|
||||||
|
import "vendor:glfw"
|
||||||
|
|
||||||
|
GLFW_MAJOR :: 3
|
||||||
|
GLFW_MINOR :: 3
|
||||||
|
GLFW_PATCH :: 4
|
||||||
|
|
||||||
|
TEST_count := 0
|
||||||
|
TEST_fail := 0
|
||||||
|
|
||||||
|
when ODIN_TEST {
|
||||||
|
expect :: testing.expect
|
||||||
|
log :: testing.log
|
||||||
|
} else {
|
||||||
|
expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) {
|
||||||
|
fmt.printf("[%v] ", loc)
|
||||||
|
TEST_count += 1
|
||||||
|
if !condition {
|
||||||
|
TEST_fail += 1
|
||||||
|
fmt.println(message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.println(" PASS")
|
||||||
|
}
|
||||||
|
log :: proc(t: ^testing.T, v: any, loc := #caller_location) {
|
||||||
|
fmt.printf("[%v] ", loc)
|
||||||
|
fmt.printf("log: %v\n", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main :: proc() {
|
||||||
|
t := testing.T{}
|
||||||
|
test_glfw(&t)
|
||||||
|
|
||||||
|
fmt.printf("%v/%v tests successful.\n", TEST_count - TEST_fail, TEST_count)
|
||||||
|
}
|
||||||
|
|
||||||
|
@(test)
|
||||||
|
test_glfw :: proc(t: ^testing.T) {
|
||||||
|
major, minor, patch := glfw.GetVersion()
|
||||||
|
expect(t, major == GLFW_MAJOR && minor == GLFW_MINOR, fmt.tprintf("Expected GLFW.GetVersion: %v.%v.%v, got %v.%v.%v instead", GLFW_MAJOR, GLFW_MINOR, GLFW_PATCH, major, minor, patch))
|
||||||
|
}
|
||||||
Vendored
+1
-1
@@ -6,7 +6,7 @@ import vk "vendor:vulkan"
|
|||||||
when ODIN_OS == "linux" { foreign import glfw "system:glfw" } // TODO: Add the billion-or-so static libs to link to in linux
|
when ODIN_OS == "linux" { foreign import glfw "system:glfw" } // TODO: Add the billion-or-so static libs to link to in linux
|
||||||
when ODIN_OS == "windows" {
|
when ODIN_OS == "windows" {
|
||||||
foreign import glfw {
|
foreign import glfw {
|
||||||
"lib/glfw3.lib",
|
"../lib/glfw3_mt.lib",
|
||||||
"system:user32.lib",
|
"system:user32.lib",
|
||||||
"system:gdi32.lib",
|
"system:gdi32.lib",
|
||||||
"system:shell32.lib",
|
"system:shell32.lib",
|
||||||
|
|||||||
Reference in New Issue
Block a user