Moves src/Cargo.toml to top-level (#979)

This commit is contained in:
Putta Khunchalee 2024-09-11 23:56:30 +07:00 committed by GitHub
parent c41cedf00d
commit 3e1472a3a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 75 additions and 73 deletions

View File

@ -13,7 +13,6 @@ jobs:
uses: actions/checkout@v4
- name: Check Rust styles
run: cargo fmt --check
working-directory: src
build-windows:
name: Build
uses: ./.github/workflows/ci-windows.yml

2
.gitignore vendored
View File

@ -3,5 +3,5 @@
/.flatpak-builder/
/.kernel-debug
/build/
/src/target/
/target/
Cargo.lock

View File

@ -14,4 +14,49 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
# Setup Rust targets.
if(WIN32)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
set(KERNEL_TARGET x86_64-unknown-none)
else()
message(FATAL_ERROR "Target CPU is not supported")
endif()
else()
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(KERNEL_TARGET x86_64-unknown-none)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
# Pre-compiled core crate for aarch64-unknown-none-softfloat does not support
# Position-Independent Executable so we need nightly toolchain for build-std feature to
# re-build core crate to support Position-Independent Executable.
set(KERNEL_TARGET aarch64-unknown-none-softfloat)
set(KERNEL_TOOLCHAIN +nightly)
set(KERNEL_OPTS -Z build-std=core,alloc)
else()
message(FATAL_ERROR "Target CPU is not supported")
endif()
endif()
set(KERNEL_OUTPUTS $<IF:$<CONFIG:Debug>,${CMAKE_CURRENT_SOURCE_DIR}/target/${KERNEL_TARGET}/debug,${CMAKE_CURRENT_SOURCE_DIR}/target/${KERNEL_TARGET}/release>)
set(KERNEL ${KERNEL_OUTPUTS}/obkrnl)
set(HOST_OUTPUTS $<IF:$<CONFIG:Debug>,${CMAKE_CURRENT_SOURCE_DIR}/target/debug,${CMAKE_CURRENT_SOURCE_DIR}/target/release>)
if(WIN32)
set(LIBCORE ${HOST_OUTPUTS}/core.lib)
else()
set(LIBCORE ${HOST_OUTPUTS}/libcore.a)
endif()
add_custom_target(core
COMMAND cargo build $<IF:$<CONFIG:Debug>,--profile=dev,--release>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/core
BYPRODUCTS ${LIBCORE})
add_custom_target(kernel
COMMAND cargo ${KERNEL_TOOLCHAIN} build $<IF:$<CONFIG:Debug>,--profile=dev,--release> --target ${KERNEL_TARGET} ${KERNEL_OPTS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/obkrnl
BYPRODUCTS ${KERNEL})
add_dependencies(core kernel)
# Add GUI.
add_subdirectory(src)

24
Cargo.toml Normal file
View File

@ -0,0 +1,24 @@
[workspace]
resolver = "2"
members = [
"src/core",
"src/fs",
"src/gmtx",
"src/kernel",
"src/llt",
"src/macros",
"src/obconf",
"src/obkrnl",
"src/obvirt",
"src/param",
"src/pfs",
"src/pkg",
"src/tls"
]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
debug = "full"

View File

@ -1,6 +1,7 @@
# External dependencies.
find_package(Qt6 REQUIRED COMPONENTS Svg Widgets)
find_package(Threads REQUIRED)
if(WIN32 OR (UNIX AND NOT APPLE))
find_package(Vulkan REQUIRED)
endif()
@ -9,50 +10,6 @@ if(APPLE)
find_library(HYPERVISOR Hypervisor REQUIRED)
endif()
# Setup Rust target.
if(WIN32)
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
set(KERNEL_TARGET x86_64-unknown-none)
else()
message(FATAL_ERROR "Target CPU is not supported")
endif()
else()
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(KERNEL_TARGET x86_64-unknown-none)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
# Pre-compiled core crate for aarch64-unknown-none-softfloat does not support
# Position-Independent Executable so we need nightly toolchain for build-std feature to
# re-build core crate to support Position-Independent Executable.
set(KERNEL_TARGET aarch64-unknown-none-softfloat)
set(KERNEL_TOOLCHAIN +nightly)
set(KERNEL_OPTS -Z build-std=core,alloc)
else()
message(FATAL_ERROR "Target CPU is not supported")
endif()
endif()
set(KERNEL_OUTPUTS $<IF:$<CONFIG:Debug>,${CMAKE_CURRENT_SOURCE_DIR}/target/${KERNEL_TARGET}/debug,${CMAKE_CURRENT_SOURCE_DIR}/target/${KERNEL_TARGET}/release>)
set(KERNEL ${KERNEL_OUTPUTS}/obkrnl)
set(HOST_OUTPUTS $<IF:$<CONFIG:Debug>,${CMAKE_CURRENT_SOURCE_DIR}/target/debug,${CMAKE_CURRENT_SOURCE_DIR}/target/release>)
if(WIN32)
set(LIBCORE ${HOST_OUTPUTS}/core.lib)
else()
set(LIBCORE ${HOST_OUTPUTS}/libcore.a)
endif()
add_custom_target(core
COMMAND cargo build $<IF:$<CONFIG:Debug>,--profile=dev,--release>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/core
BYPRODUCTS ${LIBCORE})
add_custom_target(kernel
COMMAND cargo ${KERNEL_TOOLCHAIN} build $<IF:$<CONFIG:Debug>,--profile=dev,--release> --target ${KERNEL_TARGET} ${KERNEL_OPTS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/obkrnl
BYPRODUCTS ${KERNEL})
add_dependencies(core kernel)
# Setup application target.
add_executable(obliteration WIN32 MACOSX_BUNDLE
ansi_escape.cpp

View File

@ -1,23 +0,0 @@
[workspace]
resolver = "2"
members = [
"core",
"fs",
"gmtx",
"kernel",
"llt",
"macros",
"obconf",
"obkrnl",
"obvirt",
"param",
"pfs",
"pkg",
"tls"
]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"

View File

@ -356,13 +356,13 @@ void MainWindow::startKernel()
#endif
#if defined(_WIN32) && defined(NDEBUG)
kernel = (b / L"src" / L"target" / target / L"release" / L"obkrnl").u8string();
kernel = (b / L"target" / target / L"release" / L"obkrnl").u8string();
#elif defined(_WIN32) && !defined(NDEBUG)
kernel = (b / L"src" / L"target" / target / L"debug" / L"obkrnl").u8string();
kernel = (b / L"target" / target / L"debug" / L"obkrnl").u8string();
#elif defined(NDEBUG)
kernel = (b / "src" / "target" / target / "release" / "obkrnl").u8string();
kernel = (b / "target" / target / "release" / "obkrnl").u8string();
#else
kernel = (b / "src" / "target" / target / "debug" / "obkrnl").u8string();
kernel = (b / "target" / target / "debug" / "obkrnl").u8string();
#endif
} else {
#ifdef _WIN32