aedi: move single executable C target to base module

This commit is contained in:
alexey.lysiuk 2022-09-23 13:48:32 +03:00
parent 58259bae1d
commit b48ce185c2
2 changed files with 27 additions and 27 deletions

View file

@ -19,6 +19,7 @@
import copy
import os
import re
import shlex
import shutil
import subprocess
import typing
@ -499,3 +500,29 @@ class CMakeStaticDependencyTarget(CMakeTarget):
if module_path.exists():
self.update_text_file(module_path, _keep_target)
class SingleExeCTarget(MakeTarget):
def __init__(self, name=None):
super().__init__(name)
self.options = ()
def configure(self, state: BuildState):
super().configure(state)
for option in self.options:
state.options[option] = None
def build(self, state: BuildState):
c_compiler = state.c_compiler()
assert c_compiler
args = [str(c_compiler), '-O3', '-o', self.name] + state.options.to_list()
for var in ('CFLAGS', 'LDFLAGS'):
args += shlex.split(state.environment[var])
subprocess.run(args, check=True, cwd=state.build_path, env=state.environment)
def post_build(self, state: BuildState):
self.copy_to_bin(state)

View file

@ -17,38 +17,11 @@
#
import pathlib
import shlex
import zipapp
from .base import *
class SingleExeCTarget(MakeTarget):
def __init__(self, name=None):
super().__init__(name)
self.options = ()
def configure(self, state: BuildState):
super().configure(state)
for option in self.options:
state.options[option] = None
def build(self, state: BuildState):
c_compiler = state.c_compiler()
assert c_compiler
args = [str(c_compiler), '-O3', '-o', self.name] + state.options.to_list()
for var in ('CFLAGS', 'LDFLAGS'):
args += shlex.split(state.environment[var])
subprocess.run(args, check=True, cwd=state.build_path, env=state.environment)
def post_build(self, state: BuildState):
self.copy_to_bin(state)
class BuildCMakeTarget(CMakeTarget):
def __init__(self, name='cmake'):
super().__init__(name)