Skip to content

Commit

Permalink
Merge pull request #31 from dsm/develop
Browse files Browse the repository at this point in the history
added native windows mingw build.
  • Loading branch information
ra3xdh authored Dec 5, 2024
2 parents 0d603ec + c50525f commit 81b4f81
Show file tree
Hide file tree
Showing 29 changed files with 194 additions and 74 deletions.
93 changes: 73 additions & 20 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,83 @@ name: windows
on:
push:
branches: [ "develop", "release/*" ]
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches: [ "develop", "release/*" ]
workflow_dispatch:

env:
BUILD_TYPE: Release

jobs:
build:
setup:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.read_version.outputs.version }}
short_hash: ${{ steps.read_version.outputs.short_hash }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Read version from file
id: read_version
run: |
if [ "${{ github.ref_type }}" == "tag" ]; then
VERSION=${{ github.ref_name }}
SHORT_HASH=""
else
MAJOR_MINOR=$(cut -d. -f1-2 VERSION)
VERSION="${MAJOR_MINOR}.99"
# Get the short hash of the current commit
COMMIT_HASH=$(echo ${{ github.sha }} | cut -c1-7)
SHORT_HASH="-$COMMIT_HASH"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "SHORT_HASH=$SHORT_HASH" >> $GITHUB_ENV
echo "short_hash=$SHORT_HASH" >> $GITHUB_OUTPUT
- name: Print version and hash
run: |
echo "Qucs-S version is ${{ env.VERSION }}"
echo "Qucs-S short hash is ${{ env.SHORT_HASH }}"
build-windows:
runs-on: windows-latest
needs: setup
strategy:
fail-fast: false
steps:
- name: Disable autocrlf
shell: pwsh
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout repository
uses: actions/checkout@v4
- name: Install gperf using Chocolatey
shell: pwsh
run: |
choco install gperf winflexbison3 -y
- name: '⚙️ Install CMake'
uses: lukka/get-cmake@latest

- name: Build with cmake
shell: pwsh
run: |
cmake.exe -B build/ -G "Ninja" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake.exe --build build/ --parallel --config ${{env.BUILD_TYPE}}
build-windows-msys2:
runs-on: windows-latest
needs: setup
strategy:
fail-fast: false
matrix:
sys:
- mingw64
- clang64
- ucrt64
defaults:
run:
shell: msys2 {0}
Expand All @@ -28,29 +89,21 @@ jobs:
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
msystem: ucrt64
cache: true
update: true
install: >-
bison
flex
dos2unix
pacboy: >-
cmake:p
gcc:p
make:p
python:p
gperf:p
install: bison flex dos2unix zip p7zip
pacboy: cmake:p gcc:p make:p ninja:p gperf:p

- name: Build with cmake
run: |
ls -la
cmake.exe -B build/ -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake.exe --build build/ -j`nproc` --config ${{env.BUILD_TYPE}}
cmake.exe -B build/ -G "Ninja" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake.exe --build build/ --parallel --config ${{env.BUILD_TYPE}}
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,6 @@ else() # Linux, OSX

endif()

#
# Check for sed
#
find_program(SED_TOOL NAMES sed)
if(NOT SED_TOOL)
message(FATAL_ERROR "Unable to find sed")
else()
message(STATUS "Found sed: " ${SED_TOOL})
endif()

#
# Check for gperf
#
Expand Down
28 changes: 14 additions & 14 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ include_directories(
${qucs-core_BINARY_DIR}/src/components # generated verilog/[].core.h
)

add_executable(repl_reg repl_reg.cpp)
IF(WIN32)
SET(repl_reg_exe repl_reg.exe)
ELSE() # Unix
SET(repl_reg_exe repl_reg)
ENDIF()
#
# Replace 'evaluate::[whatever]' by NULL
#
Expand All @@ -220,22 +226,16 @@ include_directories(
#
add_custom_command(
OUTPUT gperfappgen.h
COMMAND
${SED_TOOL} -e 's/evaluate::[a-zA-Z0-9_]*/NULL/g' <
${CMAKE_CURRENT_SOURCE_DIR}/applications.h >
${CMAKE_CURRENT_BINARY_DIR}/gperfappgen.h
DEPENDS ${applications.h})
COMMAND ${repl_reg_exe} ${CMAKE_CURRENT_SOURCE_DIR}/applications.h ${CMAKE_CURRENT_BINARY_DIR}/gperfappgen.h 0
DEPENDS ${repl_reg_exe} ${applications.h} )

#
# Compile gperfappgen * used to generate gperf input file (used in qucsator)
#
set(gperf_SRC gperfappgen.cpp gperfappgen.h)

IF(WIN32)
add_executable(gperfappgen.exe ${gperf_SRC})
ELSE() # Unix
add_executable(gperfappgen ${gperf_SRC})
ENDIF()
add_executable(gperfappgen ${gperf_SRC})

#
# Run gperfappgen, pipe to gperf input to gperfapphash.gph
#
Expand All @@ -244,10 +244,11 @@ IF(WIN32)
ELSE() # Unix
SET(gperfappgen_exe gperfappgen)
ENDIF()

add_custom_command(
OUTPUT gperfapphash.gph
COMMAND ${gperfappgen_exe} > ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.gph && dos2unix ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.gph
DEPENDS ${gperfappgen})
DEPENDS ${gperfappgen_exe})

