Skip to content

Commit

Permalink
FIX: Building grammers properly
Browse files Browse the repository at this point in the history
  • Loading branch information
maveonair committed Jun 12, 2023
1 parent f4e38aa commit cc5bf70
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 45 deletions.
45 changes: 12 additions & 33 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from contextlib import chdir
from distutils.dir_util import copy_tree

HELIX_VERSION = "23.03"
HELIX_VERSION = "23.05"
DEBIAN_DIRECTORY = os.path.join(os.path.dirname(os.path.abspath(__file__)), "debian")
TARGET_DIRECTORY = os.path.join(os.getcwd(), "target")
HELIX_SOURCE_CODE_URL = "https://github.com/helix-editor/helix/archive/refs/tags"
HELIX_SOURCE_CODE_URL = f"https://github.com/helix-editor/helix/releases/download/{HELIX_VERSION}/helix-{HELIX_VERSION}-source.tar.xz"


def get_args() -> tuple[str, str]:
Expand All @@ -35,20 +35,17 @@ def get_args() -> tuple[str, str]:


def prepare_target(target_directory: str) -> None:
rmtree(target_directory)
os.mkdir(target_directory)

if os.path.exists(target_directory):
rmtree(target_directory)

def get_helix_source_url(helix_version: str) -> str:
return f"{HELIX_SOURCE_CODE_URL}/{helix_version}.tar.gz"
os.mkdir(target_directory)


def download_helix_release(target_directory_path: str, helix_version: str) -> str:
url = get_helix_source_url(helix_version)
filename = f"helix_{helix_version}.orig.tar.gz"
filename = f"helix_{helix_version}.orig.tar.xz"

print(f"-> Downloading {url}...")
response = requests.get(url, allow_redirects=True)
print(f"-> Downloading {HELIX_SOURCE_CODE_URL}...")
response = requests.get(HELIX_SOURCE_CODE_URL, allow_redirects=True)

target_file_path = os.path.join(target_directory_path, filename)

Expand Down Expand Up @@ -86,20 +83,6 @@ def create_cargo_vendor_archive(
subprocess.check_call(["tar", "cJf", tar_file_path, "vendor/"])


def crate_grammar_sources_archive(
source_directory_path: str, destination_directory_path: str
) -> None:
with chdir(source_directory_path):
print("-> Run cargo build...")
subprocess.check_call(["cargo", "build", "--release"])

tar_file_path = os.path.join(destination_directory_path, "grammars.src.tar.xz")
print(f"-> Create {tar_file_path}...")
subprocess.check_call(
["tar", "cJf", tar_file_path, "runtime/grammars/sources/"]
)


def create_dependencies_archives(
source_directory_path: str, destination_directory_path: str
) -> None:
Expand All @@ -108,24 +91,20 @@ def create_dependencies_archives(
destination_directory_path=destination_directory_path,
)

crate_grammar_sources_archive(
source_directory_path=source_directory_path,
destination_directory_path=destination_directory_path,
)


def prepare_for_build(
source_directory_path: str
) -> str:
prepare_target(TARGET_DIRECTORY)
prepare_target(source_directory_path)

release_file_path = download_helix_release(
target_directory_path=TARGET_DIRECTORY,
helix_version=HELIX_VERSION,
)

unarchive_helix_release(
target_directory_path=TARGET_DIRECTORY,
target_directory_path=source_directory_path,
archive_file_path=release_file_path,
)

Expand Down Expand Up @@ -164,7 +143,7 @@ def update_changelog(source_directory_path, ubuntu_codename, changelog_version)
def run_debuild(source_directory_path: str) -> None:
with chdir(source_directory_path):
print("-> Run debuild...")
subprocess.check_call(["debuild", "-S", "-sa"])
subprocess.check_call(["debuild", "--no-lintian", "-S", "-sa"])


def run_build(
Expand All @@ -179,7 +158,7 @@ def run_build(
prepare_target(source_directory_path)

unarchive_helix_release(
target_directory_path=TARGET_DIRECTORY, archive_file_path=release_file_path
target_directory_path=source_directory_path, archive_file_path=release_file_path
)

move_debian_files(
Expand Down
5 changes: 0 additions & 5 deletions debian/cargo.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
[source.crates-io]
replace-with = "vendored-sources"

[source."https://github.com/tree-sitter/tree-sitter"]
git = "https://github.com/tree-sitter/tree-sitter"
rev = "c51896d32dcc11a38e41f36e3deb1a6a9c4f4b14"
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"
36 changes: 36 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
helix (23.05-8) unstable; urgency=medium

* Remove grammar sources after build

-- Fabian Mettler <[email protected]> Mon, 12 Jun 2023 17:32:00 +0100

helix (23.05-7) unstable; urgency=medium

* Add missing build dependencies

-- Fabian Mettler <[email protected]> Mon, 12 Jun 2023 17:15:00 +0100

helix (23.05-6) unstable; urgency=medium

* Try to fix build process for grammars

-- Fabian Mettler <[email protected]> Mon, 12 Jun 2023 09:55:00 +0100

helix (23.05-5) unstable; urgency=medium

* Try to fix build process for grammars

-- Fabian Mettler <[email protected]> Sun, 11 Jun 2023 15:58:00 +0100

helix (23.05-4) unstable; urgency=medium

* Try to fix build process for grammars

-- Fabian Mettler <[email protected]> Sun, 11 Jun 2023 15:48:00 +0100

helix (23.05-3) unstable; urgency=medium

* New upstream release

-- Fabian Mettler <[email protected]> Sun, 11 Jun 2023 15:29:00 +0100

helix (23.03-3) unstable; urgency=medium

* Fix build process for grammars
Expand Down
8 changes: 5 additions & 3 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ Section: editors
Priority: optional
Maintainer: Fabian Mettler <[email protected]>
Build-Depends:
cargo:native,
cargo,
debhelper (>= 12),
rustc:native,
g++,
git,
rustc,
Standards-Version: 4.5.1
Homepage: https://github.com/helix-editor/helix

Expand All @@ -17,4 +19,4 @@ Depends:
Provides:
editor
Description: A post-modern text editor
It's a joke. If Neovim is the modern Vim, then Helix is post-modern.
It's a joke. If Neovim is the modern Vim, then Helix is post-modern.d
5 changes: 2 additions & 3 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ override_dh_auto_build:
mkdir -p .cargo
cp debian/cargo.config .cargo/config.toml
tar xJf debian/vendor.tar.xz
tar xJf debian/grammars.src.tar.xz
cargo build --release
cargo build --locked --offline --release

# cleanup grammar sources
#cleanup grammar sources
rm -rf ./runtime/grammars/sources

override_dh_auto_install:
Expand Down
1 change: 0 additions & 1 deletion debian/source/include-binaries
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
debian/grammars.src.tar.xz
debian/vendor.tar.xz

0 comments on commit cc5bf70

Please sign in to comment.