Skip to content

Commit

Permalink
Some cleanup and fixes (#5)
Browse files Browse the repository at this point in the history
* Update vasm to 1.9c
* Fix shrinkler installation.
* Silence Darwin compiler about '-s' option.
* Remove python package submodules
* Remove some unused functions.
* Move lhafile into Docker environment.
* Fix GitHub actions.
  • Loading branch information
cahirwpz authored Apr 15, 2023
1 parent c68fc59 commit 9e556d8
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 123 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ jobs:
submodules: true

- name: Download archives
run: ./toolchain-m68k --quiet download
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
./toolchain-m68k --quiet download
- name: Build toolchain
run: ./toolchain-m68k --quiet build --prefix=/usr/local
Expand Down
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[submodule "submodules/sfdc"]
path = submodules/sfdc
url = https://github.com/adtools/sfdc
[submodule "submodules/python-lhafile"]
path = submodules/python-lhafile
url = https://github.com/FrodeSolheim/python-lhafile
[submodule "submodules/fd2pragma"]
path = submodules/fd2pragma
url = https://github.com/adtools/fd2pragma.git
Expand All @@ -19,6 +16,3 @@
[submodule "submodules/fs-uae"]
path = submodules/fs-uae
url = https://github.com/FrodeSolheim/fs-uae.git
[submodule "submodules/python-amidev"]
path = submodules/python-amidev
url = https://github.com/cahirwpz/python-amidev.git
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ RUN apt-get install -y --no-install-recommends \
automake bison ca-certificates flex git-core gettext gperf \
gcc g++ libc6-dev libglib2.0-dev libncurses-dev libpng-dev \
libsdl2-dev libsdl2-ttf-dev libopenal-dev libtool make patch \
pkg-config python3 libpython3-dev python3-setuptools quilt \
subversion texinfo zip
pkg-config python3 python3-dev python3-pip quilt texinfo zip
COPY requirements.txt .
RUN pip3 install setuptools wheel && pip3 install -r requirements.txt
93 changes: 5 additions & 88 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
from logging import debug, info, error
from os import path
import contextlib
from distutils import spawn, sysconfig
import fileinput
from distutils import spawn
import os
from multiprocessing import cpu_count
import shutil
import site
import subprocess
import sys
import tarfile
Expand Down Expand Up @@ -67,35 +65,6 @@ def panic(*args):
sys.exit(1)


@fill_in_args
def cmpver(op, v1, v2):
assert op in ['eq', 'lt', 'gt']

v1 = [int(x) for x in v1.split('.')]
v2 = [int(x) for x in v2.split('.')]

def _cmp(l1, l2):
if not len(l1) and not len(l2):
return 0
if not len(l1):
return -1
if not len(l2):
return 1

if l1[0] < l2[0]:
return -1
if l1[0] > l2[0]:
return 1
if l1[0] == l2[0]:
return _cmp(l1[1:], l2[1:])

res = _cmp(v1, v2)

return ((op == 'eq' and res == 0) or
(op == 'lt' and res < 0) or
(op == 'gt' and res > 0))


@fill_in_args
def topdir(name):
if not path.isabs(name):
Expand Down Expand Up @@ -299,25 +268,6 @@ def unarc(name):
raise RuntimeError('Unrecognized archive: "%s"', name)


@fill_in_args
def fix_python_shebang(filename, prefix):
PYTHON = fill_in('{python}')
SITEDIR = path.join(prefix, '{sitedir}')
for line in fileinput.input(files=[filename], inplace=True):
line = line.rstrip()
if line.startswith('#!'):
print('#!/usr/bin/env PYTHONPATH=%s %s' % (SITEDIR, PYTHON))
else:
print(line.rstrip())


@fill_in_args
def add_site_dir(dirname, py_ver):
dirname = path.join(dirname, 'lib', py_ver, 'site-packages')
info('adding "%s" to python site dirs', topdir(dirname))
site.addsitedir(dirname)


@contextlib.contextmanager
def cwd(name):
old = os.getcwd()
Expand Down Expand Up @@ -374,38 +324,6 @@ def wrapper(*args, **kwargs):
return real_decorator


def extend_pythonpath(prefix):
SITEDIR = path.join(prefix, '{sitedir}')
try:
return ':'.join([os.environ['PYTHONPATH'], SITEDIR])
except KeyError:
return SITEDIR


@recipe('pyinstall', 1)
def pyinstall(name, **kwargs):
prefix = kwargs.get('prefix', '{prefix}')
mkdir(path.join(prefix, '{sitedir}'))
with env(PYTHONPATH=extend_pythonpath(prefix)):
execute('{python}', '-m', 'easy_install', '--prefix=' + prefix, name)

@recipe('pyfixbin', 1)
def pyfixbin(name, names, **kwargs):
prefix = kwargs.get('prefix', '{prefix}')
for name in names:
fix_python_shebang(path.join(prefix, 'bin', name), prefix)


@recipe('pysetup', 1)
def pysetup(name, **kwargs):
prefix = kwargs.get('prefix', '{prefix}')
mkdir(path.join(prefix, '{sitedir}'))
with env(PYTHONPATH=extend_pythonpath(prefix)):
with cwd(path.join('{build}', name)):
execute('{python}', 'setup.py', 'build')
execute('{python}', 'setup.py', 'install', '--prefix=' + prefix)


@recipe('fetch', 1)
def fetch(name, url):
if url.startswith('http') or url.startswith('ftp'):
Expand Down Expand Up @@ -530,8 +448,7 @@ def require_header(headers, lang='c', errmsg='', symbol=None, value=None):
panic(errmsg)


__all__ = ['setvar', 'panic', 'cmpver', 'find_executable', 'chmod', 'execute',
'rmtree', 'mkdir', 'copy', 'copytree', 'unarc', 'fetch', 'cwd',
'symlink', 'remove', 'move', 'find', 'textfile', 'env', 'path',
'add_site_dir', 'pysetup', 'pyinstall', 'recipe', 'unpack', 'patch',
'configure', 'make', 'require_header', 'touch', 'pyfixbin']
__all__ = ['setvar', 'panic', 'find_executable', 'chmod', 'execute', 'rmtree',
'mkdir', 'copy', 'copytree', 'fetch', 'cwd', 'symlink', 'remove',
'move', 'find', 'textfile', 'env', 'path', 'recipe', 'unpack',
'patch', 'configure', 'make', 'require_header', 'touch']
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lhafile
1 change: 0 additions & 1 deletion submodules/python-amidev
Submodule python-amidev deleted from 6accf4
1 change: 0 additions & 1 deletion submodules/python-lhafile
Submodule python-lhafile deleted from 8f800b
34 changes: 10 additions & 24 deletions toolchain-m68k
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ from os import environ
import argparse
import logging
import platform
import re
import string
import sys

environ['DONTWRITEBYTECODE'] = 'y'
Expand All @@ -23,14 +21,16 @@ URLS = \
'https://ftp.gnu.org/gnu/texinfo/texinfo-4.12.tar.gz',
'https://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz',
('https://github.com/askeksa/Shrinkler/archive/refs/tags/v4.7.tar.gz',
'shrinkler-4.7.tar.gz'),
'Shrinkler-4.7.tar.gz'),
('ftp://ftp.uk.freesbie.org/sites/distfiles.gentoo.org/distfiles/' +
'flex-2.5.4a.tar.gz', 'flex-2.5.4.tar.gz'),
('http://hp.alinea-computer.de/AmigaOS/NDK39.lha', 'NDK_3.9.lha'),
('http://server.owl.de/~frank/tags/vasm1_8h.tar.gz', 'vasm.tar.gz')]
('http://phoenix.owl.de/tags/vasm1_9c.tar.gz', 'vasm.tar.gz')]