#
# Run gperf, create hash table. * -I, Include the necessary system include files
Expand All @@ -258,9 +259,8 @@ add_custom_command(
OUTPUT gperfapphash.cpp
COMMAND ${GPERF_TOOL} -I -m 8 ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.gph >
temp.gperf
COMMAND ${SED_TOOL} -e 's/{""},/{"",0},/g' < temp.gperf >
${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.cpp
DEPENDS gperfapphash.gph)
COMMAND ${repl_reg_exe} temp.gperf ${CMAKE_CURRENT_BINARY_DIR}/gperfapphash.cpp 1
DEPENDS gperfapphash.gph ${repl_reg_exe})

# target <- source (includea) equation.cpp: gperfapphash.cpp
#
Expand Down
2 changes: 1 addition & 1 deletion src/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#endif


#if defined(_WIN32) & not defined(__MINGW32__)
#if defined(_WIN32) && defined(_MSC_VER)
#define strcasecmp stricmp
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/converter/check_spice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <float.h>
#include <ctype.h>

#if defined(_WIN32) & not defined(__MINGW32__)
#if defined(_WIN32) && defined(_MSC_VER)
#define strcasecmp stricmp
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/converter/csv_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct csv_data {
};

/* Definition of line separator. */
#ifdef __MINGW32__
#ifdef _WIN32
#define csv_crlf "\n"
#else
#define csv_crlf "\r\n"
Expand Down
4 changes: 2 additions & 2 deletions src/converter/parse_spice.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <string.h>
#include <ctype.h>

#if defined(_WIN32) & not defined(__MINGW32__)
#if defined(_WIN32) && defined(_MSC_VER)
#define strcasecmp stricmp
#endif

Expand Down Expand Up @@ -128,7 +128,7 @@ static struct value_t * spice_append_val_values (struct value_t * values,

%}

%name-prefix "spice_"
%define api.prefix {spice_}

%token TitleLine InvalidCharacter End Eol
%token Identifier Digits Floats Nodes Options Function
Expand Down
2 changes: 1 addition & 1 deletion src/converter/parse_vcd.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

%}

%name-prefix "vcd_"
%define api.prefix {vcd_}

%token t_END
%token t_COMMENT
Expand Down
2 changes: 1 addition & 1 deletion src/converter/scan_spice.lpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <string.h>
#include <ctype.h>

