Skip to content

Enable debug for all release, attach console for windows.[CPP-380][CPP-384] #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,24 @@ jobs:
cd ..
echo "${OS_NAME}.zip" >bench-archive.filename;
echo "BENCH_ARCHIVE=$(cat bench-archive.filename)" >>$GITHUB_ENV

RELEASE_ARCHIVE=$(find . -maxdepth 1 -iname "*.tar.xz")
RELEASE_ARCHIVE=$(find . -maxdepth 1 -iname "*.tar.xz" ! -iname "*-debug*")
DEBUG_ARCHIVE=$(find . -maxdepth 1 -iname "*-debug.tar.xz")
echo $RELEASE_ARCHIVE >release-archive.filename
echo "RELEASE_ARCHIVE=$(cat release-archive.filename)" >>$GITHUB_ENV
echo $DEBUG_ARCHIVE >debug-archive.filename
echo "DEBUG_ARCHIVE=$(cat debug-archive.filename)" >>$GITHUB_ENV
- uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-artifacts
path: |
${{ env.RELEASE_ARCHIVE }}
release-archive.filename
- uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-artifacts-debug
path: |
${{ env.DEBUG_ARCHIVE }}
debug-archive.filename
- uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-artifacts-bench
Expand Down Expand Up @@ -374,30 +382,30 @@ jobs:
run: |
cd console
if [ "$RUNNER_OS" == "Windows" ]; then
python ./bench_runner.py --frontend_cpu --executable="${GITHUB_WORKSPACE}/console/Scripts/swiftnav-console.exe"
python ./bench_runner.py --frontend_cpu --executable="${GITHUB_WORKSPACE}/console/Scripts/console.exe"
elif [ "$RUNNER_OS" == "macOS" ]; then
chmod +x "${GITHUB_WORKSPACE}/console/bin/swiftnav-console"
chmod +x "${GITHUB_WORKSPACE}/console/bin/console"
chmod +x "${GITHUB_WORKSPACE}/console/bin/python3"
python ./bench_runner.py --frontend_cpu --executable="${GITHUB_WORKSPACE}/console/bin/swiftnav-console"
python ./bench_runner.py --frontend_cpu --executable="${GITHUB_WORKSPACE}/console/bin/console"
elif [ "$RUNNER_OS" == "Linux" ]; then
chmod +x "${GITHUB_WORKSPACE}/console/bin/swiftnav-console"
chmod +x "${GITHUB_WORKSPACE}/console/bin/console"
chmod +x "${GITHUB_WORKSPACE}/console/bin/python3"
python ./bench_runner.py --frontend_cpu --executable="${GITHUB_WORKSPACE}/console/bin/swiftnav-console"
python ./bench_runner.py --frontend_cpu --executable="${GITHUB_WORKSPACE}/console/bin/console"
fi
- name: Run MEM Frontend Benchmark.
shell: bash
run: |
cd console
if [ "$RUNNER_OS" == "Windows" ]; then
python ./bench_runner.py --frontend_mem --executable="${GITHUB_WORKSPACE}/console/Scripts/swiftnav-console.exe"
python ./bench_runner.py --frontend_mem --executable="${GITHUB_WORKSPACE}/console/Scripts/console.exe"
elif [ "$RUNNER_OS" == "macOS" ]; then
chmod +x "${GITHUB_WORKSPACE}/console/bin/swiftnav-console"
chmod +x "${GITHUB_WORKSPACE}/console/bin/console"
chmod +x "${GITHUB_WORKSPACE}/console/bin/python3"
python ./bench_runner.py --frontend_mem --executable="${GITHUB_WORKSPACE}/console/bin/swiftnav-console"
python ./bench_runner.py --frontend_mem --executable="${GITHUB_WORKSPACE}/console/bin/console"
elif [ "$RUNNER_OS" == "Linux" ]; then
chmod +x "${GITHUB_WORKSPACE}/console/bin/swiftnav-console"
chmod +x "${GITHUB_WORKSPACE}/console/bin/console"
chmod +x "${GITHUB_WORKSPACE}/console/bin/python3"
python ./bench_runner.py --frontend_mem --executable="${GITHUB_WORKSPACE}/console/bin/swiftnav-console"
python ./bench_runner.py --frontend_mem --executable="${GITHUB_WORKSPACE}/console/bin/console"
fi


