From 37d4a86392c204fae3421f713a320e3eff88f3c5 Mon Sep 17 00:00:00 2001 From: Thien Tran Date: Tue, 11 Feb 2025 10:23:36 +0800 Subject: [PATCH 1/4] doc: bring back old build from source instructions --- BUILDING.md | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 8 +---- 2 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 BUILDING.md diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 000000000..026915445 --- /dev/null +++ b/BUILDING.md @@ -0,0 +1,102 @@ +# Build Cortex.cpp from source + +Firstly, clone the Cortex.cpp repository [here](https://github.com/janhq/cortex.cpp) and initialize the submodules: + +```bash +git clone https://github.com/janhq/cortex.cpp +cd cortex.cpp +git submodule update --init --recursive +``` + +#### Windows + +1. Navigate to the `engine` folder. +2. Configure the vpkg: + +```bash +cd vcpkg +./bootstrap-vcpkg.bat +vcpkg install +``` + +3. Build the Cortex.cpp inside the `engine/build` folder (you can change `-DCMAKE_TOOLCHAIN_FILE` to use your own `vcpkg`): + +```bash +mkdir build +cd build +cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static +cmake --build . --config Release +``` + +4. Verify that Cortex.cpp is installed correctly by getting help information. + +```sh +cortex -h +``` + +#### Linux and MacOS + +1. Navigate to the `engine` folder. +2. Configure the vpkg: + +```bash +cd vcpkg +./bootstrap-vcpkg.sh +vcpkg install +``` + +3. Build the Cortex.cpp inside the `engine/build` folder (you can change `-DCMAKE_TOOLCHAIN_FILE` to use your own `vcpkg`): + +```bash +mkdir build +cd build +cmake .. -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake +make -j4 +``` + +4. Verify that Cortex.cpp is installed correctly by getting help information. + +```sh +./cortex -h +``` + +#### Devcontainer / Codespaces + +1. Open Cortex.cpp repository in Codespaces or local devcontainer + + [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/janhq/cortex.cpp?quickstart=1) + + ```sh + devcontainer up --workspace-folder . + ``` + +2. Configure vpkg in `engine/vcpkg`: + +```bash {"tag": "devcontainer"} +cd engine/vcpkg +export VCPKG_FORCE_SYSTEM_BINARIES="$([[ $(uname -m) == 'arm64' ]] && echo '1' || echo '0')" +./bootstrap-vcpkg.sh +``` + +3. Build the Cortex.cpp inside the `engine/build` folder: + +```bash {"tag": "devcontainer"} +cd engine +mkdir -p build +cd build +cmake .. -DCMAKE_TOOLCHAIN_FILE=$(realpath ..)/vcpkg/scripts/buildsystems/vcpkg.cmake +make -j$(grep -c ^processor /proc/cpuinfo) +``` + +4. Verify that Cortex.cpp is installed correctly by getting help information. + +```sh {"tag": "devcontainer"} +cd engine/build +./cortex -h +``` + +5. Everytime a rebuild is needed, just run the commands above using oneliner + +```sh +npx -y runme run --filename README.md -t devcontainer -y +``` diff --git a/README.md b/README.md index 756a5f3fd..0feb179d3 100644 --- a/README.md +++ b/README.md @@ -160,13 +160,7 @@ cortex-nightly hardware activate ### Build from Source -```bash -git clone https://github.com/janhq/cortex.cpp -cd cortex.cpp -git submodule update --init --recursive -cd engine/vcpkg && ./bootstrap-vcpkg.sh -cd ../build && cmake .. && make -j4 -``` +See [BUILDING.md](BUILDING.md) ## Uninstall Cortex From 1f4d32eb11639ce8e9d27483e2c2680370329798 Mon Sep 17 00:00:00 2001 From: Thien Tran Date: Tue, 11 Feb 2025 10:25:27 +0800 Subject: [PATCH 2/4] doc: fix missing ./ --- BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index 026915445..ff580eb46 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -42,7 +42,7 @@ cortex -h ```bash cd vcpkg ./bootstrap-vcpkg.sh -vcpkg install +./vcpkg install ``` 3. Build the Cortex.cpp inside the `engine/build` folder (you can change `-DCMAKE_TOOLCHAIN_FILE` to use your own `vcpkg`): From c87650ac71d312daf0ab4ed75db9dc9688e5ef63 Mon Sep 17 00:00:00 2001 From: Thien Tran Date: Tue, 11 Feb 2025 10:28:15 +0800 Subject: [PATCH 3/4] doc: add ./ for windows too --- BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index ff580eb46..dee499c41 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -16,7 +16,7 @@ git submodule update --init --recursive ```bash cd vcpkg ./bootstrap-vcpkg.bat -vcpkg install +./vcpkg install ``` 3. Build the Cortex.cpp inside the `engine/build` folder (you can change `-DCMAKE_TOOLCHAIN_FILE` to use your own `vcpkg`): From ac22440e8b98b5a18834891fe0087c39cb2b0367 Mon Sep 17 00:00:00 2001 From: Thien Tran Date: Tue, 11 Feb 2025 14:06:56 +0800 Subject: [PATCH 4/4] add cmake prereq --- BUILDING.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/BUILDING.md b/BUILDING.md index dee499c41..47d246a03 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -8,6 +8,15 @@ cd cortex.cpp git submodule update --init --recursive ``` +You also need to install CMake. On Linux and MacOS, you can install CMake via your package manager + +```bash +sudo apt install cmake # Ubuntu +brew install cmake # MacOS +``` + +On Windows, you can download CMake from https://cmake.org/download/. + #### Windows 1. Navigate to the `engine` folder.