diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 28ef5e005..1ab455a26 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -78,13 +78,26 @@ def presetFlags = [ def anyFailure = false def gitClone() { + /* Read git tag from environment or set the default one. */ if (env.GIT_COMMIT == null) env.GIT_COMMIT = 'master' println "[-] Using git tag [${env.GIT_COMMIT}]" - def scmVars = checkout scm: [$class: 'GitSCM', - branches: [[name: env.GIT_COMMIT]], - userRemoteConfigs: [[url: 'https://github.com/86Box/86Box.git']]] - env.GIT_COMMIT = scmVars.GIT_COMMIT + + /* Use stashes to avoid performing multiple clones. */ + if (env.GIT_STASHED != 'true') { + /* Perform clone/checkout. */ + def scmVars = checkout scm: [$class: 'GitSCM', + branches: [[name: env.GIT_COMMIT]], + userRemoteConfigs: [[url: 'https://github.com/86Box/86Box.git']]] + env.GIT_COMMIT = scmVars.GIT_COMMIT + + /* Stash data and mark it as stashed. */ + stash name: 'git' + env.GIT_STASHED = 'true' + } else { + /* Unstash data. */ + unstash name: 'git' + } } def removeDir(dir) { @@ -98,41 +111,68 @@ def runBuild(args) { if (isUnix()) sh "chmod u+x \"$WORKSPACE/.ci/build.sh\" && exec \"$WORKSPACE/.ci/build.sh\" $args" else - bat "C:\\msys64\\msys2_shell.cmd -msys2 -defterm -here -no-start -c 'exec \"\$(cygpath -u \\'%WORKSPACE%\\')\"/.ci/build.sh $args'" + bat "C:\\msys64\\msys2_shell.cmd -msys2 -defterm -here -no-start -c 'exec \"\$(cygpath -u \\'%WORKSPACE%\\')/.ci/build.sh\" $args'" } pipeline { agent none + environment { + DISCORD_WEBHOOK_URL = credentials('discord-webhook-url') + } + + options { + disableConcurrentBuilds() + quietPeriod(0) + } + parameters { string(name: 'BUILD_TYPE', defaultValue: 'beta', /* !!! CHANGE HERE !!! for build type */ description: "Build type to pass on to CMake. Don't change this, you should instead change the default value on .ci/Jenkinsfile") } - environment { - DISCORD_WEBHOOK_URL = credentials('discord-webhook-url') - } - stages { stage('Source Tarball') { agent none steps { script { - /* Run a dummy git clone on any node to try and save the latest commit regardless of executor status. - This avoids a timing issue where HEAD changes between polling and the nodes being available below. - I talked to a few people, and we reached the conclusion that reading the polled commit from within - the pipeline is not really possible (maybe short of switching to a multi-branch pipeline), so we - have to live with this hack, which shortens but doesn't fully eliminate the timing issue's window. */ - node { - /* Ignore exceptions as this is not really critical. */ - try { - gitClone() - } catch (e) {} - try { - cleanWs() - } catch (e) {} + /* Hack to extract the current HEAD commit from this build's git polling + log. This avoids a race condition where HEAD changes in the time period + between Jenkins polling the git repository and the first build node + performing the first git clone once ready. (See issue JENKINS-20518) */ + if (env.GIT_COMMIT == null) { + /* This must run on the master node to read the polling log. */ + node('master') { + /* Ignore exceptions as this is not really critical. */ + try { + /* Switch to this build's directory. */ + dir("${env.JENKINS_HOME}/jobs/${env.JOB_NAME}/builds/${env.BUILD_NUMBER}") { + /* Parse polling log. */ + def pollingLog = readFile file: 'polling.log' + def match = pollingLog =~ /Latest remote head revision on [^ ]+ is: ([a-zA-Z0-9]+)/ + if (match && match[0]) { + env.GIT_COMMIT = match[0][1] + println "[-] Read git tag [${env.GIT_COMMIT}] from polling log" + } + } + } catch (e) {} + } + + /* If the polling log parsing fails, perform a dummy git clone on any node. + Not quite as fast as reading the polling log, but it works as a backup. */ + if (env.GIT_COMMIT == null) { + node { + /* Ignore exceptions again as this is not really critical. */ + try { + gitClone() + } catch (e) {} + try { + cleanWs() + } catch (e) {} + } + } } /* Create source tarball. */ @@ -188,12 +228,10 @@ pipeline { /* Switch to output directory. */ dir('output') { + /* Run build process. */ def packageName = "${env.JOB_BASE_NAME}${dynarecSlugs[dynarec]}${presetSlugs[preset]}-$os-$arch-b${env.BUILD_NUMBER}" - dir(dynarecNames[dynarec]) { - dir("$os - ${archNames[arch]}") { - /* Run build process. */ - runBuild("-b \"$packageName\" \"$arch\" ${presetFlags[preset]} ${dynarecFlags[dynarec]} -D \"BUILD_TYPE=$BUILD_TYPE\" -D \"EMU_BUILD=build ${env.BUILD_NUMBER}\" -D \"EMU_BUILD_NUM=${env.BUILD_NUMBER}\"") - } + dir("${dynarecNames[dynarec]}/$os - ${archNames[arch]}") { + runBuild("-b \"$packageName\" \"$arch\" ${presetFlags[preset]} ${dynarecFlags[dynarec]} -D \"BUILD_TYPE=$BUILD_TYPE\" -D \"EMU_BUILD=build ${env.BUILD_NUMBER}\" -D \"EMU_BUILD_NUM=${env.BUILD_NUMBER}\"") } /* Archive resulting artifacts. */ @@ -223,12 +261,14 @@ pipeline { post { always { script { + /* Mark build as failed if any step has failed. */ if (anyFailure) { println "[!] Failing build because a build stage failed" currentBuild.result = 'FAILURE' } - if (!env.JOB_BASE_NAME.contains("TestBuildPleaseIgnore")) { + /* Send out build notifications. */ + if (!env.JOB_BASE_NAME.contains('TestBuildPleaseIgnore')) { try { /* Notify Discord. */ def result = currentBuild.currentResult.toLowerCase() diff --git a/src/86box.c b/src/86box.c index bbb97368c..55477b849 100644 --- a/src/86box.c +++ b/src/86box.c @@ -18,6 +18,7 @@ * Copyright 2016-2020 Miran Grca. * Copyright 2017-2020 Fred N. van Kempen. * Copyright 2021 Laci bá' + * Copyright 2021 dob205 */ #include #include @@ -394,7 +395,9 @@ pc_init(int argc, char *argv[]) { char path[2048], path2[2048]; char *cfg = NULL, *p; +#ifdef __APPLE__ char mac_rom_path[2048]; +#endif char temp[128]; struct tm *info; time_t now; @@ -418,9 +421,6 @@ pc_init(int argc, char *argv[]) */ plat_getcwd(usr_path, sizeof(usr_path) - 1); plat_getcwd(rom_path, sizeof(rom_path) - 1); - - printf("JV:usr_path %s\n",usr_path); - printf("JV:rom_path %s\n",usr_path); memset(path, 0x00, sizeof(path)); memset(path2, 0x00, sizeof(path)); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b1ec7712..7e9e24e89 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,17 +32,11 @@ set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") endif() -#Adding the macOS glue for ROM paths -set(MAC_GLUE) -if (APPLE) - set(MAC_GLUE ${CMAKE_CURRENT_SOURCE_DIR}/mac/macOSXGlue.m) -endif() - # WIN32 marks us as a GUI app on Windows # MACOSX_BUNDLE prepares a macOS application bundle including with the app icon add_executable(86Box WIN32 MACOSX_BUNDLE 86box.c config.c log.c random.c timer.c io.c acpi.c apm.c dma.c ddma.c nmi.c pic.c pit.c port_6x.c port_92.c ppi.c pci.c mca.c usb.c - device.c nvr.c nvr_at.c nvr_ps2.c ${APP_ICON_MACOSX} ${MAC_GLUE}) + device.c nvr.c nvr_at.c nvr_ps2.c ${APP_ICON_MACOSX}) if(APPLE) target_link_libraries(86Box "-framework AppKit") @@ -93,10 +87,19 @@ if(MINGW) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".dll.a") endif() +# Variables introduced by richardg867 for versioning stuff +if(NOT CMAKE_PROJECT_VERSION_PATCH) + set(CMAKE_PROJECT_VERSION_PATCH 0) +endif() +if(NOT EMU_BUILD_NUM) + set(EMU_BUILD_NUM 0) +endif() +if(NOT EMU_COPYRIGHT_YEAR) + set(EMU_COPYRIGHT_YEAR 2021) +endif() + #some macOS specific configuration steps if(APPLE) - find_library(COCOA_LIBRARY Cocoa) - target_link_libraries (86Box ${COCOA_LIBRARY} ) # Force using the newest library if it's installed by homebrew set(CMAKE_FIND_FRAMEWORK LAST) @@ -104,19 +107,19 @@ if(APPLE) # prepare stuff for macOS app bundles set(CMAKE_MACOSX_BUNDLE 1) - # setting our compilation target to macOS Mojave (macOS version 10.14), can be eventually changed to macOS 10.13 High Sierra + # setting our compilation target to macOS 10.13 High Sierra set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13") # set the Info.plist properly set_target_properties(86Box PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist.in) set(MACOSX_BUNDLE_GUI_IDENTIFIER net.86Box.86Box) set(MACOSX_BUNDLE_BUNDLE_NAME 86Box) - set(MACOSX_BUNDLE_BUNDLE_VERSION 3.0) - set(MACOSX_BUNDLE_SHORT_VERSION_STRING "3.0") - set(MACOSX_BUNDLE_LONG_VERSION_STRING "3.0.0") + set(MACOSX_BUNDLE_BUNDLE_VERSION 3.0.${EMU_BUILD_NUM}) + set(MACOSX_BUNDLE_SHORT_VERSION_STRING "3.0.${EMU_BUILD_NUM}") + set(MACOSX_BUNDLE_LONG_VERSION_STRING "3.0.${EMU_BUILD_NUM}") set(MACOSX_BUNDLE_ICON_FILE 86Box.icns) set(MACOSX_BUNDLE_INFO_STRING "A emulator of old computers") - set(MACOSX_BUNDLE_COPYRIGHT "© 2007-2021 Sarah Walker, Miran Grča, Fred N. van Kempen (waltje), SA1988, MoochMcGee, reenigne, leilei, JohnElliott, greatpsycho, and others") + set(MACOSX_BUNDLE_COPYRIGHT "© 2007-${EMU_COPYRIGHT_YEAR} 86Box contributors") # preparing the code signing for easier distribution, Apple dev certificate needed at one point @@ -154,15 +157,6 @@ find_package(PNG REQUIRED) include_directories(${PNG_INCLUDE_DIRS}) target_link_libraries(86Box PNG::PNG) -if(NOT CMAKE_PROJECT_VERSION_PATCH) - set(CMAKE_PROJECT_VERSION_PATCH 0) -endif() -if(NOT EMU_BUILD_NUM) - set(EMU_BUILD_NUM 0) -endif() -if(NOT EMU_COPYRIGHT_YEAR) - set(EMU_COPYRIGHT_YEAR 2021) -endif() configure_file(include/86box/version.h.in include/86box/version.h @ONLY) include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) diff --git a/src/sound/snd_ac97_codec.c b/src/sound/snd_ac97_codec.c index b992b0e6a..ac19cdd7b 100644 --- a/src/sound/snd_ac97_codec.c +++ b/src/sound/snd_ac97_codec.c @@ -542,7 +542,7 @@ ac97_codec_init(const device_t *info) /* Associate this codec to the current controller. */ if (!ac97_codec || (ac97_codec_count <= 0)) { - fatal("AC97 Codec %d: No controller to associate codec\n", ac97_codec_id); + pclog("AC97 Codec %d: No controller to associate codec\n", ac97_codec_id); return NULL; } *ac97_codec = dev; @@ -583,6 +583,8 @@ static void ac97_codec_close(void *priv) { ac97_codec_t *dev = (ac97_codec_t *) priv; + if (!dev) + return; ac97_codec_log("AC97 Codec %d: close()\n", dev->codec_id); diff --git a/src/win/win_dynld.c b/src/win/win_dynld.c index c0f9b4488..98eb4739f 100644 --- a/src/win/win_dynld.c +++ b/src/win/win_dynld.c @@ -74,7 +74,7 @@ dynld_module(const char *name, dllimp_t *table) } /* All good. */ - pclog("loaded %s\n", name); + dynld_log("loaded %s\n", name); return((void *)h); }