Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ moves back that amount of space
* Iris now handles horizontal scrolling when a line is longer than the screen
* Allow for specifying file to save to from command bar
* `e` key now moves cursor to end of the current word
* Add the version of the `rawterm` library used to the `--version` command
when making a release build

* Resolved issue with iris crashing after opening an existing file with 0 bytes
* Resolved issue where filename isn't centered in the status bar
Expand Down
58 changes: 53 additions & 5 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ def loc() -> int:
)


def restore_rawterm_to_main() -> None:
print("[LOG] Restoring rawterm to main branch")
with open("src/CMakeLists.txt", "r") as f:
lines = f.readlines()

for idx, line in enumerate(lines):
if "set(RAWTERM_GIT_TAG" in line and "main" not in line:
lines[idx] = "set(RAWTERM_GIT_TAG \"main\")\n"
break

with open("src/CMakeLists.txt", "w") as f:
f.writelines(lines)


def clean() -> int:
print("Removing build directory")
shutil.rmtree("build", ignore_errors=True)
Expand All @@ -55,9 +69,10 @@ def clean() -> int:

for file in files:
if os.path.isfile(file):
print(f"Removing {file}")
print(f"[LOG] Removing {file}")
os.remove(file)

restore_rawterm_to_main()
return 0


Expand All @@ -66,7 +81,7 @@ def create_read_only_file() -> None:
if os.path.exists(file_name):
return

print("Creating readonly file...")
print("[LOG] Creating readonly file...")
with open(file_name, "w") as f:
f.write("This is a read-only file\n")
f.write("We have some more text here")
Expand Down Expand Up @@ -115,10 +130,10 @@ def create_symlink() -> None:

if platform.machine() == "x86_64":
src += "_x86_64"
print("Creating symlink (x86_64)...")
print("[LOG] Creating symlink (x86_64)...")
elif platform.machine() == "aarch64":
src += "_aarch64"
print("Creating symlink (aarch64)...")
print("[LOG] Creating symlink (aarch64)...")
else:
raise OSError("Architecture not found")

Expand Down Expand Up @@ -157,12 +172,44 @@ def test(testname: str | None, asan: bool) -> int:
)


def get_rawterm_version() -> str:
cmd = [
"git",
"ls-remote",
"--tags",
"--sort=v:refname",
"git@github.com:Ttibsi/rawterm",
]

result = subprocess.run(cmd, capture_output=True, text=True, check=True)

last_version_str = result.stdout.strip().splitlines()[-1]
version_tag = last_version_str.split("/")[-1]
return version_tag.strip()


def write_rawterm_version(tag: str) -> None:
print(f"[LOG] rawterm version: {tag}")
with open("src/CMakeLists.txt", "r") as f:
lines = f.readlines()

for idx, line in enumerate(lines):
if "set(RAWTERM_GIT_TAG" in line and "main" in line:
lines[idx] = line.replace("main", tag)

with open("src/CMakeLists.txt", "w") as f:
f.writelines(lines)


def build(release: bool = False) -> int:
ret: int = 0
cmd: str = "cmake -G Ninja -S . -B build"
if release:
cmd += " -DRELEASE=true"

version_tag = get_rawterm_version()
write_rawterm_version(version_tag)

ret = run_shell_cmd(cmd)
if ret:
return ret
Expand Down Expand Up @@ -216,7 +263,8 @@ def main(argv: Sequence[str] | None = None) -> int:
else:
ret = build(args.release)

print(f"Elapsed time: {round(timeit.default_timer() - start, 2)} Seconds")
elapsed_time = round(timeit.default_timer() - start, 2)
print(f"[LOG] Elapsed time: {elapsed_time} Seconds")

return ret

Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/include)

include(FetchContent)
set(RAWTERM_GIT_TAG "main")
fetchcontent_declare(
rawterm
GIT_REPOSITORY https://github.com/ttibsi/rawterm
GIT_TAG main
GIT_TAG ${RAWTERM_GIT_TAG}
)
fetchcontent_makeavailable(rawterm)

Expand Down
5 changes: 3 additions & 2 deletions src/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

#include <string_view>

[[nodiscard]] constexpr inline std::string_view version() noexcept {
[[nodiscard]] constexpr std::string_view version() noexcept {
return "Iris version: " "@GIT_VERSION@" "\n"
"Compiled on date: " "@COMPILE_DATE@" "\n"
"Build type: " "@BUILD_MODE@";
"Build type: " "@BUILD_MODE@" "\n"
"Rawterm version: " "@RAWTERM_GIT_TAG@" "\n";
}

#endif // VERSION_H
Loading