Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

From Nothing To Hello World

This page explain the quickest way to test a program on Redox. This tutorial doesn't build Redox from source.

In this example we will use a "Hello World" program written in Rust.

  1. 建立 tryredox 資料夾。

    mkdir -p ~/tryredox
    
  2. 導航至 tryredox 資料夾。

    cd ~/tryredox
    
  3. 下載用於組態 Podman 的腳本,並下載 Redox 建置系統。

    curl -sf https://gitlab.redox-os.org/redox-os/redox/raw/master/podman_bootstrap.sh -o podman_bootstrap.sh
    
  4. 執行下載的腳本。

    time bash -e podman_bootstrap.sh
    
  5. 在當前外殼中啟用 Rust 工具鏈。

    source ~/.cargo/env
    
  6. 導航至 Redox 建置系統目錄。

    cd ~/tryredox/redox
    
  7. 建立 .config 檔案,並增添 REPO_BINARY 環境變數來下載預編譯軟體包。

    echo "REPO_BINARY?=1 \n CONFIG_NAME?=my-config" >> .config
    
  8. 建立 hello-world 配方資料夾。

    mkdir recipes/other/hello-world
    
  9. Create the source folder for the recipe.

    mkdir recipes/other/hello-world/source
    
  10. Navigate to the recipe's source folder.

    cd recipes/other/hello-world/source
    
  11. Initialize a Cargo project with the "Hello World" string.

    cargo init --name="hello-world"
    
  12. 建立 hello-world 配方組態。

    cd ~/tryredox/redox
    
    nano recipes/other/hello-world/recipe.toml
    
  13. Add the following to the recipe configuration:

    [build]
    template = "cargo"
    
  14. 建立 my-config 檔案系統組態。

    cp config/x86_64/desktop.toml config/x86_64/my-config.toml
    
  15. Open the my-config filesystem configuration file (i.e., config/x86_64/my-config.toml) and add the hello-world package to it.

    [packages]
    # Add the item below
    hello-world = "source"
    
  16. 編譯 Hello World 程式並更新 Redox 映像檔。

    time make prefix rp.hello-world
    
  17. Start the Redox virtual machine without a GUI.

    make qemu gpu=no
    
  18. 在 Redox 登入畫面,於使用者名稱欄位輸入「user」並按下 Enter。

  19. 執行「Hello World」程式。

    helloworld
    
  20. 關閉 Redox 虛擬機。

    sudo shutdown