Skip to content

Commit

Permalink
Moves src/Cargo.toml to top-level (#979)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon authored Sep 11, 2024
1 parent c41cedf commit 3e1472a
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 73 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
/.flatpak-builder/
/.kernel-debug
/build/
/src/target/
/target/
Cargo.lock
45 changes: 45 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 24 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
45 changes: 1 addition & 44 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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
Expand Down
23 changes: 0 additions & 23 deletions src/Cargo.toml

This file was deleted.

8 changes: 4 additions & 4 deletions src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3e1472a

Please sign in to comment.