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

v2.0.5 switch to multi-file package.

- dropped build scripts and files for single-file distribution.
- updated git pre-commit hook to run "make check" instead of "make dist"
- renamed zero-input-framework to zero-input. This is to conform "there
  should be a library with the same name as package name" rule.
- rename .el.in to .el.tpl.
  melpa build process will do something on .el.in, which I do not expect.
- "make tar" is a little messy because emacs doesn't support git archive
  generated tar file.
- add zero-input-pkg.el in git, melpa build hangs when this file is not
  present.
parent 02f7fbfc
Loading
Loading
Loading
Loading

.gitattributes

0 → 100644
+6 −0
Original line number Diff line number Diff line
*-test.el export-ignore
*-debug.el export-ignore
git-hooks/ export-ignore
zero-input-reload-all.el export-ignore
.gitattributes export-ignore
.gitignore export-ignore
+2 −1
Original line number Diff line number Diff line
*.zip
*.elc
*.tar
*.tmp
build/
+14 −17
Original line number Diff line number Diff line
VERSION := $(shell grep 'setq zero-input-version' zero-input-framework.el | cut -d'"' -f2)
VERSION := $(shell grep 'setq zero-input-version' zero-input.el | cut -d'"' -f2)
TAR_BUILD_DIR := build

default: dist
default: check
#===============
# multiple file
#===============
check:
	emacs -Q --batch -l zero-input-reload-all.el -f zero-input-rebuild -l zero-input-table.el -l zero-input-table-test.el -f ert-run-tests-batch
	sed "s/PKG_VERSION/$(VERSION)/g" zero-input-pkg.el.tpl > zero-input-pkg.tmp
	if ! diff -q zero-input-pkg.tmp zero-input-pkg.el; then mv zero-input-pkg.tmp zero-input-pkg.el; fi
tar: check
	git archive -o zero-input-$(VERSION).tar --prefix=zero-input-$(VERSION)/ HEAD
	rm -rf $(TAR_BUILD_DIR)/ && mkdir -p $(TAR_BUILD_DIR)/
	tar xf zero-input-$(VERSION).tar -C $(TAR_BUILD_DIR)/
	sed "s/PKG_VERSION/$(VERSION)/g" zero-input-pkg.el.tpl > $(TAR_BUILD_DIR)/zero-input-$(VERSION)/zero-input-pkg.el
	rm zero-input-$(VERSION).tar
	tar cf zero-input-$(VERSION).tar -C $(TAR_BUILD_DIR)/ zero-input-$(VERSION)
	tar -tf zero-input-$(VERSION).tar
zip:
	git archive -o zero-input-el-$(VERSION).zip --prefix=zero-input/ HEAD
#==========================
# 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-input.el
dist-check: build
	@echo "testing byte-compile is clean..."
	emacs -Q --batch -l ~/.emacs.d/elpa/s-1.11.0/s.el --eval='(byte-compile-file "zero-input.el")'
	@echo "running unit tests..."
	emacs -Q --batch -l ~/.emacs.d/elpa/s-1.11.0/s.el -l zero-input.el -l zero-input-panel-test.el -l zero-input-pinyin-service-test.el -l zero-input-framework-test.el -l zero-input-pinyin-test.el -l zero-input-table.el -l zero-input-table-test.el -f ert-run-tests-batch
#====================
# other make targets
#====================
@@ -29,4 +26,4 @@ install-git-hooks:
	rsync -air git-hooks/ .git/hooks/
version:
	@echo $(VERSION)
.PHONY: default check zip dist build dist-check install-git-hooks version
.PHONY: default check tar zip dist build dist-check install-git-hooks version
+8 −13
Original line number Diff line number Diff line
* COMMENT -*- mode: org -*-
#+Date: 2019-09-01
Time-stamp: <2019-10-28>
Time-stamp: <2019-11-05>

* zero-el
* zero-input

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

* File list
- zero-input.el

  It's a generated file for one-file package distribution. Not used for
  development.

- zero-input-framework.el

  zero framework source code. This provides the framework and user interface
  for zero-el.
  for zero-input.

- zero-input-panel.el

@@ -36,18 +31,18 @@ and zero-input-framework, which is an emacs Chinese input method framework.

- zero-input-reload-all.el

  zero-el development utility.
  development utility.

- zero-input-table.el

  serves as an example of how to use zero framework to create new input
  methods.

* introduce to zero-el
* introduce to zero-input
https://blog.emacsos.com/zero-el.html

* License
zero-el is under Apache License 2.0
zero-input is under Apache License 2.0

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

build.py

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

"""
build zero-input.el from zero-input.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-input-panel.el") == (
        "INCLUDE_ZERO_INPUT_PANEL_EL")
    assert placeholder_for_file("zero-input-pinyin-service.el") == (
        "INCLUDE_ZERO_INPUT_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-input.el.in") as tpl:
        content = tpl.read()
    expanded_content = expand_placeholder_for_files(content, [
        "zero-input-panel.el",
        "zero-input-framework.el",
        "zero-input-table.el",
        "zero-input-pinyin-service.el",
        "zero-input-pinyin.el",
        ])
    with open('zero-input.el', 'w') as out:
        out.write(expanded_content)


if __name__ == '__main__':
    main()
Loading