mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-17 04:34:40 +03:00
see #72: use travis-ci
This commit is contained in:
19
.travis.yml
Normal file
19
.travis.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- openssl aes-256-cbc -K $encrypted_9157553ce13c_key -iv $encrypted_9157553ce13c_iv -in .travis/travis.enc -out ~/.ssh/id_rsa -d
|
||||||
|
- chmod 600 ~/.ssh/id_rsa
|
||||||
|
- git config --global user.name "Changkun Ou"
|
||||||
|
- git config --global user.email "hi@changkun.us"
|
||||||
|
- make build-env
|
||||||
|
|
||||||
|
addons:
|
||||||
|
ssh_known_hosts:
|
||||||
|
- changkun.de
|
||||||
|
|
||||||
|
script:
|
||||||
|
- make build
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
scp -r website/public/modern-cpp/* $encrypted_server_user@changkun.de:$encrypted_server_path
|
||||||
BIN
.travis/travis.enc
Normal file
BIN
.travis/travis.enc
Normal file
Binary file not shown.
26
Makefile
26
Makefile
@@ -1,12 +1,26 @@
|
|||||||
all: pdf website
|
DOCKER_ENV=changkun/modern-cpp-tutorial:build-env
|
||||||
|
LANGS = zh-cn en-us
|
||||||
|
ALL_BUILDS = pdf website
|
||||||
|
|
||||||
pdf:
|
# dep
|
||||||
cd pdf/zh-cn && make
|
|
||||||
cd pdf/en-us && make
|
all: $(ALL_BUILDS)
|
||||||
|
|
||||||
|
pdf: $(LANGS)
|
||||||
|
$(LANGS):
|
||||||
|
cd pdf/$@ && make && make clean
|
||||||
|
|
||||||
website:
|
website:
|
||||||
cd website && make
|
cd website && make
|
||||||
|
|
||||||
|
build:
|
||||||
|
docker run --rm -v `pwd`:/modern-cpp-tutorial -it $(DOCKER_ENV) make
|
||||||
|
|
||||||
|
# dev
|
||||||
|
|
||||||
|
build-env:
|
||||||
|
docker build -t $(DOCKER_ENV) -f ./docker/Dockerfile .
|
||||||
|
|
||||||
serve:
|
serve:
|
||||||
cd website && make s
|
cd website && make s
|
||||||
|
|
||||||
@@ -14,5 +28,7 @@ clean:
|
|||||||
cd pdf/zh-cn && make clean
|
cd pdf/zh-cn && make clean
|
||||||
cd pdf/en-us && make clean
|
cd pdf/en-us && make clean
|
||||||
cd website && make clean
|
cd website && make clean
|
||||||
|
docker images -f "dangling=true" -q | xargs docker rmi -f
|
||||||
|
docker image prune -f
|
||||||
|
|
||||||
.PHONY : pdf website clean
|
.PHONY : $(LANGS) $(ALL_BUILDS) serve build-env build-all clean
|
||||||
@@ -37,6 +37,14 @@
|
|||||||
|
|
||||||
本书的[网站](https://changkun.de/modern-cpp)源码可以在[这里](./website)找到,由 [hexo](https://hexo.io) 和 [vuejs](https://vuejs.org) 协同构建而成。网站旨在提供一个除 GitHub 之外的阅读方式,除了在桌面端访问之外,你也可以在移动端上阅读本书。
|
本书的[网站](https://changkun.de/modern-cpp)源码可以在[这里](./website)找到,由 [hexo](https://hexo.io) 和 [vuejs](https://vuejs.org) 协同构建而成。网站旨在提供一个除 GitHub 之外的阅读方式,除了在桌面端访问之外,你也可以在移动端上阅读本书。
|
||||||
|
|
||||||
|
## 构建
|
||||||
|
|
||||||
|
如果你希望在本地编译整个仓库,我们建议使用 [Docker](https://docs.docker.com/install/)。如果 Docker 在你的本地能正常使用,则可以简单的通过运行下面的指令完成构建:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ make build
|
||||||
|
```
|
||||||
|
|
||||||
## 致谢
|
## 致谢
|
||||||
|
|
||||||
笔者时间和水平有限,如果读者发现书中内容的错误,欢迎提 [Issue](https://github.com/changkun/modern-cpp-tutorial/issues),或者直接提 [Pull request](https://github.com/changkun/modern-cpp-tutorial/pulls)。详细贡献指南请参考[如何参与贡献](CONTRIBUTING.md),由衷感谢每一位指出本书中出现错误的读者,包括但不限于 [Contributors](https://github.com/changkun/modern-cpp-tutorial/graphs/contributors)。
|
笔者时间和水平有限,如果读者发现书中内容的错误,欢迎提 [Issue](https://github.com/changkun/modern-cpp-tutorial/issues),或者直接提 [Pull request](https://github.com/changkun/modern-cpp-tutorial/pulls)。详细贡献指南请参考[如何参与贡献](CONTRIBUTING.md),由衷感谢每一位指出本书中出现错误的读者,包括但不限于 [Contributors](https://github.com/changkun/modern-cpp-tutorial/graphs/contributors)。
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ There are few exercises At the end of each chapter of the book. It is for testin
|
|||||||
|
|
||||||
The source code of the [website](https://changkun.de/modern-cpp) of this book can be found [here](./website), which is built by [hexo](https://hexo.io) and [vuejs](https://vuejs.org). The website provides you another way of reading the book, it is also adapts to mobile.
|
The source code of the [website](https://changkun.de/modern-cpp) of this book can be found [here](./website), which is built by [hexo](https://hexo.io) and [vuejs](https://vuejs.org). The website provides you another way of reading the book, it is also adapts to mobile.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
If you are interested in build everything locally, it is recommended using [Docker](https://docs.docker.com/install/). To build, simply run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ make build
|
||||||
|
```
|
||||||
|
|
||||||
## Acknowledgements
|
## Acknowledgements
|
||||||
|
|
||||||
This book was originally written in Chinese by [Changkun Ou](https://changkun.de).
|
This book was originally written in Chinese by [Changkun Ou](https://changkun.de).
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void sort(Sortable& c); // c 是一个 Sortable 类型的对象
|
|||||||
|
|
||||||
我们现在来看一个实际的例子。
|
我们现在来看一个实际的例子。
|
||||||
|
|
||||||
TODO:
|
TODO: https://godbolt.org/z/9liFPD
|
||||||
|
|
||||||
## 模块
|
## 模块
|
||||||
|
|
||||||
|
|||||||
18
docker/Dockerfile
Normal file
18
docker/Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
FROM node:latest
|
||||||
|
|
||||||
|
LABEL "maintainer"="Changkun Ou <hi@changkun.us>"
|
||||||
|
LABEL "repository"="https://github.com/changkun/modern-cpp-tutorial"
|
||||||
|
LABEL "homepage"="https://changkun.de/modern-cpp/"
|
||||||
|
|
||||||
|
# FUCKING UNICODE
|
||||||
|
ENV LANG C.UTF-8
|
||||||
|
ENV LC_ALL C.UTF-8
|
||||||
|
|
||||||
|
WORKDIR /modern-cpp-tutorial
|
||||||
|
|
||||||
|
# Node & Npm & Python3 are from node:latest
|
||||||
|
# Install Texlive & Pandoc
|
||||||
|
RUN apt update && \
|
||||||
|
apt install wget texlive-full -y && \
|
||||||
|
wget https://github.com/jgm/pandoc/releases/download/2.7.3/pandoc-2.7.3-1-amd64.deb && \
|
||||||
|
dpkg -i pandoc-2.7.3-1-amd64.deb
|
||||||
@@ -11,21 +11,21 @@ revision:
|
|||||||
|
|
||||||
pdf: markdown
|
pdf: markdown
|
||||||
@echo "Compiling PDF file..."
|
@echo "Compiling PDF file..."
|
||||||
@pandoc -f markdown+smart -s $(filename).md -o $(filename).pdf \
|
pandoc -f markdown+smart -s $(filename).md -o $(filename).pdf \
|
||||||
--title-prefix $(title) \
|
--title-prefix $(title) \
|
||||||
--listings -H meta/cpp-listings.tex \
|
--listings -H meta/cpp-listings.tex \
|
||||||
--template=meta/template.tex \
|
--template=meta/template.tex \
|
||||||
--pdf-engine=`which xelatex`
|
--pdf-engine=`which xelatex`
|
||||||
@echo "Done."
|
@echo "Done."
|
||||||
@rm *.md revision.tex
|
rm *.md revision.tex
|
||||||
|
|
||||||
markdown:
|
markdown:
|
||||||
@echo "Copy markdown files..."
|
@echo "Copy markdown files..."
|
||||||
@cp -r ../../book/en-us/* .
|
cp -r ../../book/en-us/* .
|
||||||
@echo "Aggregating markdown files..."
|
@echo "Aggregating markdown files..."
|
||||||
@python3 aggregator.py
|
python3 aggregator.py
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf revision.tex *.md *.pdf
|
rm -rf revision.tex *.md
|
||||||
|
|
||||||
.PHONY: markdown pdf clean
|
.PHONY: markdown pdf clean
|
||||||
Binary file not shown.
@@ -11,21 +11,21 @@ revision:
|
|||||||
|
|
||||||
pdf: markdown
|
pdf: markdown
|
||||||
@echo "Compiling PDF file..."
|
@echo "Compiling PDF file..."
|
||||||
@pandoc -f markdown+smart -s $(filename).md -o $(filename).pdf \
|
pandoc -f markdown+smart -s $(filename).md -o $(filename).pdf \
|
||||||
--title-prefix $(title) \
|
--title-prefix $(title) \
|
||||||
--listings -H meta/cpp-listings.tex \
|
--listings -H meta/cpp-listings.tex \
|
||||||
--template=meta/template.tex \
|
--template=meta/template.tex \
|
||||||
--pdf-engine=`which xelatex`
|
--pdf-engine=`which xelatex`
|
||||||
@echo "Done."
|
@echo "Done."
|
||||||
@rm *.md revision.tex
|
rm *.md revision.tex
|
||||||
|
|
||||||
markdown:
|
markdown:
|
||||||
@echo "Copy markdown files..."
|
@echo "Copy markdown files..."
|
||||||
@cp -r ../../book/zh-cn/* .
|
cp -r ../../book/zh-cn/* .
|
||||||
@echo "Aggregating markdown files..."
|
@echo "Aggregating markdown files..."
|
||||||
@python3 aggregator.py
|
python3 aggregator.py
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf revision.tex *.md *.pdf
|
rm -rf revision.tex *.md
|
||||||
|
|
||||||
.PHONY: markdown pdf clean
|
.PHONY: markdown pdf clean
|
||||||
@@ -1,19 +1,21 @@
|
|||||||
# !/usr/bin/env python3
|
# !/usr/bin/env python3
|
||||||
# author: changkun<hi@changkun.us>
|
# author: changkun<hi@changkun.us>
|
||||||
|
|
||||||
import os
|
import os, io
|
||||||
|
|
||||||
chapters = ['00-preface.md', '01-intro.md', '02-usability.md', '03-runtime.md', '04-containers.md', '05-pointers.md', '06-regex.md', '07-thread.md', '08-filesystem.md', '09-others.md', '10-cpp20.md', 'appendix1.md', 'appendix2.md']
|
chapters = ['00-preface.md', '01-intro.md', '02-usability.md', '03-runtime.md', '04-containers.md', '05-pointers.md', '06-regex.md', '07-thread.md', '08-filesystem.md', '09-others.md', '10-cpp20.md', 'appendix1.md', 'appendix2.md']
|
||||||
|
|
||||||
ignores = ['TOC', '返回目录', '许可', 'license']
|
ignores = ['TOC', '返回目录', '许可', 'license']
|
||||||
|
|
||||||
with open('modern-cpp-tutorial.md', 'w') as outfile:
|
head = """---
|
||||||
outfile.write("""---
|
|
||||||
title: "高速上手 C++11/14/17/20"
|
title: "高速上手 C++11/14/17/20"
|
||||||
author: 欧长坤 <hi@changkun.us>
|
author: 欧长坤 <hi@changkun.us>
|
||||||
copyright: cc-by-nc-nd 4.0
|
copyright: cc-by-nc-nd 4.0
|
||||||
---
|
---
|
||||||
""")
|
"""
|
||||||
|
|
||||||
|
with io.open('modern-cpp-tutorial.md', 'w', encoding='utf8') as outfile:
|
||||||
|
outfile.write(head)
|
||||||
for chapter in chapters:
|
for chapter in chapters:
|
||||||
if os.path.isfile(chapter):
|
if os.path.isfile(chapter):
|
||||||
with open(chapter) as ch:
|
with open(chapter) as ch:
|
||||||
|
|||||||
Binary file not shown.
@@ -11,19 +11,17 @@ all: clean
|
|||||||
cp -r ../assets/figures ./src/modern-cpp/assets/figures
|
cp -r ../assets/figures ./src/modern-cpp/assets/figures
|
||||||
cp -r ../exercises ./src/modern-cpp/
|
cp -r ../exercises ./src/modern-cpp/
|
||||||
cp -r ../code ./src/modern-cpp/
|
cp -r ../code ./src/modern-cpp/
|
||||||
hexo generate
|
npx hexo generate
|
||||||
mv public/index.html public/modern-cpp/index.html
|
mv public/index.html public/modern-cpp/index.html
|
||||||
s: all
|
s: all
|
||||||
node_modules/serve/bin/serve.js ./public
|
node_modules/serve/bin/serve.js ./public
|
||||||
clean:
|
clean:
|
||||||
rm -rf ./src/modern-cpp/assets/cover-2nd.png
|
rm -rf ./src/modern-cpp/assets/cover-2nd.png \
|
||||||
rm -rf ./src/modern-cpp/assets/figures
|
./src/modern-cpp/assets/figures \
|
||||||
rm -rf public db.json src/modern-cpp/zh-cn
|
./src/modern-cpp/assets/alipay.jpg \
|
||||||
rm -rf public db.json src/modern-cpp/en-us
|
./src/modern-cpp/assets/wechat.jpg \
|
||||||
rm -rf ./src/modern-cpp/assets/alipay.jpg
|
./src/modern-cpp/about/donate.md \
|
||||||
rm -rf ./src/modern-cpp/assets/wechat.jpg
|
./src/modern-cpp/about/community.md \
|
||||||
rm -rf ./src/modern-cpp/about/donate.md
|
./src/modern-cpp/code \
|
||||||
rm -rf ./src/modern-cpp/about/community.md
|
./src/modern-cpp/exercises \
|
||||||
rm -rf ./src/modern-cpp/code
|
public db.json src/modern-cpp/zh-cn src/modern-cpp/en-us
|
||||||
rm -rf ./src/modern-cpp/exercises
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user