1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 02:25:28 +03:00

teach build.rs to init submodules if needed

Forgetting to update the submodules is a commonly reported build
issue with an obscure error message:

```
CMake Error: The source directory "/home/USER/wezterm/target/debug/build/freetype-430fe24cb64c561c/out/zlib-src/zlib" does not appear to contain CMakeLists.txt.
```

this teaches the build.rs machinery to run the submodule update
if it looks like it is needed.
This commit is contained in:
Wez Furlong 2019-10-29 08:17:10 -07:00
parent d0f2204bdd
commit 61b27c8089
6 changed files with 28 additions and 8 deletions

View File

@ -20,8 +20,6 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Update submodules
run: git submodule update --init
- name: Install System Deps - name: Install System Deps
run: sudo ./get-deps run: sudo ./get-deps
- name: Install Rust - name: Install Rust

View File

@ -20,8 +20,6 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Update submodules
run: git submodule update --init
- name: Install Rust - name: Install Rust
shell: cmd shell: cmd
run: | run: |

View File

@ -18,8 +18,6 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Update submodules
run: git submodule update --init
- name: Install System Deps - name: Install System Deps
run: sudo ./get-deps run: sudo ./get-deps
- name: Install Rust - name: Install Rust

View File

@ -18,8 +18,6 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Update submodules
run: git submodule update --init
- name: Install Rust - name: Install Rust
shell: cmd shell: cmd
run: | run: |

View File

@ -4,6 +4,10 @@ use std::env;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
fn zlib() { fn zlib() {
if !Path::new("zlib/.git").exists() {
git_submodule_update();
}
// The out-of-source build for zlib unfortunately modifies some of // The out-of-source build for zlib unfortunately modifies some of
// the sources, leaving the repo with a dirty status. Let's take // the sources, leaving the repo with a dirty status. Let's take
// a copy of the sources so that we don't trigger this. // a copy of the sources so that we don't trigger this.
@ -49,6 +53,10 @@ fn libpath(p: &Path, name: &str) -> PathBuf {
} }
fn libpng() { fn libpng() {
if !Path::new("libpng/.git").exists() {
git_submodule_update();
}
let mut config = Config::new("libpng"); let mut config = Config::new("libpng");
let dst = config.profile("Release").build(); let dst = config.profile("Release").build();
emit_libdirs(&dst); emit_libdirs(&dst);
@ -60,6 +68,10 @@ fn libpng() {
} }
fn freetype() { fn freetype() {
if !Path::new("freetype2/.git").exists() {
git_submodule_update();
}
let mut config = Config::new("freetype2"); let mut config = Config::new("freetype2");
let dst = config let dst = config
.define("FT_WITH_PNG", "ON") .define("FT_WITH_PNG", "ON")
@ -73,6 +85,12 @@ fn freetype() {
println!("cargo:lib={}", libpath(&dst, "freetype").display()); println!("cargo:lib={}", libpath(&dst, "freetype").display());
} }
fn git_submodule_update() {
let _ = std::process::Command::new("git")
.args(&["submodule", "update", "--init"])
.status();
}
fn main() { fn main() {
zlib(); zlib();
libpng(); libpng();

View File

@ -3,6 +3,10 @@ use std::env;
use std::path::Path; use std::path::Path;
fn harfbuzz() { fn harfbuzz() {
if !Path::new("harfbuzz/.git").exists() {
git_submodule_update();
}
let mut config = Config::new("harfbuzz"); let mut config = Config::new("harfbuzz");
for (key, value) in std::env::vars() { for (key, value) in std::env::vars() {
println!("{}: {}", key, value); println!("{}: {}", key, value);
@ -44,6 +48,12 @@ fn emit_libdirs(p: &Path) {
} }
} }
fn git_submodule_update() {
let _ = std::process::Command::new("git")
.args(&["submodule", "update", "--init"])
.status();
}
fn main() { fn main() {
harfbuzz(); harfbuzz();
let out_dir = env::var("OUT_DIR").unwrap(); let out_dir = env::var("OUT_DIR").unwrap();