Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更改了xmake工程的配置 #5

Merged
merged 8 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions arch/arm/typedef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef __TYPEDEF_H__
#define __TYPEDEF_H__

#define NULL 0

typedef unsigned char uint8_t;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why for arm? These should be the common definitions.

typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;

typedef signed char int8_t;
typedef signed short int int16_t;
typedef signed int int32_t;
typedef signed long long int64_t;

typedef volatile uint8_t vuint8_t;
typedef volatile uint16_t vuint16_t;
typedef volatile uint32_t vuint32_t;
typedef volatile uint64_t vuint64_t;

typedef volatile int8_t vint8_t;
typedef volatile int16_t vint16_t;
typedef volatile int32_t vint32_t;
typedef volatile int64_t vint64_t;

typedef int64_t intmax_t;
typedef uint64_t uintmax_t;

#endif
4 changes: 2 additions & 2 deletions include/stdarg.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef __STDARG_H__
#define __STDARG_H__

typedef char * va_list;
#define va_list __builtin_va_list
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_end(v) __builtin_va_end(v)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看看网页版本,乱的。另外,你这边是TAB

#define va_arg(v,l) __builtin_va_arg(v,l)
#define va_copy(d,s) __builtin_va_copy(d,s)

Expand Down
2 changes: 1 addition & 1 deletion src/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int print(const char *str, ...)
ptr_string++;
continue;
case 'c':
arg_int_val = va_arg(ptr_args, int);
arg_int_val = va_arg(ptr_args, char);
m_putc((char)arg_int_val);
ret_num++;
ptr_string++;
Expand Down
13 changes: 13 additions & 0 deletions toolchains/riscv-none-embed.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
PATH = "D:\\RT-ThreadStudio\\repo\\Extract\\ToolChain_Support_Packages\\WCH\\RISC-V-GCC-WCH\\8.2.0"
BIN_DIR = PATH .. "\\bin"
PREFIX = "riscv-none-embed-"

TOOLCHAIN_NAME = "riscv-none-embed"

toolchain(TOOLCHAIN_NAME)

set_kind("standalone")
set_sdkdir(PATH)
set_bindir(BIN_DIR)

toolchain_end()
21 changes: 7 additions & 14 deletions toolchains/riscv64-unknown-elf.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
PATH = "E:\\toolchain\\riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-w64-mingw32"
BINDIR =PATH.."\\bin"
PREFIX = "riscv64-unknown-elf-"

PATH = "E:\toolchain\riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-w64-mingw32"
TOOLCHAIN_NAME = "riscv64-unknown-elf"

toolchain("riscv64-unknown-elf")

set_kind("standalone")
set_bindir("E:/toolchain/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-w64-mingw32/bin")
set_toolset("cc", "$PATH\bin\riscv64-unknown-elf-gcc.exe")
set_toolset("cxx", "$PATH\bin\riscv64-unknown-elf-g++.exe")
set_toolset("ld", "$PATH\bin\riscv64-unknown-elf-ld.exe")
--set_toolset("sh", "$PATH\bin\riscv64-unknown-elf-gcc-sh.exe")
set_toolset("ar", "$PATH\bin\riscv64-unknown-elf-gcc-ar.exe")
set_toolset("ex", "$PATH\bin\riscv64-unknown-elf-gcc-ar.exe")
set_toolset("strip", "$PATH\bin\riscv64-unknown-elf-strip.exe")
set_toolset("mm", "$PATH\bin\riscv64-unknown-elf-gcc.exe")
set_toolset("mxx", "$PATH\bin\riscv64-unknown-elf-gcc.exe", "$PATH\bin\riscv64-unknown-elf-g++.exe")
set_toolset("as", "$PATH\bin\riscv64-unknown-elf-gcc.exe")
set_sdkdir(PATH)
set_bindir(BINDIR)

toolchain_end()


26 changes: 15 additions & 11 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,33 @@ add_rules("mode.debug", "mode.release")
-- add toolchains
includes("toolchains/*.lua")

DEVICE = ' -march=rv32imac -mabi=ilp32 -DUSE_PLIC -DUSE_M_TIME -DNO_INIT -mcmodel=medany -msmall-data-limit=8 -L. -nostartfiles -lc '
--set target
target("mlibc")
--set static lib
-- set target file type
set_kind("static")
--strip all infomation
set_strip("all")
--use cross compiler
set_plat("cross")
--set default target
set_default(true)
--set target file Extension
set_extension(".a")
-- set target dir
set_targetdir("./")
--set target filename
set_filename("mlibc.a")
--set optimize O1
set_optimize("fast")
--set languages standard
set_languages("c99", "cxx11")

add_cflags("-nostdlib", {force = true})

add_files("src/**.c")
-- set compiler cflags for device
add_cflags(DEVICE, {force = true})
-- set compiler cflags for no standard library
add_cflags("-nostdlib","-ffreestanding", {force = true})
-- add all files
add_files("src/*.c")
-- add headfile dir
add_includedirs("include",{public = true})
set_toolchains("riscv64-unknown-elf")

-- set_toolchains("riscv64-unknown-elf")
set_toolchains("riscv-none-embed")
target_end()

--
Expand Down