from common import * # NOQA
from common import (setvar, execute, rmtree, configure, unpack, path, panic,
mkdir, env, make, touch, patch, require_header, copy, cwd, recipe,
find_executable, textfile, chmod, copytree, move, find, fetch)


@recipe('target-prepare')
Expand Down Expand Up @@ -147,8 +147,6 @@ def download():


def build():
py_ver = 'python%d.%d' % (sys.version_info.major, sys.version_info.minor)

for var in list(environ.keys()):
if var not in ['_', 'LOGNAME', 'HOME', 'SHELL', 'TMPDIR', 'PWD']:
del environ[var]
Expand All @@ -175,12 +173,13 @@ def build():
environ['LANG'] = 'C'
environ['TERM'] = 'xterm'

add_site_dir('{prefix}', py_ver)

CC = find_executable(CC)
CXX = find_executable(CXX)
FLAGS = '-s -O2 -pipe'

if platform.system() == 'Darwin':
FLAGS += ' -Wno-unused-command-line-argument'

if getLogger().isEnabledFor(logging.DEBUG):
FLAGS += ' -Wall'
else:
Expand Down Expand Up @@ -213,14 +212,6 @@ def build():
require_header(['ncurses.h', 'ncurses/ncurses.h'],
lang='c', errmsg='libncurses-dev package missing')

# require_header([path.join(py_ver, 'Python.h')],
# lang='c', errmsg='python-dev package missing')

execute('git', 'submodule', 'init', 'submodules/python-lhafile')
execute('git', 'submodule', 'update', 'submodules/python-lhafile')
unpack('python-lha', work_dir='{build}')
pysetup('python-lha')

download()
execute('quilt', 'push', '-a', ignore_errors=True)

Expand Down Expand Up @@ -362,9 +353,6 @@ def build():
make('{fsuae}', parallel=True)
make('{fsuae}', 'install')

unpack('python-amidev', work_dir='{build}')
pysetup('python-amidev')

unpack('{shrinkler}', work_dir='{build}')
make('{shrinkler}')
install_shrinkler()
Expand Down Expand Up @@ -403,8 +391,7 @@ if __name__ == "__main__":
help='installation directory')
args = parser.parse_args()

setvar(top=path.abspath(path.dirname(sys.argv[0])),
py_ver='python%d.%d' % (sys.version_info.major, sys.version_info.minor))
setvar(top=path.abspath(path.dirname(sys.argv[0])))

setvar(m4='m4-1.4.17',
gawk='gawk-3.1.8',
Expand All @@ -417,10 +404,9 @@ if __name__ == "__main__":
binutils='binutils-gdb',
fsuae='fs-uae',
gcc='gcc-2.95.3',
shrinkler='shrinkler-4.7',
shrinkler='Shrinkler-4.7',
target='m68k-amigaos',
python=sys.executable,
sitedir=path.join('lib', '{py_ver}', 'site-packages'),
patches=path.join('{top}', 'patches'),
stamps=path.join('{top}', '.build-m68k', 'stamps'),
build=path.join('{top}', '.build-m68k', 'build'),
Expand Down

0 comments on commit 9e556d8

Please sign in to comment.