Expand Down
48 changes: 44 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ members = ["console_backend", "entrypoint"]
[profile.release]
lto = true
codegen-units = 1
debug = true
69 changes: 49 additions & 20 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -286,22 +286,23 @@ cd ../../..
exec --fail-on-error ${DIST_PYTHON} ./get-pip.py
'''

[tasks.build-entrypoint]
[tasks.build-console]
command = "cargo"
args = ["build", "--release", "--bin", "entrypoint"]
args = ["build", "--release", "--bin", "console"]

[tasks.build-dist-install-entrypoint]
dependencies = ["build-entrypoint"]
[tasks.build-dist-install-console]
dependencies = ["build-console"]
script_runner = "@duckscript"
script = '''
cp target/release/entrypoint py39-dist/bin/swiftnav-console
exec --fail-on-error strip py39-dist/bin/swiftnav-console
cp target/release/console py39-dist/bin/console
'''

[tasks.build-dist-install-entrypoint.windows]
[tasks.build-dist-install-console.windows]
script = '''
mkdir py39-dist/Scripts
cp target/release/entrypoint.exe py39-dist/Scripts/swiftnav-console.exe
cp target/release/console.exe py39-dist/Scripts/console.exe
cp target/release/console.pdb py39-dist/Scripts/console.pdb
cp target/x86_64-pc-windows-msvc/release/console_backend.pdb py39-dist/Lib/site-packages/console_backend/console_backend.pdb
'''

[tasks.build-dist-install-frontend-wheel]
Expand Down Expand Up @@ -338,7 +339,7 @@ run_task = [
{ name = [
"build-dist-install-frontend-wheel",
"build-dist-install-backend-wheel",
"build-dist-install-entrypoint",
"build-dist-install-console",
"build-dist-copy-resources",
"build-dist-freeze",
] },
Expand All @@ -361,7 +362,7 @@ for name in ${all_folders}
end
end

file_exts = array pyc pyi pdb tcl gif png
file_exts = array pyc pyi tcl gif png
for ext in ${file_exts}
files = glob_array **/*.${ext}
for file in ${files}
Expand All @@ -387,9 +388,11 @@ end

os = os_family
if eq ${os} windows
mv ./Scripts/swiftnav-console.exe .
mv ./Scripts/console.exe .
mv ./Scripts/console.pdb .
rm -r ./Scripts
mv ./swiftnav-console.exe ./Scripts/
mv ./console.exe ./Scripts/
mv ./console.pdb ./Scripts/

rm -r ./include
rm -r ./tcl
Expand All @@ -406,10 +409,10 @@ if eq ${os} windows
rm ${bin}
end
else
mv ./bin/swiftnav-console .
mv ./bin/console .
mv ./bin/python3 .
rm -r ./bin
mv ./swiftnav-console ./bin/
mv ./console ./bin/
mv ./python3 ./bin/

rm -r ./share
Expand Down Expand Up @@ -455,6 +458,29 @@ for file in ${files}
end
'''

[tasks.strip-dist-pdb.windows]
cwd = "py39-dist"
script_runner = "@duckscript"
script = '''
files = glob_array **/*.pdb
for file in ${files}
rm ${file}
end
'''

[tasks.strip-dist]
script_runner = "@duckscript"
script = '''
exec --fail-on-error strip py39-dist/bin/console
'''

[tasks.strip-dist.windows]
script_runner = "@duckscript"
script = '''
cm_run_task strip-dist-pdb
exec --fail-on-error strip.exe py39-dist/Scripts/console.exe
'''

