2016-06-29 23:56:12 -04:00
|
|
|
// Copyright 2016 Joe Wilm, The Alacritty Project Contributors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2018-10-16 13:02:52 -04:00
|
|
|
#[cfg(windows)]
|
|
|
|
extern crate embed_resource;
|
|
|
|
#[cfg(windows)]
|
Display errors and warnings
To make sure that all error and information reporting to the user is
unified, all instances of `print!`, `eprint!`, `println!` and
`eprintln!` have been removed and replaced by logging.
When `RUST_LOG` is not specified, the default Alacritty logger now also
prints to both the stderr and a log file. The log file is only created
when a message is written to it and its name is printed to stdout the
first time it is used.
Whenever a warning or an error has been written to the log file/stderr,
a message is now displayed in Alacritty which points to the log file
where the full error is documented.
The message is cleared whenever the screen is cleared using either the
`clear` command or the `Ctrl+L` key binding.
To make sure that log files created by root don't prevent normal users
from interacting with them, the Alacritty log file is `/tmp/Alacritty-$PID.log`.
Since it's still possible that the log file can't be created, the UI
error/warning message now informs the user if the message was only
written to stderr. The reason why it couldn't be created is then printed
to stderr.
To make sure the deletion of the log file at runtime doesn't create any
issues, the file is re-created if a write is attempted without the file
being present.
To help with debugging Alacritty issues, a timestamp and the error
level are printed in all log messages.
All log messages now follow this format:
[YYYY-MM-DD HH:MM] [LEVEL] Message
Since it's not unusual to spawn a lot of different terminal emulators
without restarting, Alacritty can create a ton of different log files.
To combat this problem, logfiles are removed by default after
Alacritty has been closed. If the user wants to persist the log of a
single session, the `--persistent_logging` option can be used. For
persisting all log files, the `persistent_logging` option can be set in
the configuration file
2018-11-17 09:39:13 -05:00
|
|
|
extern crate tempfile;
|
2018-10-16 13:02:52 -04:00
|
|
|
#[cfg(windows)]
|
|
|
|
extern crate reqwest;
|
|
|
|
#[cfg(windows)]
|
|
|
|
extern crate zip;
|
|
|
|
|
2016-05-21 00:36:28 -04:00
|
|
|
extern crate gl_generator;
|
|
|
|
|
2018-10-16 13:02:52 -04:00
|
|
|
use gl_generator::{Api, Fallbacks, GlobalGenerator, Profile, Registry};
|
|
|
|
|
2016-05-21 00:36:28 -04:00
|
|
|
use std::env;
|
|
|
|
use std::fs::File;
|
|
|
|
use std::path::Path;
|
|
|
|
|
2018-10-16 13:02:52 -04:00
|
|
|
#[cfg(windows)]
|
|
|
|
use std::io;
|
|
|
|
#[cfg(windows)]
|
|
|
|
use std::fs::OpenOptions;
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
2018-10-17 00:52:28 -04:00
|
|
|
const WINPTY_PACKAGE_URL: &str = "https://github.com/rprichard/winpty/releases/download/0.4.3/winpty-0.4.3-msvc2015.zip";
|
2018-10-16 13:02:52 -04:00
|
|
|
|
2016-05-21 00:36:28 -04:00
|
|
|
fn main() {
|
|
|
|
let dest = env::var("OUT_DIR").unwrap();
|
|
|
|
let mut file = File::create(&Path::new(&dest).join("gl_bindings.rs")).unwrap();
|
|
|
|
|
2018-10-16 13:02:52 -04:00
|
|
|
Registry::new(
|
|
|
|
Api::Gl,
|
|
|
|
(4, 5),
|
|
|
|
Profile::Core,
|
|
|
|
Fallbacks::All,
|
|
|
|
["GL_ARB_blend_func_extended"],
|
|
|
|
).write_bindings(GlobalGenerator, &mut file)
|
2016-05-21 00:36:28 -04:00
|
|
|
.unwrap();
|
2018-10-16 13:02:52 -04:00
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
{
|
|
|
|
embed_resource::compile("assets/windows/windows.rc");
|
|
|
|
|
|
|
|
// Path is relative to target/{profile}/build/alacritty-HASH/out
|
|
|
|
let file = Path::new(&env::var("OUT_DIR").unwrap()).join("../../../winpty-agent.exe");
|
|
|
|
if !file.exists() {
|
|
|
|
aquire_winpty_agent(&file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(windows)]
|
|
|
|
fn aquire_winpty_agent(out_path: &Path) {
|
Display errors and warnings
To make sure that all error and information reporting to the user is
unified, all instances of `print!`, `eprint!`, `println!` and
`eprintln!` have been removed and replaced by logging.
When `RUST_LOG` is not specified, the default Alacritty logger now also
prints to both the stderr and a log file. The log file is only created
when a message is written to it and its name is printed to stdout the
first time it is used.
Whenever a warning or an error has been written to the log file/stderr,
a message is now displayed in Alacritty which points to the log file
where the full error is documented.
The message is cleared whenever the screen is cleared using either the
`clear` command or the `Ctrl+L` key binding.
To make sure that log files created by root don't prevent normal users
from interacting with them, the Alacritty log file is `/tmp/Alacritty-$PID.log`.
Since it's still possible that the log file can't be created, the UI
error/warning message now informs the user if the message was only
written to stderr. The reason why it couldn't be created is then printed
to stderr.
To make sure the deletion of the log file at runtime doesn't create any
issues, the file is re-created if a write is attempted without the file
being present.
To help with debugging Alacritty issues, a timestamp and the error
level are printed in all log messages.
All log messages now follow this format:
[YYYY-MM-DD HH:MM] [LEVEL] Message
Since it's not unusual to spawn a lot of different terminal emulators
without restarting, Alacritty can create a ton of different log files.
To combat this problem, logfiles are removed by default after
Alacritty has been closed. If the user wants to persist the log of a
single session, the `--persistent_logging` option can be used. For
persisting all log files, the `persistent_logging` option can be set in
the configuration file
2018-11-17 09:39:13 -05:00
|
|
|
let tmp_dir = tempfile::Builder::new().prefix("alacritty_build").tempdir().unwrap();
|
2018-10-17 00:52:28 -04:00
|
|
|
|
2018-10-16 13:02:52 -04:00
|
|
|
let mut response = reqwest::get(WINPTY_PACKAGE_URL).unwrap();
|
|
|
|
let mut file = OpenOptions::new()
|
|
|
|
.read(true)
|
|
|
|
.write(true)
|
|
|
|
.create(true)
|
|
|
|
.open(tmp_dir.path().join("winpty_package.zip")).unwrap();
|
|
|
|
|
|
|
|
io::copy(&mut response, &mut file).unwrap();
|
|
|
|
|
|
|
|
let mut archive = zip::ZipArchive::new(file).unwrap();
|
|
|
|
|
|
|
|
let target = match env::var("TARGET").unwrap().split("-").next().unwrap() {
|
2018-10-17 00:52:28 -04:00
|
|
|
"x86_64" => "x64",
|
|
|
|
"i386" => "ia32",
|
2018-10-16 13:02:52 -04:00
|
|
|
_ => panic!("architecture has no winpty binary")
|
|
|
|
};
|
|
|
|
|
2018-10-17 00:52:28 -04:00
|
|
|
let mut winpty_agent = archive.by_name(&format!("{}/bin/winpty-agent.exe", target)).unwrap();
|
2018-10-16 13:02:52 -04:00
|
|
|
|
|
|
|
io::copy(&mut winpty_agent, &mut File::create(out_path).unwrap()).unwrap();
|
2016-05-21 00:36:28 -04:00
|
|
|
}
|