Skip to content

Commit

Permalink
Merge pull request #150 from kaorut/github_actions_setup
Browse files Browse the repository at this point in the history
Add a script to the setup project to make library install image #147

(cherry picked from commit 3827a63)
  • Loading branch information
kaorut committed Jun 14, 2021
1 parent e6dde9d commit 0ecdd33
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 17 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/windows-visualcpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,17 @@ jobs:
- name: Make archive
shell: powershell
run: |
Compress-Archive -Path .\bin.setup\Release.Win32 -DestinationPath .\bin.setup\tetengo-windows-Win32-$env:TETENGO_VER.zip
Compress-Archive -Path .\bin.setup\Release.x64 -DestinationPath .\bin.setup\tetengo-windows-x64-$env:TETENGO_VER.zip
Compress-Archive -Path .\bin.setup\Release.Win32 -DestinationPath .\bin.setup\tetengo-windows-Win32-$env:TETENGO_VER.zip
Compress-Archive -Path .\bin.setup\Release.x64 -DestinationPath .\bin.setup\tetengo-windows-x64-$env:TETENGO_VER.zip
Compress-Archive -Path .\bin.libimage\Release.x64 -DestinationPath .\bin.libimage\tetengo-windows-libimage-x64-$env:TETENGO_VER.zip
- name: Move artifacts
shell: cmd
run: |
mkdir artifacts
move bin.setup\tetengo-windows-Win32-%TETENGO_VER%.zip artifacts
move bin.setup\tetengo-windows-x64-%TETENGO_VER%.zip artifacts
move bin.setup\tetengo-windows-Win32-%TETENGO_VER%.zip artifacts
move bin.setup\tetengo-windows-x64-%TETENGO_VER%.zip artifacts
move bin.libimage\tetengo-windows-libimage-x64-%TETENGO_VER%.zip artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
aclocal.m4
autom4te.cache/
bin/
bin.libimage/
bin.setup/
compile
config.guess
Expand Down
1 change: 1 addition & 0 deletions setup/installer/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright (C) 2019-2021 kaoru https://www.tetengo.org/

script_files = \
copy_libimage_files.py \
generate_content_wxs.py \
generate_content_wxs_source.py

Expand Down
9 changes: 8 additions & 1 deletion setup/installer/Makefile.nmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ COPY=copy
ECHO=echo
MKDIR=mkdir
DEL=del
RMDIR=rmdir

OBJDIR=$(WORKDIR)\obj\$(CONFIGURATION).$(PLATFORM)
BINDIR=$(WORKDIR)\bin.setup\$(CONFIGURATION).$(PLATFORM)
LIBIMAGEBINDIR=$(WORKDIR)\bin.libimage\$(CONFIGURATION).$(PLATFORM)
TETENGOOUTDIR=$(WORKDIR)\..\..\bin\$(CONFIGURATION).$(PLATFORM)

all: $(BINDIR)\tetengo.msi $(BINDIR)\setup.exe $(BINDIR)\setup.conf
all: $(BINDIR)\tetengo.msi $(BINDIR)\setup.exe $(BINDIR)\setup.conf $(LIBIMAGEBINDIR)

$(BINDIR)\tetengo.msi: $(OBJDIR)\tetengo.en.msi $(OBJDIR)\ja.mst
-$(MKDIR) $(BINDIR)
Expand Down Expand Up @@ -62,7 +64,12 @@ $(BINDIR)\setup.exe: $(TETENGOOUTDIR)\setup.exe
$(BINDIR)\setup.conf:
$(ECHO) tetengo.msi > $@

$(LIBIMAGEBINDIR): $(OBJDIR)\content_wxs_source.txt
-$(MKDIR) $(LIBIMAGEBINDIR)
$(PYTHON) "$(WORKDIR)\copy_libimage_files.py" $** $@

