diff --git a/Jenkinsfile b/Jenkinsfile index 0cd7352..58ff344 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,26 +1,10 @@ -@Library('xmos_jenkins_shared_library@v0.28.0') +@Library('xmos_jenkins_shared_library@v0.37.0') def runningOn(machine) { println "Stage running on:" println machine } -def buildApps(appList) { - appList.each { app -> - sh "cmake -G 'Unix Makefiles' -S ${app} -B ${app}/build" - sh "xmake -C ${app}/build -j\$(nproc)" - } -} - -def buildDocs(String zipFileName) { - withVenv { - sh 'pip install git+ssh://git@github.com/xmos/xmosdoc' - sh 'xmosdoc' - zip zipFile: zipFileName, archive: true, dir: "doc/_build" - } -} - - getApproval() pipeline { @@ -28,10 +12,13 @@ pipeline { parameters { string( name: 'TOOLS_VERSION', - defaultValue: '15.2.1', + defaultValue: '15.3.0', description: 'The tools version to build with (check /projects/tools/ReleasesTools/)' ) } // parameters + environment { + REPO_NAME = 'xscope_fileio' //TODO remove this after Jenkins Shared Library Update + } // environment options { skipDefaultCheckout() timestamps() @@ -80,23 +67,23 @@ pipeline { } } } - stage('Build') { - steps { - sh "git clone -b develop git@github.com:xmos/xcommon_cmake ${WORKSPACE}/xcommon_cmake" - dir('xscope_fileio') { - withTools(params.TOOLS_VERSION) { - withEnv(["XMOS_CMAKE_PATH=${WORKSPACE}/xcommon_cmake"]) { - buildApps([ - "examples/fileio_features_xc", - "examples/throughput_c", - "tests/no_hang", - "tests/close_files", - ]) // buildApps - } // withEnv - } // withTools - } // dir - } // steps - } // stage 'Build' + + stage('Build examples') { + steps { + dir("xscope_fileio/examples") { + xcoreBuild() + } // dir + } // steps + } // Build examples + + stage('Build tests') { + steps { + dir("xscope_fileio/tests") { + xcoreBuild() + } // dir + } // steps + } // Build examples + stage('Cleanup xtagctl'){ steps { dir('xscope_fileio') { @@ -140,7 +127,7 @@ pipeline { withTools(params.TOOLS_VERSION) { dir('host') { - withVS("vcvars32.bat") { + withVS("vcvars64.bat") { sh 'cmake -G "Ninja" .' sh 'ninja' } @@ -186,7 +173,7 @@ pipeline { checkout scm createVenv("requirements.txt") withTools(params.TOOLS_VERSION) { - buildDocs("xscope_fileio.zip") + buildDocs(archiveZipOnly: true) } } } diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..7a11c40 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.21) +include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) +project(xscope_fileio) +add_subdirectory(throughput_c) +add_subdirectory(fileio_features_xc) diff --git a/examples/fileio_features_xc/CMakeLists.txt b/examples/fileio_features_xc/CMakeLists.txt index 8bd45cd..1624f25 100644 --- a/examples/fileio_features_xc/CMakeLists.txt +++ b/examples/fileio_features_xc/CMakeLists.txt @@ -3,7 +3,7 @@ include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(fileio_features_xc) # sandbox -set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) +set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) # target ans srcs set(APP_HW_TARGET XCORE-AI-EXPLORER) diff --git a/examples/fileio_features_xc/Makefile b/examples/fileio_features_xc/Makefile deleted file mode 100644 index ffc077f..0000000 --- a/examples/fileio_features_xc/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# The TARGET variable determines what target system the application is -# compiled for. It either refers to an XN file in the source directories -# or a valid argument for the --target option when compiling -TARGET = XCORE-AI-EXPLORER - -# The APP_NAME variable determines the name of the final .xe file. It should -# not include the .xe postfix. If left blank the name will default to -# the project name -APP_NAME = - -# The USED_MODULES variable lists other modules used by the application. -USED_MODULES = xscope_fileio(>=0.1.0) - -# The flags passed to xcc when building the application -# You can also set the following to override flags for a particular language: -# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS -# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to -# xcc for the final link (mapping) stage. -XCC_FLAGS = -Os -g -report -DTEST_WAV_XSCOPE=1 - -# The XCORE_ARM_PROJECT variable, if set to 1, configures this -# project to create both xCORE and ARM binaries. -XCORE_ARM_PROJECT = 0 - -# The VERBOSE variable, if set to 1, enables verbose output from the make system. -VERBOSE = 0 - -XMOS_MAKE_PATH ?= ../.. --include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common \ No newline at end of file diff --git a/examples/fileio_features_xc/README.rst b/examples/fileio_features_xc/README.rst index cb1e3d2..783baed 100644 --- a/examples/fileio_features_xc/README.rst +++ b/examples/fileio_features_xc/README.rst @@ -8,8 +8,7 @@ Build example (using xcommon_cmake) .. warning:: - Make sure ``xscope_fileio`` host application is installed. - Make sure ``XCOMMON_CMAKE_PATH`` environment variable is set to the directory where ``xcommon_cmake`` is located. + Make sure ``xscope_fileio`` python package and host application are installed. Run the following command from the current directory: diff --git a/examples/throughput_c/CMakeLists.txt b/examples/throughput_c/CMakeLists.txt index fd56f54..743a404 100644 --- a/examples/throughput_c/CMakeLists.txt +++ b/examples/throughput_c/CMakeLists.txt @@ -3,12 +3,11 @@ include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(fileio_test) # sandbox -set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) +set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) # target ans srcs set(APP_HW_TARGET XCORE-AI-EXPLORER) -set(APP_XC_SRCS main.xc) -set(APP_C_SRCS test.c) +set(APP_C_SRCS main.c) # flags set(APP_COMPILER_FLAGS diff --git a/examples/throughput_c/Makefile b/examples/throughput_c/Makefile deleted file mode 100644 index 1f1a6e2..0000000 --- a/examples/throughput_c/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -TARGET_FLAG ?= -target=XCORE-AI-EXPLORER -TARGET_EXEC ?= bin/fileio_test.xe - -XCC ?= xcc - -SRCS := main.xc test.c ../../xscope_fileio/src/xscope_io_device.c -INC_DIRS += $(dir $(SRCS)) ../../xscope_fileio/api ../../xscope_fileio -INC_FLAGS := $(addprefix -I,$(INC_DIRS)) - -BUILD_DIR := build -OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) -DEPS := $(OBJS:.o=.d) - -CFLAGS := -c $(INC_FLAGS) $(TARGET_FLAG) -Os -g -XCFLAGS := $(CFLAGS) - -$(TARGET_EXEC): $(OBJS) config.xscope -# @echo "**HELLO LINKER**" - $(XCC) $(TARGET_FLAG) -o $@ $^ -report - -# c source -$(BUILD_DIR)/%.c.o: %.c - $(MKDIR_P) $(dir $@) -# @echo "**HELLO C**" - $(XCC) $(CFLAGS) -c $< -o $@ - -# xc source -$(BUILD_DIR)/%.xc.o: %.xc - $(MKDIR_P) $(dir $@) -# @echo "**HELLO XC**" - $(XCC) $(XCFLAGS) -c $< -o $@ - -# asm source -$(BUILD_DIR)/%.S.o: %.S - $(MKDIR_P) $(dir $@) -# @echo "**HELLO ASM**" - $(XCC) $(ASMFLAGS) -c $< -o $@ - -.PHONY: clean - -clean: - $(RM) -r build - $(RM) $(TARGET_EXEC) - --include $(DEPS) - -MKDIR_P ?= mkdir -p diff --git a/examples/throughput_c/README.rst b/examples/throughput_c/README.rst index 1a89921..68c830a 100644 --- a/examples/throughput_c/README.rst +++ b/examples/throughput_c/README.rst @@ -8,8 +8,7 @@ Build example (using xcommon_cmake) .. warning:: - Make sure ``xscope_fileio`` host application is installed. - Make sure ``XCOMMON_CMAKE_PATH`` environment variable is set to the directory where ``xcommon_cmake`` is located. + Make sure ``xscope_fileio`` python package and host application are installed. Run the following command from the current directory: @@ -30,4 +29,5 @@ Run the following command from top-level directory: Output ------ -The output will be several files in the current directory inside the output folder. +The example writes and reads files on the host computer and measures the KBPS throughput. Once finished, the measurements are displayed on the console. + diff --git a/examples/throughput_c/test.c b/examples/throughput_c/main.c similarity index 84% rename from examples/throughput_c/test.c rename to examples/throughput_c/main.c index 098c1eb..9cd1837 100644 --- a/examples/throughput_c/test.c +++ b/examples/throughput_c/main.c @@ -49,12 +49,10 @@ void do_test(void){ unsigned t3 = get_reference_time(); write_total_time += t3 - t2; } while(num_bytes > 0); - - - - - printf("Throughput KBPS Read: %f, Write: %f\n", ticks_to_KBPS(read_total_time, fsize), ticks_to_KBPS(write_total_time, fsize)); + printf("Throughput KBPS Read: %f, Write: %f\n", + ticks_to_KBPS(read_total_time, fsize), + ticks_to_KBPS(write_total_time, fsize)); } void main_tile0(chanend_t xscope_chan) @@ -63,3 +61,11 @@ void main_tile0(chanend_t xscope_chan) do_test(); xscope_close_all_files(); } + +int main(){ + chanend_t xscope_chan = chanend_alloc(); + xscope_io_init(xscope_chan); + main_tile0(xscope_chan); + chanend_free(xscope_chan); + return 0; +} diff --git a/examples/throughput_c/main.xc b/examples/throughput_c/main.xc deleted file mode 100644 index d6ef713..0000000 --- a/examples/throughput_c/main.xc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2021-2024 XMOS LIMITED. -// This Software is subject to the terms of the XMOS Public Licence: Version 1. -#include -#include -#include - -extern "C" { -void main_tile0(chanend); -} - -int main (void) -{ - chan xscope_chan; - par - { - xscope_host_data(xscope_chan); - on tile[0]: main_tile0(xscope_chan); - } - return 0; -} - diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..a5ed0a2 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.21) +include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) +project(xscope_fileio_tests) +add_subdirectory(no_hang) +add_subdirectory(close_files) diff --git a/tests/close_files/CMakeLists.txt b/tests/close_files/CMakeLists.txt index 60478f8..b91a8d6 100644 --- a/tests/close_files/CMakeLists.txt +++ b/tests/close_files/CMakeLists.txt @@ -3,7 +3,7 @@ include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(xscope_fileio_close) # sandbox -set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) +set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) message("XMOS_SANDBOX_DIR: ${XMOS_SANDBOX_DIR}") # target diff --git a/tests/no_hang/CMakeLists.txt b/tests/no_hang/CMakeLists.txt index e71728e..e67db1d 100644 --- a/tests/no_hang/CMakeLists.txt +++ b/tests/no_hang/CMakeLists.txt @@ -3,7 +3,7 @@ include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake) project(no_hang) # sandbox -set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) +set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) message("XMOS_SANDBOX_DIR: ${XMOS_SANDBOX_DIR}") # target