generated from Serial-ATA/sscrt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
executable file
·115 lines (80 loc) · 3.71 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env just --justfile
# -----------------------------------------------------------------------------
# PROJECTS:
# -----------------------------------------------------------------------------
# TODO
GENERATED_DIR := justfile_directory() + "/generated"
GENERATORS_DIR := justfile_directory() + "/generators"
ASM_SPECS_DIR := GENERATORS_DIR + "/asm_specs"
# -----------------------------------------------------------------------------
# SUBMODULES:
# -----------------------------------------------------------------------------
INTEL_XED_PATH := ASM_SPECS_DIR + "/x86/xed"
# -----------------------------------------------------------------------------
# PYTHON VENV CONFIG:
# -----------------------------------------------------------------------------
PYTHON_VENV_DEPENDENCIES := "pip wheel requests pip-tools"
PYTHON_VENV_LOCATION := justfile_directory() + "/generators/asm_specs/.venv"
PYTHON_VENV_BIN := PYTHON_VENV_LOCATION + if os_family() == "windows" { "/Scripts" } else { "/bin" }
VENV_PYTHON_EXE := PYTHON_VENV_BIN + if os_family() == "windows" { "/python.exe" } else { "/python3" }
# Used in `clean`
VENV_UNINSTALL_LIST := PYTHON_VENV_LOCATION + "/to-uninstall.txt"
SYSTEM_PYTHON_DEFAULT := if os() == "windows" { "python" } else { "python3" }
SYSTEM_PYTHON_EXE := env_var_or_default("PYTHON", SYSTEM_PYTHON_DEFAULT)
# -----------------------------------------------------------------------------
# OTHER:
# -----------------------------------------------------------------------------
DEV_NULL := if os() == "windows" { "nul" } else { "/dev/null" }
# -----------------------------------------------------------------------------
# ASM:
# -----------------------------------------------------------------------------
ASM_GENERATED_DIR := GENERATED_DIR + "/asm_specs"
# x86/XED
X86_GENERATED_DIR := ASM_GENERATED_DIR + "/x86"
X86_SPECS_DIR := ASM_SPECS_DIR + "/x86"
X86_GENERATOR_PATH := X86_SPECS_DIR + "/x86.py"
INTEL_XED_MFILE_PATH := INTEL_XED_PATH + "/mfile.py"
INTEL_XED_OPTIONS := "--build-dir=" + X86_GENERATED_DIR + " --install-dir=" + DEV_NULL + " just-prep"
# -----------------------------------------------------------------------------
# TARGETS:
# -----------------------------------------------------------------------------
default: debug
# Initialize Git submodules
submodules:
git submodule update --init
# Cleans any previous builds and Python venvs
clean:
-'{{ VENV_PYTHON_EXE }}' -m pip freeze > {{ VENV_UNINSTALL_LIST }}
-'{{ VENV_PYTHON_EXE }}' -m pip uninstall -y -r {{ VENV_UNINSTALL_LIST }}
-rm {{ VENV_UNINSTALL_LIST }}
# Clean Intel XED
'{{ VENV_PYTHON_EXE }}' '{{ INTEL_XED_MFILE_PATH }}' -c {{ INTEL_XED_OPTIONS }}
# TODO: clean other projects
# Setup the python venv
setup_python:
if test ! -e '{{ PYTHON_VENV_LOCATION }}'; then '{{ SYSTEM_PYTHON_EXE }}' -m venv {{ PYTHON_VENV_LOCATION }}; fi
'{{ VENV_PYTHON_EXE }}' -m pip install --upgrade {{ PYTHON_VENV_DEPENDENCIES }}
# Build Intel XED x86 decoder
build_xed: submodules setup_python
'{{ VENV_PYTHON_EXE }}' '{{ INTEL_XED_MFILE_PATH }}' --no-encoder --limit-strings {{ INTEL_XED_OPTIONS }}
# Run x86.py to generate instruction tables
run_x86: build_xed
#!/usr/bin/env bash
export PYTHONPATH="$PYTHONPATH:{{ ASM_SPECS_DIR }}"
'{{ VENV_PYTHON_EXE }}' '{{ X86_GENERATOR_PATH }}'
# Parse the various instruction sources, used by the assembler
asm: run_x86
# Build the assembler project
assembler: asm
cd assembler &&\
cargo build
# Build the entire project in debug
debug: asm
cargo build
# Build the entire project in release
release: asm
cargo build --release
# Build and run the java binary with the provided arguments
java +ARGS: debug
cd tools/java &&\
cargo run -- {{ ARGS }}