[tasks.compress-dist]
env = { ARCHIVE_NAME = "console_pp" }
script_runner = "@duckscript"
Expand All @@ -464,8 +490,11 @@ date = trim ${output.stdout}
output = exec --fail-on-error git describe --always --tags --dirty
version = trim ${output.stdout}
output_name = set "${ARCHIVE_NAME}-${version}-${BUILD_TRIPLET}-${date}"
exec --fail-on-error tar -C "py39-dist" -cvf "${output_name}-debug.tar" .
cm_run_task strip-dist
exec --fail-on-error tar -C "py39-dist" -cvf "${output_name}.tar" .
exec --fail-on-error rm -f "${output_name}.tar.xz"
exec --fail-on-error xz -T 0 -e -9 "${output_name}-debug.tar"
exec --fail-on-error xz -T 0 -e -9 "${output_name}.tar"
'''

Expand Down Expand Up @@ -643,42 +672,42 @@ args = ["utils/bench_runner.py", "--disk_usage"]
script_runner = "@shell"
script = '''
echo 'This is only used to validate locally.'
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_cpu --executable=${WORKSPACE}/py39-dist/bin/swiftnav-console
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_cpu --executable=${WORKSPACE}/py39-dist/bin/console
'''

[tasks.frontend-cpu-bench.windows]
script_runner = "@shell"
script = '''
echo 'This is only used to validate locally.'
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_cpu --executable=${WORKSPACE}/py39-dist/Scripts/swiftnav-console.exe
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_cpu --executable=${WORKSPACE}/py39-dist/Scripts/console.exe
'''

[tasks.frontend-cpu-bench.mac]
script_runner = "@shell"
script = '''
echo 'This is only used to validate locally.'
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_cpu --executable=${WORKSPACE}/py39-dist/bin/swiftnav-console
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_cpu --executable=${WORKSPACE}/py39-dist/bin/console
'''

[tasks.frontend-mem-bench.linux]
script_runner = "@shell"
script = '''
echo 'This is only used to validate locally.'
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_mem --executable=${WORKSPACE}/py39-dist/bin/swiftnav-console
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_mem --executable=${WORKSPACE}/py39-dist/bin/console
'''

[tasks.frontend-mem-bench.windows]
script_runner = "@shell"
script = '''
echo 'This is only used to validate locally.'
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_mem --executable=${WORKSPACE}/py39-dist/Scripts/swiftnav-console.exe
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_mem --executable=${WORKSPACE}/py39-dist/Scripts/console.exe
'''

[tasks.frontend-mem-bench.mac]
script_runner = "@shell"
script = '''
echo 'This is only used to validate locally.'
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_mem --executable=${WORKSPACE}/py39-dist/bin/swiftnav-console
cd console_backend/tests && python ../../utils/bench_runner.py --frontend_mem --executable=${WORKSPACE}/py39-dist/bin/console
'''

[tasks.newline-terminator]
Expand Down
6 changes: 6 additions & 0 deletions console_backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ mimalloc = { version = "0.1", default-features = false }
[target.'cfg(any(target_os = "macos", target_os = "windows"))'.dependencies]
serialport = "4.0.1"

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = ">=0.24", features = [
"Win32_System_Console",
"Win32_Foundation",
] }

[dev-dependencies]
logtest = "2.0.0"
serial_test = "0.5.1"
Expand Down
4 changes: 2 additions & 2 deletions console_backend/src/cli_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ impl CliOptions {
|| arg.ends_with("python.exe")
|| arg.ends_with("pythonw.exe"))
&& (n_arg.ends_with(".py")
|| n_arg.ends_with("swiftnav-console.exe")
|| n_arg.ends_with("swiftnav-console"))
|| n_arg.ends_with("console.exe")
|| n_arg.ends_with("console"))
{
continue;
}
Expand Down
11 changes: 11 additions & 0 deletions console_backend/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ use crate::server_recv_thread::server_recv_thread;
use crate::shared_state::SharedState;
use crate::utils::{refresh_connection_frontend, refresh_loggingbar};

pub(crate) fn attach_console() {
#[cfg(target_os = "windows")]
{
use windows::Win32::System::Console::AttachConsole;
unsafe {
AttachConsole(u32::MAX).as_bool();
}
}
}

/// The backend server
#[pyclass]
struct Server {
Expand Down Expand Up @@ -101,6 +111,7 @@ impl Server {

#[text_signature = "($self, /)"]
pub fn start(&mut self) -> PyResult<ServerEndpoint> {
attach_console();
let (client_send, client_recv) = channel::unbounded();
let (server_send, server_recv) = channel::unbounded();
let client_send = ChannelSender::boxed(client_send);
Expand Down
Binary file modified docs/imgs/app-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions entrypoint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
authors = ["Swift Navigation <[email protected]>"]
name = "entrypoint"
name = "console"
version = "0.1.0"
description = "Starts the console with the correct python installation"
edition = "2018"
Expand All @@ -9,6 +9,12 @@ edition = "2018"
[dependencies]

[[bin]]
name = "entrypoint"
name = "console"
path = "src/main.rs"
bench = false

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = ">=0.24", features = [
"Win32_System_Console",
"Win32_Foundation",
] }
Loading