1 Star 0 Fork 0

fibjs / build_tools

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

build_tools

fibjs's build_tools based on .cmake

Getting Started

To use build_tools for fibjs, you need install:

  • CMake >= 3.0
  • C/Cpp Compiler
    • Windows: clang/VC++
    • Linux: clang
    • MacOS: clang

To explain how to use built_tools, we try to compile examples/hello.

All <built_tool_path> in codes refers to this project's root path.

Workflow on CMake ccripts

We recommend CMake script-mode as build workflow, that is, instead of bash/sh/cmd/powershell, just use CMake script to drive your build.

include(<built_tool_path>/cmake-scripts/get_env.cmake)

set(WORK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/output")

set(BIN_ROOT "${WORK_ROOT}/bin")
set(OUT_ROOT "${WORK_ROOT}/out")
set(DIST_DIRNAME "${CMAKE_HOST_SYSTEM_NAME}_${BUILD_ARCH}_${BUILD_TYPE}")

if("${CLEAN_BUILD}" STREQUAL "true")
    rimraf(${BIN_ROOT}/${DIST_DIRNAME})
    rimraf(${OUT_ROOT}/${DIST_DIRNAME})
else()
    set(OUT_PATH "${OUT_ROOT}/${DIST_DIRNAME}")

    build("${CMAKE_CURRENT_SOURCE_DIR}" "${OUT_PATH}/hello")

    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test")
        build("${CMAKE_CURRENT_SOURCE_DIR}/test" "${OUT_PATH}/hello_test")
    endif()
endif()

As of this script, build funciton is defined in <built_tool_path>/cmake-scripts/get_env.cmake.

build(src_dirname, outputpath)

It tried to find <src_dirname>/CMakeLists.txt and run do cmake build against it. That is, you can customize by writing your own CMakeList.txt

Create CMakeLists.txt

Add one CMakeLists.txt on your project. like examples/hello/CMakeLists.txt.

To build one static Library, include cmake/Library.cmake

cmake_minimum_required(VERSION 2.6)

include(<built_tool_path>/cmake/Library.cmake)

Or put one CMakeLists.txt on project_root's test directory, like examples/hello/test/CMakeLists.txt.

To build one test executation, include cmake/LibraryTest.cmake

cmake_minimum_required(VERSION 2.6)

include(<built_tool_path>/cmake/LibraryTest.cmake)

Run CMake

cmake -DBUILD_ARCH=x64\
    -DBUILD_TYPE=release\
    -DCLEAN_BUILD=""\
    -DBUILD_JOBS=4\
    -DBUILD_USE_CLANG=1\
    -P build.cmake

see more configuration on

Copyright

MIT License

MIT License Copyright (c) 2021 fibjs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

fibjs's build_tools based on .cmake 展开 收起
Shell 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/fibjs/build_tools.git
git@gitee.com:fibjs/build_tools.git
fibjs
build_tools
build_tools
dev

搜索帮助