Skip to content

Commit 13452b2

Browse files
committed
working build script
1 parent a4946af commit 13452b2

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

examples/Blinky_LED_1_KIT_TC397_TFT/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.27)
1+
cmake_minimum_required(VERSION 3.22)
22
project(Blinky LANGUAGES C)
33

44
# List all files and subdirectories in Libraries and Configurations folders

manage.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import docker
1+
import docker, argparse, os, time
22
from docker.errors import DockerException
33
from docker import DockerClient
4+
from docker.types import Mount
45
from operator import attrgetter
56
from itertools import chain
67
from typing import Any, Callable
7-
import argparse
88

99
IMAGE: str = 'francescomecatti/tricore-dev-env:1.0'
1010

@@ -27,16 +27,35 @@ def inner(*args, **kwargs):
2727
print(f'Downloading container {IMAGE}...')
2828
client.images.pull(IMAGE)
2929
print('Done!')
30-
30+
3131
f(client, *args, **kwargs)
3232

3333
return inner
3434

3535

3636
@container_startup
3737
def build(client: DockerClient, args: Any) -> None:
38-
out = client.containers.run(IMAGE, 'ls /', remove=True)
38+
abs_path = os.path.join(os.getcwd(), args.folder)
39+
if not os.path.isfile(os.path.join(abs_path, "CMakeLists.txt")):
40+
raise FileNotFoundError("Missing CMake file.")
41+
42+
build_path = os.path.join(abs_path, "build")
43+
if not os.path.isdir(build_path):
44+
os.makedirs(build_path)
45+
46+
src_folder = Mount("/home/src", abs_path, type='bind')
47+
48+
print(f"Building source from {args.folder} ...")
49+
out = client.containers.run(
50+
IMAGE,
51+
remove=True,
52+
mounts=[src_folder],
53+
entrypoint = '/bin/bash -c',
54+
# command='/bin/bash -c "apt install -y cmake "'
55+
command='"apt install -y cmake && cd /home/src/build && cmake --toolchain tricore_toolchain.cmake .. && make -j$(nproc)"'
56+
)
3957
print(out)
58+
print("Done!")
4059

4160

4261
@container_startup
@@ -49,7 +68,7 @@ def flash(client: DockerClient, args: Any) -> None:
4968
subparsers = parser.add_subparsers(title='action', required=True)
5069

5170
build_subparser = subparsers.add_parser('build', help='Build a project for TriCore architecture. A CMake file is required.')
52-
build_subparser.add_argument('folder', metavar='BASEDIR', type=str)
71+
build_subparser.add_argument('folder', metavar='SRCDIR', type=str)
5372
build_subparser.add_argument('-v', '--verbose', help='Enable container log on the terminal.', action='count', default=0, required=False)
5473
build_subparser.set_defaults(handler=build)
5574

project-template/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.27)
1+
cmake_minimum_required(VERSION 3.22)
22
project(Blinky LANGUAGES C)
33

44
# List all files and subdirectories in Libraries and Configurations folders

0 commit comments

Comments
 (0)