Skip to content

Commit

Permalink
Make cargo build work from a clean checkout; relocate tuari frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
DrChat committed Feb 3, 2024
1 parent 80a310a commit e14c9eb
Show file tree
Hide file tree
Showing 42 changed files with 376 additions and 150 deletions.
459 changes: 344 additions & 115 deletions Cargo.lock

Large diffs are not rendered by default.

25 changes: 11 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
[workspace]
resolver = "2"
members = [
"crates/client",
"crates/entities",
"crates/migrations",
"crates/shared",
"crates/spyglass",
"crates/tauri",
"crates/ui-components",
"crates/*",

# This requires a .env file to be set up.
"apps/web",

# Public published crates
"crates/spyglass-plugin",
"crates/spyglass-lens",
"crates/spyglass-rpc",
"crates/spyglass-searcher",
"crates/spyglass-processor"
# This requires `tauri build` and depends on a few other binaries, so it is not part of the workspace.
"apps/tauri"
]

# Exclude the crates under `apps/` because they require special steps to be completed before
# they can be built.
default-members = [
"crates/*"
]

[profile.release]
codegen-units = 1
# codegen-units = 1
lto = true
incremental = false
opt-level = "s"
Expand Down
30 changes: 15 additions & 15 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ skip_git_env_info = true

[env]
SPYGLASS_CLIENT_DIR = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/crates/client"
TAURI_DEV_CONFIG = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/crates/tauri/tauri.dev.conf.json"
TAURI_DEV_CONFIG = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/apps/tauri/tauri.dev.conf.json"
EXECUTABLE_EXTENSION = { source = "${CARGO_MAKE_RUST_TARGET_OS}", mapping = { "windows" = ".exe" } }
TARGET_FOLDER = { default_value = "debug", mapping = { "release" = "release" }, source = "${PROFILE}" }

Expand Down Expand Up @@ -38,16 +38,16 @@ dependencies = [
"setup-tauri",
"download-whisper",
"prepare-env-file",
"build-backend",
"build-crates",
"copy-backend-binaries",
"copy-pdftotext-binaries",
]

