GithubHelp home page GithubHelp logo

nakos's Introduction

NakOS

NakOS is an operating system written using C++.

NakOS

Developing for NakOS

To develop for NakOS, you must first set up your cross-compiler. Instructions on how to do this could be found here. Put the cross compiler in folder called Toolchain/.

The way you configure and build gcc should be slightly modified when you work with C++. The guide will only correctly configure the freestanding libc libraries, but we want libstd++, gcc's version of C++ Standard Library. You instead build libc and libstd++ like so:

mkdir build-gcc
cd build-gcc
# '--disable-hosted-libstdcxx' is added
../gcc-x.y.z/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers --disable-hosted-libstdcxx
make all-gcc
make all-target-libgcc
# Need to add for freestanding C++ Standard Libraries
make all-target-libstdc++-v3
make install-gcc
# Need to add for freestanding C++ Standard Libraries
make install-target-libstdc++-v3

make install-target-libgcc

Building NakOS

cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 . -GNinja -DCMAKE_TOOLCHAIN_FILE=Toolchain/os-dev-toolchain.cmake

LSP Setup

Vim

If you're using clangd, you have to pass --query-driver=/path/to/cross-compiler as an argument. If you use CoC, your config file (you generate this with :CocLocalConfig) should look like:

{
  "languageserver": {
    "clangd": {
      "command": "clangd",
      "args": ["--background-index", "--query-driver", "/home/jared/Projects/CPP/NakOS/Toolchain/opt/cross/bin/i686-elf-g++"],
      "rootPatterns": ["compile_flags.txt", "compile_commands.json", ".vim/", ".git/", ".hg/"],
      "filetypes": ["c", "cpp", "objc", "objcpp"]
    }
  }
}

You may have more properties within the configuration file and the path to the cross-compiler will certainly differ. For example, my full NakOS/.vim/coc-settings.json, looks like:

{
  "languageserver": {
    "clangd": {
      "command": "clangd",
      "args": ["--query-driver", "/home/jared/Projects/CPP/NakOS/Toolchain/opt/cross/bin/i686-elf-g++"],
      "rootPatterns": ["compile_flags.txt", "compile_commands.json", ".vim/", ".git/", ".hg/"],
      "filetypes": ["c", "cpp", "objc", "objcpp"]
    }
  },

  "suggest.noselect": true
}

### Neovim

If you have Neovim 0.9.0 or above, you can have an .nvim.lua file with the following

require("lspconfig").clangd.setup({
    on_new_config = function(config)
            config.cmd = {
                "clangd",
                "--background-index",
                "--query-driver",
                "/home/jared/Projects/CPP/NakOS/Toolchain/opt/cross/bin/i686-elf-g++",
            }
        end
})

If you are using NeoVim and lsp_config, you could add the following to your init.lua. Replace project_root with your project directory and replace

"/home/jared/Projects/CPP/NakOS/Toolchain/opt/cross/bin/i686-elf-g++",

with where your compiler is located

local lspconfig = require("lspconfig")
local project_root = "/home/jared/Projects/CPP/NakOS"

if vim.fn.getcwd() == project_root then
    lspconfig.clangd.setup({
        cmd = {
            "clangd",
            "--background-index",
            "--query-driver",
            "/home/jared/Projects/CPP/NakOS/Toolchain/opt/cross/bin/i686-elf-g++",
        },
        filetypes = { "c", "cpp", "objc", "objcpp" },
    })
end

An alternative way to configure your init.lua is by adding the following:

require("lspconfig").clangd.setup({
    on_new_config = function(config, root_dir)
        local path = "/home/jared/Projects/CPP/NakOS"
        if vim.startswith(root_dir, path) then
            config.cmd = {
                "clangd",
                "--background-index",
                "--query-driver",
                "/home/jared/Projects/CPP/NakOS/Toolchain/opt/cross/bin/i686-elf-g++",
            }
        end
    end,
})

Which accomplishes the same thing

And if you're using LazyVim, you can add create a folder under lua/plugins and add the following

-- File: ~/.config/nvim/lua/plugins/lspconfig.lua

return {
    "neovim/nvim-lspconfig",
    config = function()
        require("lspconfig").clangd.setup({
            cmd = {
                "clangd",
                "--background-index",
                "--query-driver",
                "/home/jared/Projects/CPP/NakOS/Toolchain/opt/cross/bin/i686-elf-g++",
            },
            filetypes = { "c", "cpp", "objc", "objcpp" },
        })
    end,
}

nakos's People

Contributors

j-barnak avatar

Stargazers

 avatar

Watchers

Oleg Kovalenko avatar  avatar

nakos's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.