Ninja构建系统入门--手敲一遍BUILD.ninja

本文介绍了Ninja构建工具的入门,包括Ninja的简介、如何通过编译Ninja源码进行安装,以及手动编写.ninja文件的步骤。通过实例展示了如何创建和运行一个简单的C++程序,演示了Ninja的编译和链接过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ninja构建系统入门--手敲一遍BUILD.ninja

准备

啥子是Ninnja

Ninja 是Google的一名程序员推出的注重速度的构建工具,一般在Unix/Linux上的程序通过make/makefile来构建编译,而Ninja通过将编译任务并行组织,大大提高了构建速度。

开始

下面简单介绍下通过编译 Ninja 源码的方式来安装
首先,确保已经安装了这些依赖:g++,graphviz,gtest,git,re2c 和 python2.7+。

$ git clone git://github.com/ninja-build/ninja.git && cd ninja
$ git checkout release
$ cat README
$ ls
COPYING  HACKING.md  README  RELEASING  bootstrap.py  configure.py  doc/  misc/  src/

编译

一切就绪之后,执行下列命令来编译 ninja

$ ./configure.py --bootstrap

上述命令会在当前目录下生成一个叫 ninja (Windows 下是 ninja.exe)的可执行文件,然后我们把这个文件拷到系统目录(比如 /usr/bin)就完成安装了。

手动编写 .ninja 文件

vim build.ninja


ninja_required_version = 1.5


cflags = -Wall -Werror
cc = g++

rule cc
  command = $cc -c $cflags -MD -MF $out.d $in -o $out
  description= 编译 $in 成为 $out
  depfile = $out.d
  deps=gcc
  
build dome.o: cc dome.cpp

rule link_dome
   command= $cc $defines  $includes $cflags $in -o $out
   description= 连接 $in 成为 $out
build dome: link_dome dome.o

build all: phony dome

default all

vim dome.cpp

#include <iostream>
int main(void){
	std::cout << "hello world" << std::endl;
	return 0;
}

ninja all
在这里插入图片描述
在这里插入图片描述

结束

在这里插入图片描述

### DeepSeek R1 模型复现代码 GitHub 仓库实现 对于希望获取 DeepSeek R1 模型或项目复现代码的开发者而言,GitHub 是一个重要的资源平台。通常情况下,开源社区会提供官方或其他贡献者的实现版本。 许多研究团队会在论文发布的同时公开相应的源码链接,方便其他研究人员验证实验结果并进一步改进算法。如果 DeepSeek R1 已经发布了对应的预训练模型或是详细的架构描述,则很可能存在配套的开源实现[^1]。 为了找到特定于 DeepSeek R1 的 GitHub 实现库,建议采取以下方式搜索: - 使用关键词 `DeepSeek R1` 结合 `reproduction`, `implementation` 或者 `source code` 进行组合查询; - 查看是否有来自作者所在机构发布的官方存储库; - 浏览 Issues 和 Pull Requests 页面了解最新动态以及潜在问题解决方案; 值得注意的是,并不是所有的研究成果都会立即开放其完整的工程化实现细节。因此,在某些时候可能需要等待一段时间直到更多资料被公布出来,或者是通过阅读原始文献来尝试自行构建类似的系统结构[^2]。 ```python import requests from bs4 import BeautifulSoup def search_github_repos(query): url = f"https://github.com/search?q={query}&type=repositories" response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') repos_info = [] items = soup.select('.repo-list-item') for item in items[:5]: # 获取前五个匹配项作为示例展示 title = item.h3.a['href'].split('/')[-1] link = "https://github.com" + item.h3.a['href'] description_tag = item.find('p', class_='mb-1') desc = description_tag.text.strip() if description_tag else '' repo_data = { "title": title, "link": link, "description": desc } repos_info.append(repo_data) return repos_info search_query = "DeepSeek R1 reproduction OR implementation" results = search_github_repos(search_query) for result in results: print(f"{result['title']}\n{result['link']}\nDescription: {result['description']}\n") ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

无与伦比的傻

微信公众号:dasha500

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值