first commit

This commit is contained in:
amass 2025-03-28 18:09:49 +08:00
commit e18488ba0e
7 changed files with 153 additions and 0 deletions

17
.clang-format Normal file
View File

@ -0,0 +1,17 @@
BasedOnStyle: LLVM
ObjCBlockIndentWidth: 4
IndentWidth: 4
TabWidth: 4
AccessModifierOffset: -4
ColumnLimit: 120
#模板声明后换行
AlwaysBreakTemplateDeclarations: true
# 是否允许短if单行 If true, if (a) return; 可以放到同一行
AllowShortIfStatementsOnASingleLine: true
#短句 while (true) continue; 能被放到单行。
AllowShortLoopsOnASingleLine: true
AllowShortFunctionsOnASingleLine: false

44
.gitignore vendored Normal file
View File

@ -0,0 +1,44 @@
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.h
*.qmlc
*.jsc
Makefile*
*build-*
# Qt unit tests
target_wrapper.*
# QtCreator
*.autosave
# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*
# QtCreator CMake
CMakeLists.txt.user*
.idea
build
Frontend/node_modules
Frontend/package-lock.json

1
CMakeLists.txt Normal file
View File

@ -0,0 +1 @@
add_executable(app main.cpp)

1
Readme.md Normal file
View File

@ -0,0 +1 @@
这是一个使用 CMake 交叉编译的初始代码。

6
main.cpp Normal file
View File

@ -0,0 +1,6 @@
#include <iostream>
int main(int argc, char const *argv[]) {
std::cout << "hello world." << std::endl;
return 0;
}

66
resources/build.sh Executable file
View File

@ -0,0 +1,66 @@
#!/bin/bash
base_path=$(pwd)
if [[ $base_path == /home/* || $base_path == /root/* ]]; then
build_path=${base_path}/build
else
build_path=/tmp/build
fi
echo "build directory: $build_path"
function cmake_scan() {
if [ ! -d ${build_path} ]; then
mkdir ${build_path}
fi
cmake \
-G Ninja \
-S ${base_path} \
-B ${build_path} \
-DCMAKE_TOOLCHAIN_FILE=resources/toolchain.cmake \
-DCMAKE_BUILD_TYPE=Debug
}
function build() {
if [ ! -f "${build_path}/CMakeCache.txt" ]; then
cmake_scan
fi
if [ $? -ne 0 ]; then
exit 1
fi
cmake \
--build ${build_path} \
--target all
if [ $? -ne 0 ]; then
exit 1
fi
}
function clean() {
if [ -d ${build_path} ]; then
rm -fr ${build_path}
fi
}
function main() {
local cmd=$1
shift 1
case $cmd in
build)
build $@
;;
scan)
cmake_scan
;;
clean)
clean
;;
*)
build
;;
esac
}
main $@

18
resources/toolchain.cmake Normal file
View File

@ -0,0 +1,18 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
# which compilers to use for C and C++
set(CMAKE_C_COMPILER arm-buildroot-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-buildroot-linux-gnueabihf-g++)
# where is the target environment located
# set(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc
# /home/alex/mingw-install)
# adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)