.PHONY: clean
clean:
-$(DEL) /f /q $(OBJDIR)\*
-$(DEL) /f /q $(BINDIR)\*
-$(RMDIR) /s /q $(LIBIMAGEBINDIR)
66 changes: 66 additions & 0 deletions setup/installer/copy_libimage_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#! /usr/bin/env python3
"""Copies the files for a library image
Copyright (C) 2019-2021 kaoru https://www.tetengo.org/
"""

import pathlib
import re
import shutil
import sys
from typing import List, Optional, Tuple


def main(args: List[str]) -> None:
"""The main function.
Args:
args (list[str]): Program rguments
"""
if len(args) < 2:
print(
"Usage: ./copy_libimage_files.py content_wxs_source.txt destination",
file=sys.stderr,
)
sys.exit(0)
files: List[Tuple[pathlib.Path, pathlib.Path]] = _list_files(pathlib.Path(args[0]))
_copy_files(files, pathlib.Path(args[1]))


def _list_files(source_path: pathlib.Path) -> List[Tuple[pathlib.Path, pathlib.Path]]:
files: List[Tuple[pathlib.Path, pathlib.Path]] = []
with source_path.open(mode="r", encoding="UTF-8") as stream:
for line in stream:
matched: Optional[re.Match[str]] = re.match(
"^([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^ ]+)", line
)
if not matched:
continue
feature: str = matched.group(1)
source_directory = pathlib.Path(matched.group(2))
source_path = pathlib.Path(matched.group(3))
destination = pathlib.Path(matched.group(4))
if (
feature != "include"
and feature != "lib.Release.Win32"
and feature != "lib.Release.x64"
):
continue
files.append(
(source_directory / source_path, (destination / source_path).parent)
)
return files


def _copy_files(
files: List[Tuple[pathlib.Path, pathlib.Path]], destination_root: pathlib.Path
) -> None:
shutil.rmtree(destination_root, ignore_errors=True)
for file in files:
destination_directory: pathlib.Path = destination_root / file[1]
destination_directory.mkdir(parents=True, exist_ok=True)
shutil.copy(file[0], destination_directory)


if __name__ == "__main__":
main(sys.argv[1:])
25 changes: 13 additions & 12 deletions setup/installer/installer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,33 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeOutput>$(OutDir)tetengo.msi</NMakeOutput>
<NMakeBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) all</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) clean</NMakeCleanCommandLine>
<NMakeBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) all</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) clean</NMakeCleanCommandLine>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<NMakeOutput>$(OutDir)tetengo.msi</NMakeOutput>
<NMakeBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) all</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) clean</NMakeCleanCommandLine>
<NMakeBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) all</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) clean</NMakeCleanCommandLine>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<NMakeOutput>$(OutDir)tetengo.msi</NMakeOutput>
<NMakeBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) all</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) clean</NMakeCleanCommandLine>
<NMakeBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) all</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) clean</NMakeCleanCommandLine>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<NMakeOutput>$(OutDir)tetengo.msi</NMakeOutput>
<NMakeBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) all</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) clean</NMakeCleanCommandLine>
<NMakeBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) all</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) clean all</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>nmake -f $(ProjectDir)Makefile.nmake ARCH=$(PlatformTarget) PLATFORM=$(Platform) SOLUTIONDIR=$(SolutionDir) WORKDIR=$(ProjectDir) OBJDIR=$(IntDir) BINDIR=$(OutDir) LIBIMAGEBINDIR=$(SolutionDir)bin.libimage\$(Configuration).$(Platform) clean</NMakeCleanCommandLine>
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="COPYING.rtf" />
<None Include="copy_libimage_files.py" />
<None Include="generate_content_wxs.py" />
<None Include="generate_content_wxs_source.py" />
<None Include="main.wxs" />
Expand Down
3 changes: 3 additions & 0 deletions setup/installer/installer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<None Include="COPYING.rtf">
<Filter>res</Filter>
</None>
<None Include="copy_libimage_files.py">
<Filter>src</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="files_to_install.txt">
Expand Down

0 comments on commit 0ecdd33

Please sign in to comment.