Commit 72196558 authored by Yuanle Song's avatar Yuanle Song
Browse files

v1.2.6 use a single file distribution for melpa.

- renamed zero.el back to zero-framework.el
- to build a dist, just run "make".
  the zero.el template is in zero.el.in
- zero.el is built and added to git repo in git pre-commit hook. it will
  be kept in master branch.
- fixed a few package-lint style warning.
parent 66e0dbb5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
*.zip
*.elc
*.tar
+22 −12
Original line number Diff line number Diff line
VERSION := $(shell grep 'setq zero-version' zero.el | cut -d'"' -f2)
VERSION := $(shell grep 'setq zero-version' zero-framework.el | cut -d'"' -f2)

default: compile
pkg-el:
	sed "s/PKG_VERSION/$(VERSION)/g" zero-pkg.el.tpl > zero-pkg.el
compile:
default: dist
#===============
# multiple file
#===============
check:
	emacs -Q --batch -l zero-reload-all.el -f zero-rebuild -l zero-table.el -l zero-table-test.el -f ert-run-tests-batch
zip: pkg-el
zip:
	git archive -o zero-el-$(VERSION).zip --prefix=zero/ HEAD
pkg: pkg-el
# Note: install from tar is not working. install from dir does work.
	@echo "Creating tar for use with M-x package-install-file"
	git archive -o zero-$(VERSION).tar --prefix=zero-$(VERSION)/ HEAD
	@echo "Done"
#==========================
# single file distribution
#==========================
dist: dist-check
build:
	if [ ! -x ~/.local/bin/pytest ]; then python3 -m pip install --user pytest; fi
	~/.local/bin/pytest build.py
	./build.py
	sed -i "s/PKG_VERSION/$(VERSION)/g" zero.el
dist-check: build
	emacs -Q --batch -l ~/.emacs.d/elpa/s-1.11.0/s.el -l zero.el -l zero-panel-test.el -l zero-pinyin-service-test.el -l zero-framework-test.el -l zero-pinyin-test.el -l zero-table.el -l zero-table-test.el -f ert-run-tests-batch
#====================
# other make targets
#====================
install-git-hooks:
	rsync -air git-hooks/ .git/hooks/
version:
	@echo $(VERSION)
.PHONY: default pkg-el compile zip pkg install-git-hooks version
.PHONY: default check zip dist build dist-check install-git-hooks version
+5 −5
Original line number Diff line number Diff line
* COMMENT -*- mode: org -*-
#+Date: 2019-09-01
Time-stamp: <2019-10-11>
Time-stamp: <2019-10-16>

* zero-el

zero-el provides zero-pinyin, an Emacs pinyin input method for Chinese and
zero library, which is an emacs Chinese input method framework.
zero-framework, which is an emacs Chinese input method framework.

* File list
- zero.el
- zero-framework.el

  zero framework source code. This provides the framework and user interface
  for zero-el.
@@ -44,5 +44,5 @@ https://blog.emacsos.com/zero-el.html
* License
zero-el is under Apache License 2.0

ibus-compute-pixel-position function in zero.el is under GPLv3.
see NOTICE file.
zero--ibus-compute-pixel-position function in zero-framework.el is under
GPLv3. see NOTICE file.

build.py

0 → 100755
+74 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
# coding=utf-8

"""
build zero.el from zero.el.in and other el files
"""

import logging

logger = logging.getLogger(__name__)


def placeholder_for_file(fn):
    """return placeholder that should be used for filename.

    """
    return "INCLUDE_" + fn.replace('-', '_').replace('.', '_').upper()


def test_placeholder_for_file():
    assert placeholder_for_file("zero-panel.el") == "INCLUDE_ZERO_PANEL_EL"
    assert placeholder_for_file("zero-pinyin-service.el") == (
        "INCLUDE_ZERO_PINYIN_SERVICE_EL")


def get_el_file_body(fn):
    rows = []
    append = False
    with open(fn) as f:
        for line in f:
            if append:
                if '(require ' in line:
                    logger.debug("skipping require call: %s", line)
                    continue
                rows.append(line)
                if line.startswith('(provide'):
                    break
            else:
                if line.startswith(";;; Code:"):
                    rows.append(";; body of %s\n" % (fn,))
                    append = True
    return "".join(rows)


def expand_placeholder_for_files(old_content, filenames):
    """replace INCLUDE_FOO_BAR_EL by body of foo-bar.el.

    """
    result = old_content
    for fn in filenames:
        result = result.replace(placeholder_for_file(fn),
                                get_el_file_body(fn))
    return result


def main():
    logging.basicConfig(
        format='%(asctime)s [%(module)s] %(levelname)-8s %(message)s',
        level=logging.INFO)
    with open("zero.el.in") as tpl:
        content = tpl.read()
    expanded_content = expand_placeholder_for_files(content, [
        "zero-panel.el",
        "zero-framework.el",
        "zero-table.el",
        "zero-pinyin-service.el",
        "zero-pinyin.el",
        ])
    with open('zero.el', 'w') as out:
        out.write(expanded_content)


if __name__ == '__main__':
    main()
+2 −2
Original line number Diff line number Diff line
#!/bin/sh
set -e
make pkg-el compile
git add zero-pkg.el
make dist-check
git add zero.el
Loading