#ifdef __MINGW32__
#ifdef _WIN32
#include <io.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/converter/scan_vcd.lpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <string.h>
#include <ctype.h>

#ifdef __MINGW32__
#ifdef _WIN32
#include <io.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/converter/touchstone_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct touchstone_data_t {
touchstone_data;

/* Definition of line separator. */
#ifdef __MINGW32__
#ifdef _WIN32
#define touchstone_crlf "\n"
#else
#define touchstone_crlf "\r\n"
Expand Down
3 changes: 2 additions & 1 deletion src/math/real.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ nr_double_t inline real (const nr_double_t r) {
\param[in] r Real number
\return Imaginary part of r
*/
nr_double_t inline imag ([[maybe_unused]] const nr_double_t r) {
nr_double_t inline imag (const nr_double_t r) {
(void) r;
return 0.0;
}

Expand Down
10 changes: 5 additions & 5 deletions src/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "netdefs.h"
#include "module.h"

#ifdef __MINGW32__
#ifdef _WIN32
#include <windows.h>
#else
#include <dlfcn.h>
Expand All @@ -57,7 +57,7 @@ std::map< std::string, creator_t *, std::less<std::string> > factorycreate;
// factorydef hold the loaded modules definitions
std::map< std::string, defs_t *, std::less<std::string> > factorydef;

#if __MINGW32__
#if _WIN32
std::list<HINSTANCE> dl_list; // list to hold handles for dynamic libs
std::list<HINSTANCE>::iterator itr;
#else
Expand Down Expand Up @@ -467,14 +467,14 @@ void module::registerDynamicModules (char *proj, std::list<std::string> modlist)
#ifdef __linux__
absPathLib = absPathLib + "/" + *it + ".so";
#endif
#ifdef __MINGW32__
#ifdef _WIN32
absPathLib = absPathLib + "\\" + *it + ".dll";
#endif

// which lib is going to be loaded
fprintf( stdout, "try loading %s\n", absPathLib.c_str() );

#if __MINGW32__
#if _WIN32
// Load the DLL
HINSTANCE dlib = ::LoadLibrary(TEXT(absPathLib.c_str()));
if (!dlib) {
Expand Down Expand Up @@ -551,7 +551,7 @@ void module::registerDynamicModules (char *proj, std::list<std::string> modlist)
void module::closeDynamicLibs()
{
for(itr=dl_list.begin(); itr!=dl_list.end(); itr++){
#if __MINGW32__
#if _WIN32
FreeLibrary(*itr);
#else
dlclose(*itr);
Expand Down
2 changes: 1 addition & 1 deletion src/parse_citi.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using namespace qucs;

%}

%name-prefix "citi_"
%define api.prefix {citi_}

%token InvalidCharacter
%token Float
Expand Down
2 changes: 1 addition & 1 deletion src/parse_csv.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using namespace qucs;

%}

%name-prefix "csv_"
%define api.prefix {csv_}

%token InvalidCharacter
%token Float
Expand Down
2 changes: 1 addition & 1 deletion src/parse_dataset.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using namespace qucs;

%}

%name-prefix "dataset_"
%define api.prefix {dataset_}

%token InvalidCharacter
%token Identifier
Expand Down
2 changes: 1 addition & 1 deletion src/parse_mdl.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using namespace qucs;

%}

%name-prefix "mdl_"
%define api.prefix {mdl_}

%token LINK
%token Identifier
Expand Down
2 changes: 1 addition & 1 deletion src/parse_netlist.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ using namespace qucs;

%}

%name-prefix "netlist_"
%define api.prefix {netlist_}

%token InvalidCharacter
%token Identifier
Expand Down
2 changes: 1 addition & 1 deletion src/parse_touchstone.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using namespace qucs;

%}

%name-prefix "touchstone_"
%define api.prefix {touchstone_}

%token InvalidCharacter
%token Float
Expand Down
Loading

0 comments on commit 81b4f81

Please sign in to comment.