Skip to content

Commit

Permalink
👷 Build also for Windows
Browse files Browse the repository at this point in the history
Also add build as release target in CI
  • Loading branch information
arthurlm committed Nov 29, 2023
1 parent 8d0acfd commit cd40648
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 15 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ env:
CARGO_TERM_COLOR: always

jobs:
test:
runs-on: ubuntu-latest
build_and_test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-lastest, windows-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: Swatinem/rust-cache@v2
- name: Build
- name: Build debug
run: cargo build --verbose
- name: Build release
run: cargo build --verbose --release
- name: Run tests no default features
run: cargo test --no-default-features
- name: Run tests
Expand Down
18 changes: 16 additions & 2 deletions quickfix-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,24 @@ fn main() {
"cargo:rustc-link-search=native={}/lib",
quickfix_bind_dst.display()
);
println!("cargo:rustc-link-lib=static=quickfix");

if matches!(env::var("PROFILE").as_deref(), Ok("debug"))
&& matches!(env::var("CARGO_CFG_TARGET_OS").as_deref(), Ok("windows"))
{
// libquickfix as a different name on windows with debug profile.
println!("cargo:rustc-link-lib=static=quickfixd");
} else {
println!("cargo:rustc-link-lib=static=quickfix");
}

println!("cargo:rustc-link-lib=static=quickfixbind");
println!("cargo:rustc-link-lib=stdc++");

// Lib std C++ is only available on UNIX platform.
if env::var("CARGO_CFG_UNIX").is_ok() {
println!("cargo:rustc-link-lib=stdc++");
}

// Link with external libraries if needed.
if have_feature("build-with-mysql") {
println!("cargo:rustc-link-lib=mysqlclient");
}
Expand Down
2 changes: 1 addition & 1 deletion quickfix-ffi/libquickfix
9 changes: 8 additions & 1 deletion quickfix-ffi/quickfix-bind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ include_directories(include)
add_library(quickfixbind STATIC
src/quickfix_bind.cpp
)
target_link_libraries(quickfixbind ${MYSQL_CLIENT_LIBS} ${PostgreSQL_LIBRARIES} quickfix)
target_link_libraries(quickfixbind ${MYSQL_CLIENT_LIBS} ${PostgreSQL_LIBRARIES})

if (WIN32)
target_link_libraries(quickfixbind debug quickfixd)
target_link_libraries(quickfixbind optimized quickfix)
else()
target_link_libraries(quickfixbind quickfix)
endif()

# Add option if asked
if (WITH_PRINT_EX_STDOUT)
Expand Down
2 changes: 1 addition & 1 deletion quickfix-ffi/quickfix-bind/include/quickfix_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ FixMessage_t *FixMessage_fromStringAndDictionary(const char *text, const FixData
const char *FixMessage_getField(const FixMessage_t *obj, int32_t tag);
int8_t FixMessage_setField(FixMessage_t *obj, int32_t tag, const char *value);
int8_t FixMessage_removeField(FixMessage_t *obj, int32_t tag);
int8_t FixMessage_toBuffer(const FixMessage_t *obj, char *buffer, size_t length);
int8_t FixMessage_toBuffer(const FixMessage_t *obj, char *buffer, uint64_t length);
void FixMessage_delete(const FixMessage_t *obj);

FixHeader_t *FixMessage_copyHeader(const FixMessage_t *obj);
Expand Down
2 changes: 1 addition & 1 deletion quickfix-ffi/quickfix-bind/src/quickfix_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ int8_t FixMessage_removeField(Message *obj, int32_t tag) {
});
}

int8_t FixMessage_toBuffer(const Message *obj, char *buffer, size_t length) {
int8_t FixMessage_toBuffer(const Message *obj, char *buffer, uint64_t length) {
if (length == 0)
return 0;

Expand Down
6 changes: 1 addition & 5 deletions quickfix-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,7 @@ extern "C" {
pub fn FixMessage_removeField(obj: FixMessage_t, tag: i32) -> i8;

#[must_use]
pub fn FixMessage_toBuffer(
obj: FixMessage_t,
buffer: *mut ffi::c_char,
length: ffi::c_long,
) -> i8;
pub fn FixMessage_toBuffer(obj: FixMessage_t, buffer: *mut ffi::c_char, length: u64) -> i8;
pub fn FixMessage_delete(obj: FixMessage_t);

// Header
Expand Down
2 changes: 1 addition & 1 deletion quickfix/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Message {
pub fn as_string_with_len(&self, max_len: usize) -> Result<String, QuickFixError> {
let mut buffer = vec![0_u8; max_len];
let buffer_ptr = buffer.as_mut_ptr() as *mut i8;
match unsafe { FixMessage_toBuffer(self.0, buffer_ptr, max_len as i64) } {
match unsafe { FixMessage_toBuffer(self.0, buffer_ptr, max_len as u64) } {
0 => Ok(read_buffer_to_string(&buffer)),
code => Err(QuickFixError::InvalidFunctionReturnCode(code)),
}
Expand Down

0 comments on commit cd40648

Please sign in to comment.