Skip to content

Commit e5fb9a6

Browse files
authored
Enable mac target (#335)
* Change default build target to release + adding artefacts Signed-off-by: Cervenka Dusan <[email protected]> * Add documentation note of new feature. Signed-off-by: Cervenka Dusan <[email protected]> * Added shortcut for readme topics Signed-off-by: Cervenka Dusan <[email protected]> * Add .circleci/config.yml Signed-off-by: Cervenka Dusan <[email protected]> * Move to g++ in pytest Signed-off-by: Cervenka Dusan <[email protected]> Signed-off-by: Cervenka Dusan <[email protected]>
1 parent 3deecf2 commit e5fb9a6

File tree

7 files changed

+61
-64
lines changed

7 files changed

+61
-64
lines changed

.circleci/config.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,30 @@ jobs:
2121
path: ./Release/Linux/erpcgen/erpcgen
2222
build-mac-gcc:
2323
macos:
24-
xcode: 13.2.1
24+
xcode: 12.5.1 # https://circleci.com/docs/using-macos/#supported-xcode-versions https://en.wikipedia.org/wiki/MacOS_version_history#Releases
25+
resource_class: medium
2526
steps:
2627
- checkout
2728
- run: chmod u+x install_dependencies.sh && ./install_dependencies.sh
2829
- run: chmod u+x run_tests.sh && ./run_tests.sh
30+
- store_artifacts:
31+
path: ./Release/Darwin/erpcgen/erpcgen
2932
build-mac-clang:
3033
macos:
31-
xcode: 13.2.1
34+
xcode: 12.5.1 # https://circleci.com/docs/using-macos/#supported-xcode-versions https://en.wikipedia.org/wiki/MacOS_version_history#Releases
35+
resource_class: medium
3236
steps:
3337
- checkout
3438
- run: chmod u+x install_dependencies.sh && ./install_dependencies.sh clang
3539
- run: chmod u+x run_tests.sh && ./run_tests.sh clang
40+
- store_artifacts:
41+
path: ./Release/Darwin/erpcgen/erpcgen
3642

3743

3844
workflows:
3945
build-workflow:
4046
jobs:
4147
- build-linux-gcc
4248
- build-linux-clang
43-
# - build-mac-gcc # Mac is on going, or it can be hosted on company computer.
44-
# - build-mac-clang
45-
46-
# VS Code Extension Version: 1.5.1
49+
- build-mac-gcc
50+
- build-mac-clang

.travis.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

erpcgen/test/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
CC = os.environ['CC']
3737
else:
3838
CC = 'gcc'
39+
if 'CXX' in os.environ:
40+
CXX = os.environ['CXX']
41+
else:
42+
CXX = 'g++'
3943

4044
# Number of test runs to keep.
4145
RUN_KEEP_COUNT = 3

erpcgen/test/conftest.py

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ class CCompiler(object):
258258
def __init__(self, cwd=None, *args):
259259
self._cwd = cwd
260260
self._args = args
261-
self._path = config.CC
261+
self._pathCC = config.CC
262+
self._pathCXX = config.CXX
262263
self._includes = []
263264
self._sources = []
264265

@@ -269,24 +270,41 @@ def add_source(self, path):
269270
self._sources.append(path)
270271

271272
def run(self, captureOutput=False):
273+
def _run(cwd, captureOutput, pytestConfig, args, compilerType):
274+
if pytestConfig and pytestConfig.getvalue("erpcgen_log_execs"):
275+
print(f"Calling {compilerType} compiler:", " ".join(args))
276+
277+
cwd = str(cwd) if cwd is not None else None
278+
if captureOutput:
279+
return subprocess.check_output(args, cwd=cwd)
280+
else:
281+
subprocess.check_call(args, cwd=cwd)
282+
return None
283+
272284
# Enable all warnings except for unused functions.
273-
args = [self._path, "-c", "-Wall", "-Werror", "-Wno-unused-function"]
274-
args += self._args
285+
defaultArgs = ["-c", "-Wall", "-Werror", "-Wno-unused-function"]
286+
defaultArgs += self._args
287+
argsCC = [self._pathCC, "-std=gnu11"] + defaultArgs
288+
argsCXX = [self._pathCXX, "-std=gnu++11"] + defaultArgs
275289

290+
incl = []
276291
for i in self._includes:
277-
args += ["-I", str(i)]
292+
incl += ["-I", str(i)]
293+
294+
argsCXX += incl
295+
argsCC += incl
278296

279297
for s in self._sources:
280-
args.append(str(s))
298+
if str(s).split(".")[-1] == "cpp":
299+
argsCXX.append(str(s))
300+
else:
301+
argsCC.append(str(s))
281302

282-
if pytestConfig and pytestConfig.getvalue("erpcgen_log_execs"):
283-
print("Calling C/C++ compiler:", " ".join(args))
303+
output = [_run(self._cwd, captureOutput, pytestConfig, argsCC, "C")]
304+
output.append(_run(self._cwd, captureOutput,
305+
pytestConfig, argsCXX, "CXX"))
284306

285-
cwd = str(self._cwd) if self._cwd is not None else None
286-
if captureOutput:
287-
return subprocess.check_output(args, cwd=cwd)
288-
else:
289-
subprocess.check_call(args, cwd=cwd)
307+
return output
290308

291309

292310
class ErpcgenTestException(Exception):
@@ -755,15 +773,14 @@ def desc(self):
755773

756774

757775
def verify_tools():
758-
# Verify that erpcgen and the compiler are available.
759-
760-
def handle_err(e: Exception, toolName: str, expectedPath: str, envName: str):
776+
def handle_err(e: Exception, toolName: str, expectedPathCC: str, envNameCC: str, expectedPathCXX: str, envNameCXX: str):
761777
if isinstance(e, OSError):
762778
if e.errno == errno.ENOENT:
763779
print("Error: {} executable cannot be found.".format(toolName))
764-
print("Expected {} path: {}".format(toolName, expectedPath))
765-
print("To change the {} path, set the {} environment variable or create a config_local.py.".format(
766-
toolName, envName))
780+
print("Expected {} paths: {} and {}".format(
781+
toolName, expectedPathCC, expectedPathCXX))
782+
print("To change the {} path, set the {} and/or {} environment variable or create a config_local.py.".format(
783+
toolName, envNameCC, envNameCXX))
767784
print("See readme.txt for more information.")
768785
else:
769786
print("Fatal error: OS error when verifying {} is available. [errno {}]: {}".format(toolName,
@@ -784,7 +801,7 @@ def handle_err(e: Exception, toolName: str, expectedPath: str, envName: str):
784801
try:
785802
CCompiler(None, "--version").run(captureOutput=True)
786803
except (OSError, subprocess.CalledProcessError) as e:
787-
handle_err(e, "compiler", config.CC, "CC")
804+
handle_err(e, "compiler", config.CC, "CC", config.CXX, "CXX")
788805

789806

790807
verify_tools()

install_dependencies.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ Darwin*)
2424
echo "Mac os detected."
2525
brew update
2626
echo "Installing dependencies."
27-
brew install python3 bison flex -v -f 2>&1 && brew upgrade boost || true
28-
curl "https://bootstrap.pypa.io/pip/2.7/get-pip.py" | sudo python3
29-
sudo pip install tornado
30-
sudo pip install --user nose
31-
sudo pip install pytest --upgrade --ignore-installed six
27+
brew install python3 boost bison flex -v -f 2>&1
28+
sudo pip3 install tornado
29+
sudo pip3 install --user nose
30+
sudo pip3 install pytest --upgrade --ignore-installed six
31+
sudo pip3 install pyyaml
3232
;;
3333
*)
3434
echo "Unknown or currently unsupported os: ${unameOut}"

mk/flags.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ else
2828
MARCH ?= # -m32 or -m64
2929
endif
3030

31-
CXXFLAGS += -std=gnu++11 -D LINUX -Wunused-variable -Wno-deprecated-register -Wno-narrowing -Werror $(MARCH)
31+
CXXFLAGS += -std=gnu++11 -Wunused-variable -Wno-deprecated-register -Wno-narrowing -Werror $(MARCH)
3232
#CXXFLAGS += -Wall -Wextra -Wshadow -pedantic-errors
33-
CFLAGS += -std=gnu11 -D LINUX -D _GNU_SOURCE -Werror $(MARCH)
33+
CFLAGS += -std=gnu11 -Werror $(MARCH)
3434
YYFLAGS += -Wno-other # --debug --verbose
3535
LLFLAGS +=
3636
LDFLAGS += $(MARCH)

test/common/unit_test_tcp_arbitrator_client.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "test_firstInterface.h"
1818
#include "test_secondInterface.h"
1919
#include "unit_test.h"
20+
#include <chrono>
21+
#include <thread>
2022

2123
#include <unistd.h>
2224

@@ -111,6 +113,8 @@ int main(int argc, char **argv)
111113

112114
Log::info("Intit ERPC first (client) app...\n");
113115

116+
std::chrono::milliseconds duration(500);
117+
std::this_thread::sleep_for(duration);
114118
erpc_status_t err = g_transport.open();
115119
if (err)
116120
{

0 commit comments

Comments
 (0)