[tasks.build]
command = "cargo"
args = ["tauri", "build", "--config", "${TAURI_DEV_CONFIG}"]
args = ["tauri", "build", "--config", "${TAURI_DEV_CONFIG}", "--release"]
dependencies = [
"build-backend",
"build-crates",
"copy-backend-binaries",
"copy-pdftotext-binaries"
]
Expand All @@ -56,8 +56,8 @@ dependencies = [
# Private Helpers #
###################

[tasks.build-backend]
args = ["build", "-p", "spyglass", "--profile", "${CARGO_MAKE_CARGO_PROFILE}"]
[tasks.build-crates]
args = ["build", "--profile", "${CARGO_MAKE_CARGO_PROFILE}"]
command = "cargo"
private = true

Expand All @@ -71,30 +71,30 @@ cp "${SPYGLASS_BACKEND_DEBUG_BIN}" "${SPYGLASS_BACKEND_DEBUG_TAURI_BIN}"
script_runner = "@shell"

[tasks.set-platform-specific-variables]
env = { SPYGLASS_BACKEND_BIN = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${TARGET_FOLDER}}/spyglass", SPYGLASS_BACKEND_DEBUG_BIN = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${TARGET_FOLDER}/spyglass-debug", SPYGLASS_TAURI_DIR = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/crates/tauri/binaries", SPYGLASS_BACKEND_TAURI_BIN = "${SPYGLASS_TAURI_DIR}/spyglass-server-${CARGO_MAKE_RUST_TARGET_TRIPLE}", SPYGLASS_BACKEND_DEBUG_TAURI_BIN = "${SPYGLASS_TAURI_DIR}/spyglass-debug-${CARGO_MAKE_RUST_TARGET_TRIPLE}" }
env = { SPYGLASS_BACKEND_BIN = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${TARGET_FOLDER}}/spyglass", SPYGLASS_BACKEND_DEBUG_BIN = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${TARGET_FOLDER}/spyglass-debug", SPYGLASS_TAURI_DIR = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/apps/tauri/binaries", SPYGLASS_BACKEND_TAURI_BIN = "${SPYGLASS_TAURI_DIR}/spyglass-server-${CARGO_MAKE_RUST_TARGET_TRIPLE}", SPYGLASS_BACKEND_DEBUG_TAURI_BIN = "${SPYGLASS_TAURI_DIR}/spyglass-debug-${CARGO_MAKE_RUST_TARGET_TRIPLE}" }
private = true

[tasks.set-platform-specific-variables.windows]
# Only needed for these kinds of path-building, composite environment variables.
env = { SPYGLASS_BACKEND_BIN = '''${CARGO_MAKE_CRATE_TARGET_DIRECTORY}\${TARGET_FOLDER}\spyglass.exe''', SPYGLASS_BACKEND_DEBUG_BIN = '''${CARGO_MAKE_CRATE_TARGET_DIRECTORY}\${TARGET_FOLDER}\spyglass-debug.exe''', SPYGLASS_TAURI_DIR = '''${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}\crates\tauri\binaries''', SPYGLASS_BACKEND_TAURI_BIN = '''${SPYGLASS_TAURI_DIR}\spyglass-server-${CARGO_MAKE_RUST_TARGET_TRIPLE}.exe''', SPYGLASS_BACKEND_DEBUG_TAURI_BIN = '''${SPYGLASS_TAURI_DIR}\spyglass-debug-${CARGO_MAKE_RUST_TARGET_TRIPLE}.exe''' }
env = { SPYGLASS_BACKEND_BIN = '''${CARGO_MAKE_CRATE_TARGET_DIRECTORY}\${TARGET_FOLDER}\spyglass.exe''', SPYGLASS_BACKEND_DEBUG_BIN = '''${CARGO_MAKE_CRATE_TARGET_DIRECTORY}\${TARGET_FOLDER}\spyglass-debug.exe''', SPYGLASS_TAURI_DIR = '''${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}\apps\tauri\binaries''', SPYGLASS_BACKEND_TAURI_BIN = '''${SPYGLASS_TAURI_DIR}\spyglass-server-${CARGO_MAKE_RUST_TARGET_TRIPLE}.exe''', SPYGLASS_BACKEND_DEBUG_TAURI_BIN = '''${SPYGLASS_TAURI_DIR}\spyglass-debug-${CARGO_MAKE_RUST_TARGET_TRIPLE}.exe''' }
private = true

[tasks.copy-pdftotext-binaries]
private = true
script_runner = "@shell"
[tasks.copy-pdftotext-binaries.linux]
script = '''cp utils/linux/pdftotext crates/tauri/binaries/pdftotext-${CARGO_MAKE_RUST_TARGET_TRIPLE}'''
script = '''cp utils/linux/pdftotext apps/tauri/binaries/pdftotext-${CARGO_MAKE_RUST_TARGET_TRIPLE}'''
[tasks.copy-pdftotext-binaries.mac]
script = '''cp utils/mac/pdftotext crates/tauri/binaries/pdftotext-${CARGO_MAKE_RUST_TARGET_TRIPLE}'''
script = '''cp utils/mac/pdftotext apps/tauri/binaries/pdftotext-${CARGO_MAKE_RUST_TARGET_TRIPLE}'''
[tasks.copy-pdftotext-binaries.windows]
script = '''cp utils/win/pdftotext.exe crates/tauri/binaries/pdftotext-${CARGO_MAKE_RUST_TARGET_TRIPLE}.exe'''
script = '''cp utils/win/pdftotext.exe apps/tauri/binaries/pdftotext-${CARGO_MAKE_RUST_TARGET_TRIPLE}.exe'''

[tasks.create-binary-directory]
private = true
script = '''mkdir -p crates/tauri/binaries'''
script = '''mkdir -p apps/tauri/binaries'''
script_runner = "@shell"
[tasks.create-binary-directory.windows]
script = '''IF NOT EXIST .\crates\tauri\binaries mkdir .\crates\tauri\binaries'''
script = '''IF NOT EXIST .\apps\tauri\binaries mkdir .\apps\tauri\binaries'''

[tasks.download-whisper]
private = true
Expand Down Expand Up @@ -151,11 +151,11 @@ dependencies = [
"install-wasm32-wasi",
]
private = true
script = '''mkdir -p ./crates/tauri/dist'''
script = '''mkdir -p ./apps/tauri/dist'''
script_runner = "@shell"

[tasks.setup-tauri.windows]
script = '''IF NOT EXIST .\crates\tauri\dist mkdir .\crates\tauri\dist'''
script = '''IF NOT EXIST .\apps\tauri\dist mkdir .\apps\tauri\dist'''

[tasks.prepare-env-file]
private = true
Expand Down
6 changes: 3 additions & 3 deletions crates/tauri/Cargo.toml → apps/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ auto-launch = "0.4.0"
diff-struct = "0.5.1"
jsonrpsee = { version = "0.16.2", features = ["ws-client"] }
log = "0.4"
migration = { path = "../migrations" }
migration = { path = "../../crates/migrations" }
num-format = "0.4"
open = "3"
reqwest = { version = "0.11", features = ["json"] }
Expand All @@ -29,8 +29,8 @@ sentry = "0.30.0"
sentry-tracing = "0.30.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
shared = { path = "../shared", features = ["metrics"] }
spyglass-rpc = { path = "../spyglass-rpc" }
shared = { path = "../../crates/shared", features = ["metrics"] }
spyglass-rpc = { path = "../../crates/spyglass-rpc" }
strum = "0.24"
strum_macros = "0.24"
tauri = { version = "1.2.4", features = ["api-all", "clipboard", "devtools", "macos-private-api", "notification", "system-tray", "updater"] }
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions crates/tauri/tauri.conf.json → apps/tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"version": "23.11.1"
},
"build": {
"distDir": "../client/dist",
"distDir": "../../crates/client/dist",
"devPath": "http://localhost:8080",
"beforeDevCommand": "cd client && trunk serve",
"beforeBuildCommand": "cd client && trunk build",
"beforeDevCommand": "cd ../crates/client && trunk serve",
"beforeBuildCommand": "cd ../crates/client && trunk build",
"withGlobalTauri": true
},
"tauri": {
Expand Down
File renamed without changes.
Binary file not shown.

0 comments on commit e14c9eb

Please sign in to comment.