From c6cd5ce25a5be6010547e365b5ec4cd154ad57e7 Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 13:18:57 -0400 Subject: [PATCH 01/26] Add CircleCI README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d09b8a0..38fb3e0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ NFHTTP -[![Build Status](https://api.travis-ci.org/spotify/NFHTTP.svg)](https://travis-ci.org/spotify/NFHTTP) +[![CircleCI](https://circleci.com/gh/spotify/NFHTTP/tree/master.svg?style=svg)](https://circleci.com/gh/spotify/NFHTTP/tree/master) [![License](https://img.shields.io/github/license/spotify/NFHTTP.svg)](LICENSE) [![Spotify FOSS Slack](https://slackin.spotify.com/badge.svg)](https://slackin.spotify.com) [![Readme Score](http://readme-score-api.herokuapp.com/score.svg?url=https://github.com/spotify/nfhttp)](http://clayallsopp.github.io/readme-score?url=https://github.com/spotify/nfhttp) From 22c51ee68a26bdffa7c46de4db32140c57e3dd49 Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 13:23:45 -0400 Subject: [PATCH 02/26] Add Windows Build --- appveyor.yml | 9 +++++++ ci/windows.ps1 | 48 ++++++++++++++++++++++----------- ci/windows.py | 72 +++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 103 insertions(+), 26 deletions(-) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..d23ceb1 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,9 @@ +image: +- Visual Studio 2017 + +build_script: +- ps: ci/windows.ps1 + +artifacts: + - path: build/output/libNFHTTP.zip + name: libNFHTTP.zip diff --git a/ci/windows.ps1 b/ci/windows.ps1 index 0467858..ad2a029 100644 --- a/ci/windows.ps1 +++ b/ci/windows.ps1 @@ -1,3 +1,23 @@ +<# + * Copyright (c) 2018 Spotify AB. + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + #> param ( [string]$build = "windows" ) @@ -5,38 +25,34 @@ param ( Write-Host "NFHTTP build process starting..." Write-Host $build -$ErrorActionPreference = "Stop" - try { - # Get python version - $python_version = python --version - Write-Host $python_version + # Upgrade pip or else the CI will complain + c:\python27\python.exe -m pip install --upgrade pip # Start virtualenv - $virtualenv_vulcan_output = python tools/vulcan/bin/vulcan.py -v -f tools/virtualenv.vulcan -p virtualenv-15.1.0 - $virtualenv_bin = Join-Path $virtualenv_vulcan_output /virtualenv-15.1.0/virtualenv.py - python $virtualenv_bin nfdriver_env + pip install virtualenv + virtualenv nfhttp_env - & ./nfdriver_env/Scripts/activate.bat + & ./nfhttp_env/Scripts/activate.bat # Install Python Packages - & nfdriver_env/Scripts/pip.exe install urllib3 - & nfdriver_env/Scripts/pip.exe install pyyaml - & nfdriver_env/Scripts/pip.exe install flake8 - & nfdriver_env/Scripts/pip.exe install cmakelint + & nfhttp_env/Scripts/pip.exe install urllib3 ` + pyyaml ` + flake8 ` + cmakelint if($build -eq "android"){ - & nfdriver_env/Scripts/python.exe ci/androidwindows.py + & nfhttp_env/Scripts/python.exe ci/androidwindows.py } else { - & nfdriver_env/Scripts/python.exe ci/windows.py + & nfhttp_env/Scripts/python.exe ci/windows.py build } if($LASTEXITCODE -ne 0){ exit $LASTEXITCODE } - & ./nfdriver_env/Scripts/deactivate.bat + & ./nfhttp_env/Scripts/deactivate.bat } catch { diff --git a/ci/windows.py b/ci/windows.py index a027b15..27016a1 100644 --- a/ci/windows.py +++ b/ci/windows.py @@ -1,24 +1,76 @@ #!/usr/bin/env python +''' + * Copyright (c) 2018 Spotify AB. + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +''' import sys from nfbuildwindows import NFBuildWindows +from build_options import BuildOptions def main(): + buildOptions = BuildOptions() + buildOptions.addOption("installDependencies", "Install dependencies") + buildOptions.addOption("makeBuildDirectory", + "Wipe existing build directory") + buildOptions.addOption("generateProject", "Regenerate project") + buildOptions.addOption("buildTargetCLI", + "Build Target: CLI") + buildOptions.addOption("buildTargetLibrary", "Build Target: Library") + buildOptions.addOption("packageArtifacts", "Package the binary artifacts") + buildOptions.setDefaultWorkflow("Empty workflow", []) + + buildOptions.addWorkflow("build", "Production Build", [ + 'installDependencies', + 'makeBuildDirectory', + 'generateProject', + 'buildTargetCLI', + 'buildTargetLibrary', + 'packageArtifacts' + ]) + + options = buildOptions.parseArgs() + buildOptions.verbosePrintBuildOptions(options) + library_target = 'NFHTTP' cli_target = 'NFHTTPCLI' nfbuild = NFBuildWindows() - nfbuild.build_print("Installing Dependencies") - nfbuild.installDependencies() - # Make our main build artifacts - nfbuild.build_print("C++ Build Start (x86)") - nfbuild.makeBuildDirectory() - nfbuild.generateProject() - targets = [library_target, cli_target] - for target in targets: - nfbuild.buildTarget(target) - # nfbuild.runIntegrationTests() + + if buildOptions.checkOption(options, 'installDependencies'): + nfbuild.installDependencies() + + if buildOptions.checkOption(options, 'makeBuildDirectory'): + nfbuild.makeBuildDirectory() + + if buildOptions.checkOption(options, 'generateProject'): + nfbuild.generateProject(ios=True) + + if buildOptions.checkOption(options, 'buildTargetLibrary'): + nfbuild.buildTarget(library_target) + + if buildOptions.checkOption(options, 'buildTargetCLI'): + nfbuild.buildTarget(cli_target) + + if buildOptions.checkOption(options, "packageArtifacts"): + nfbuild.packageArtifacts() if __name__ == "__main__": From 9fc3a3af9d69360b6a64bae140fa1ed04fe89588 Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 13:27:24 -0400 Subject: [PATCH 03/26] Add AppVeyor badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 38fb3e0..8610b2e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ NFHTTP [![CircleCI](https://circleci.com/gh/spotify/NFHTTP/tree/master.svg?style=svg)](https://circleci.com/gh/spotify/NFHTTP/tree/master) +[![Build status](https://ci.appveyor.com/api/projects/status/57i0pfle7okccm3q/branch/master?svg=true)](https://ci.appveyor.com/project/8W9aG/nfhttp/branch/master) [![License](https://img.shields.io/github/license/spotify/NFHTTP.svg)](LICENSE) [![Spotify FOSS Slack](https://slackin.spotify.com/badge.svg)](https://slackin.spotify.com) [![Readme Score](http://readme-score-api.herokuapp.com/score.svg?url=https://github.com/spotify/nfhttp)](http://clayallsopp.github.io/readme-score?url=https://github.com/spotify/nfhttp) From d3e78fdbfb09c5007b74a9d060f52712183c837a Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 13:30:42 -0400 Subject: [PATCH 04/26] Remove installing dependencies --- ci/windows.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ci/windows.py b/ci/windows.py index 27016a1..90d5511 100644 --- a/ci/windows.py +++ b/ci/windows.py @@ -28,7 +28,6 @@ def main(): buildOptions = BuildOptions() - buildOptions.addOption("installDependencies", "Install dependencies") buildOptions.addOption("makeBuildDirectory", "Wipe existing build directory") buildOptions.addOption("generateProject", "Regenerate project") @@ -39,7 +38,6 @@ def main(): buildOptions.setDefaultWorkflow("Empty workflow", []) buildOptions.addWorkflow("build", "Production Build", [ - 'installDependencies', 'makeBuildDirectory', 'generateProject', 'buildTargetCLI', @@ -54,9 +52,6 @@ def main(): cli_target = 'NFHTTPCLI' nfbuild = NFBuildWindows() - if buildOptions.checkOption(options, 'installDependencies'): - nfbuild.installDependencies() - if buildOptions.checkOption(options, 'makeBuildDirectory'): nfbuild.makeBuildDirectory() From 851037d3f80fda9288ce71c4366dbeeb4952d434 Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 13:36:45 -0400 Subject: [PATCH 05/26] Add cmake binary --- ci/nfbuildwindows.py | 130 ++++++++----------------------------------- 1 file changed, 24 insertions(+), 106 deletions(-) diff --git a/ci/nfbuildwindows.py b/ci/nfbuildwindows.py index 0999e17..c6321dc 100644 --- a/ci/nfbuildwindows.py +++ b/ci/nfbuildwindows.py @@ -17,104 +17,8 @@ class NFBuildWindows(NFBuild): def __init__(self): super(self.__class__, self).__init__() self.project_file = 'build.ninja' - - def installClangFormat(self): - clang_format_vulcan_file = os.path.join('tools', 'clang-format.vulcan') - clang_format_extraction_folder = self.vulcanDownload( - clang_format_vulcan_file, - 'clang-format-5.0.0') - self.clang_format_binary = os.path.join( - os.path.join( - os.path.join( - clang_format_extraction_folder, - 'clang-format'), - 'bin'), - 'clang-format') - - def installNinja(self): - ninja_vulcan_file = os.path.join( - os.path.join( - os.path.join( - os.path.join('tools', 'buildtools'), - 'spotify_buildtools'), - 'software'), - 'ninja.vulcan') - ninja_extraction_folder = self.vulcanDownload( - ninja_vulcan_file, - 'ninja-1.6.0') - self.ninja_binary = os.path.join( - ninja_extraction_folder, - 'ninja') - if 'PATH' not in os.environ: - os.environ['PATH'] = '' - if len(os.environ['PATH']) > 0: - os.environ['PATH'] += os.pathsep - os.environ['PATH'] += ninja_extraction_folder - - def installMake(self): - make_vulcan_file = os.path.join('tools', 'make.vulcan') - make_extraction_folder = self.vulcanDownload( - make_vulcan_file, - 'make-4.2.1') - make_bin_folder = os.path.join( - make_extraction_folder, - 'bin') - os.environ['PATH'] += os.pathsep + make_bin_folder - - def installVisualStudio(self): - vs_vulcan_file = os.path.join( - os.path.join( - os.path.join( - os.path.join('tools', 'buildtools'), - 'spotify_buildtools'), - 'software'), - 'visualstudio.vulcan') - self.vs_extraction_folder = self.vulcanDownload( - vs_vulcan_file, - 'visualstudio-2017') - sdk_version = '10.0.15063.0' - vc_tools_version = '14.10.25017' - vc_redist_version = '14.10.25008' - vc_redist_crt = 'Microsoft.VC150.CRT' - vs_root = self.vs_extraction_folder - sdk_root = os.path.join(vs_root, 'win10sdk') - vc_root = os.path.join(vs_root, 'VC') - vc_tools_root = os.path.join(vc_root, 'Tools', 'MSVC') - vc_redist_root = os.path.join(vc_root, 'Redist', 'MSVC') - os.environ['VS_ROOT'] = vs_root - os.environ['SDK_ROOT'] = sdk_root - os.environ['INCLUDE'] = os.pathsep.join([ - os.path.join(sdk_root, 'Include', sdk_version, 'um'), - os.path.join(sdk_root, 'Include', sdk_version, 'ucrt'), - os.path.join(sdk_root, 'Include', sdk_version, 'shared'), - os.path.join(sdk_root, 'Include', sdk_version, 'winrt'), - os.path.join(vc_tools_root, vc_tools_version, 'include'), - os.path.join(vc_tools_root, vc_tools_version, 'atlmfc', 'include'), - os.environ.get('INCLUDE', '')]) - os.environ['PATH'] = os.pathsep.join([ - os.path.join(sdk_root, 'bin', sdk_version, 'x86'), - os.path.join(vc_tools_root, vc_tools_version, 'bin', 'HostX64', 'x86'), - os.path.join(vc_tools_root, vc_tools_version, 'bin', 'HostX64', 'x64'), - os.path.join(vc_redist_root, vc_redist_version, 'x64', vc_redist_crt), - os.path.join(vs_root, 'SystemCRT'), - os.environ.get('PATH', '')]) - os.environ['LIB'] = os.pathsep.join([ - os.path.join(sdk_root, 'Lib', sdk_version, 'um', 'x86'), - os.path.join(sdk_root, 'Lib', sdk_version, 'ucrt', 'x86'), - os.path.join(vc_tools_root, vc_tools_version, 'lib', 'x86'), - os.path.join(vc_tools_root, vc_tools_version, 'atlmfc', 'lib', 'x86'), - os.environ.get('LIB', '')]) - os.environ['LIBPATH'] = os.pathsep.join([ - os.path.join(vc_tools_root, vc_tools_version, 'lib', 'x86', 'store', 'references'), - os.path.join(sdk_root, 'UnionMetadata', sdk_version), - os.environ.get('LIBPATH', '')]) - - def installVulcanDependencies(self, android=False): - super(self.__class__, self).installVulcanDependencies(android) - self.installClangFormat() - self.installMake() - self.installVisualStudio() - self.installNinja() + self.cmake_binary = 'cmake' + self.android = False def generateProject(self, ios=False, @@ -142,15 +46,10 @@ def generateProject(self, '-DANDROID_STL=c++_shared']) self.project_file = 'build.ninja' else: - cl_exe = os.path.join(self.vs_extraction_folder, 'VC', 'Tools', 'MSVC', '14.10.25017', 'bin', 'HostX64', 'x86', 'cl.exe').replace('\\', '/') - rc_exe = os.path.join(self.vs_extraction_folder, 'win10sdk', 'bin', '10.0.15063.0', 'x64', 'rc.exe').replace('\\', '/') - link_exe = os.path.join(self.vs_extraction_folder, 'VC', 'Tools', 'MSVC', '14.10.25017', 'bin', 'HostX64', 'x86', 'link.exe').replace('\\', '/') cmake_call.extend([ - '-DCMAKE_C_COMPILER=' + cl_exe, - '-DCMAKE_CXX_COMPILER=' + cl_exe, - '-DCMAKE_RC_COMPILER=' + rc_exe, - '-DCMAKE_LINKER=' + link_exe, - '-DWINDOWS=1']) + 'Visual Studio 15 2017 Win64', + '-DCMAKE_SYSTEM_NAME=WindowsStore', + '-DCMAKE_SYSTEM_VERSION=10.0']) cmake_result = subprocess.call(cmake_call, cwd=self.build_directory) if cmake_result != 0: sys.exit(cmake_result) @@ -192,3 +91,22 @@ def runIntegrationTests(self): if cli_result: sys.exit(cli_result) + def packageArtifacts(self): + lib_name = 'NFHTTP.lib' + cli_name = 'NFHTTPCLI.exe' + output_folder = os.path.join(self.build_directory, 'output') + artifacts_folder = os.path.join(output_folder, 'NFHTTP') + shutil.copytree('include', os.path.join(artifacts_folder, 'include')) + source_folder = os.path.join(self.build_directory, 'source') + lib_matches = self.find_file(source_folder, lib_name) + cli_matches = self.find_file(source_folder, cli_name) + shutil.copyfile(lib_matches[0], os.path.join(artifacts_folder, lib_name)) + if not self.android: + shutil.copyfile(cli_matches[0], os.path.join(artifacts_folder, cli_name)) + output_zip = os.path.join(output_folder, 'libNFHTTP.zip') + self.make_archive(artifacts_folder, output_zip) + if self.android: + final_zip_name = 'libNFHTTP-androidx86.zip' + if self.android_arm: + final_zip_name = 'libNFHTTP-androidArm64.zip' + shutil.copyfile(output_zip, final_zip_name) From d2ad217dad4b0d2a04d9b455ede73279e98c0605 Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 13:41:50 -0400 Subject: [PATCH 06/26] Fix -G windows cmake execution --- ci/nfbuildwindows.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/nfbuildwindows.py b/ci/nfbuildwindows.py index c6321dc..f59df9e 100644 --- a/ci/nfbuildwindows.py +++ b/ci/nfbuildwindows.py @@ -28,7 +28,7 @@ def generateProject(self, cmake_call = [ self.cmake_binary, '..', - '-GNinja'] + '-G'] if android or android_arm: android_abi = 'x86_64' android_toolchain_name = 'x86_64-llvm' @@ -36,6 +36,7 @@ def generateProject(self, android_abi = 'arm64-v8a' android_toolchain_name = 'arm64-llvm' cmake_call.extend([ + 'Ninja', '-DANDROID=1', '-DCMAKE_TOOLCHAIN_FILE=' + self.android_ndk_folder + '/build/cmake/android.toolchain.cmake', '-DANDROID_NDK=' + self.android_ndk_folder, From 004a1fccd2440c2b1bf10be99f2356dcbdb11d7e Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 13:56:14 -0400 Subject: [PATCH 07/26] Download boost on windows --- ci/windows.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ci/windows.ps1 b/ci/windows.ps1 index ad2a029..3b46ef9 100644 --- a/ci/windows.ps1 +++ b/ci/windows.ps1 @@ -22,6 +22,8 @@ param ( [string]$build = "windows" ) +Add-Type -AssemblyName System.IO.Compression.FileSystem + Write-Host "NFHTTP build process starting..." Write-Host $build @@ -30,6 +32,10 @@ try # Upgrade pip or else the CI will complain c:\python27\python.exe -m pip install --upgrade pip + wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.zip -OutFile boost_1_64_0.zip + [System.IO.Compression.ZipFile]::ExtractToDirectory("boost_1_64_0.zip", "boost_1_64_0") + $env:BOOST_ROOT = Join-Path $PSScriptRoot "boost_1_64_0" + # Start virtualenv pip install virtualenv virtualenv nfhttp_env From 16b9c5ba2c589c2d749eac948f823964bb025bd4 Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 14:01:53 -0400 Subject: [PATCH 08/26] Use full paths for zip extracting --- ci/windows.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ci/windows.ps1 b/ci/windows.ps1 index 3b46ef9..9181310 100644 --- a/ci/windows.ps1 +++ b/ci/windows.ps1 @@ -33,8 +33,9 @@ try c:\python27\python.exe -m pip install --upgrade pip wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.zip -OutFile boost_1_64_0.zip - [System.IO.Compression.ZipFile]::ExtractToDirectory("boost_1_64_0.zip", "boost_1_64_0") - $env:BOOST_ROOT = Join-Path $PSScriptRoot "boost_1_64_0" + $BoostFoldername = Join-Path $PSScriptRoot "boost_1_64_0" + [System.IO.Compression.ZipFile]::ExtractToDirectory(Join-Path $PSScriptRoot "boost_1_64_0.zip", $BoostFoldername) + $env:BOOST_ROOT = $BoostFoldername # Start virtualenv pip install virtualenv From f848b8c8088a76b2e450ccac94f34f67082bf4ea Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 14:03:26 -0400 Subject: [PATCH 09/26] Add boost zip name --- ci/windows.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/windows.ps1 b/ci/windows.ps1 index 9181310..7cb3413 100644 --- a/ci/windows.ps1 +++ b/ci/windows.ps1 @@ -34,7 +34,8 @@ try wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.zip -OutFile boost_1_64_0.zip $BoostFoldername = Join-Path $PSScriptRoot "boost_1_64_0" - [System.IO.Compression.ZipFile]::ExtractToDirectory(Join-Path $PSScriptRoot "boost_1_64_0.zip", $BoostFoldername) + $BoostZipname = Join-Path $PSScriptRoot "boost_1_64_0.zip" + [System.IO.Compression.ZipFile]::ExtractToDirectory($BoostZipname, $BoostFoldername) $env:BOOST_ROOT = $BoostFoldername # Start virtualenv From 95514da56196e237b85ad2ee438a1a8d54f5b60c Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 14:24:08 -0400 Subject: [PATCH 10/26] Download to boost zip --- ci/windows.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/windows.ps1 b/ci/windows.ps1 index 7cb3413..aa93a8e 100644 --- a/ci/windows.ps1 +++ b/ci/windows.ps1 @@ -32,9 +32,9 @@ try # Upgrade pip or else the CI will complain c:\python27\python.exe -m pip install --upgrade pip - wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.zip -OutFile boost_1_64_0.zip $BoostFoldername = Join-Path $PSScriptRoot "boost_1_64_0" $BoostZipname = Join-Path $PSScriptRoot "boost_1_64_0.zip" + wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.zip -OutFile $BoostZipname [System.IO.Compression.ZipFile]::ExtractToDirectory($BoostZipname, $BoostFoldername) $env:BOOST_ROOT = $BoostFoldername From 04a2922161821ead6f18fd6b18dbed6904a72cd3 Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 14:31:01 -0400 Subject: [PATCH 11/26] Add submodule updates --- ci/windows.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/windows.ps1 b/ci/windows.ps1 index aa93a8e..4a710f4 100644 --- a/ci/windows.ps1 +++ b/ci/windows.ps1 @@ -29,6 +29,8 @@ Write-Host $build try { + git submodule update --init --recursive + # Upgrade pip or else the CI will complain c:\python27\python.exe -m pip install --upgrade pip From f335750947e8d4c50a41832e57890ae70dc8e73b Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 14:43:14 -0400 Subject: [PATCH 12/26] Add git submodule to appveyor yaml --- appveyor.yml | 1 + ci/windows.ps1 | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d23ceb1..485d2ff 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,7 @@ image: - Visual Studio 2017 build_script: +- git submodule update --init --recursive - ps: ci/windows.ps1 artifacts: diff --git a/ci/windows.ps1 b/ci/windows.ps1 index 4a710f4..aa93a8e 100644 --- a/ci/windows.ps1 +++ b/ci/windows.ps1 @@ -29,8 +29,6 @@ Write-Host $build try { - git submodule update --init --recursive - # Upgrade pip or else the CI will complain c:\python27\python.exe -m pip install --upgrade pip From 495e3a2844913d354684bd1758605ed3fe4a915f Mon Sep 17 00:00:00 2001 From: sackfield Date: Tue, 28 Aug 2018 16:04:15 -0400 Subject: [PATCH 13/26] Build using msbuild.exe --- ci/nfbuildwindows.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ci/nfbuildwindows.py b/ci/nfbuildwindows.py index f59df9e..ee61fce 100644 --- a/ci/nfbuildwindows.py +++ b/ci/nfbuildwindows.py @@ -56,13 +56,20 @@ def generateProject(self, sys.exit(cmake_result) def buildTarget(self, target, sdk='macosx', arch='x86_64'): - result = subprocess.call([ - self.ninja_binary, - '-C', - self.build_directory, - '-f', - self.project_file, - target]) + result = 0 + if self.android: + result = subprocess.call([ + self.ninja_binary, + '-C', + self.build_directory, + '-f', + self.project_file, + target]) + else: + result = subprocess.call([ + 'msbuild.exe', + os.path.join(self.build_directory, 'NFHTTP.sln'), + '/t:NFHTTP;' + target]) if result != 0: sys.exit(result) From 4862b1f3f396a3726f3cfc064c225380fe3ac001 Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 18:42:15 +0000 Subject: [PATCH 14/26] Declare OS as windows RT --- libraries/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 42d5b94..36bfa02 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -17,7 +17,7 @@ # specific language governing permissions and limitations # under the License. add_library(sqlite "${CMAKE_CURRENT_SOURCE_DIR}/sqlite/sqlite3.c") -target_compile_definitions(sqlite PUBLIC -DSQLITE_THREADSAFE=2) +target_compile_definitions(sqlite PUBLIC -DSQLITE_THREADSAFE=2 -DSQLITE_OS_WINRT=1) set(BOOST_MAJOR 1) set(BOOST_MINOR 64) From 047c7d6c197b43c3697fe3226a34f6cace4b4d81 Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 18:47:41 +0000 Subject: [PATCH 15/26] Try accessing python3 in windows --- ci/windows.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/windows.ps1 b/ci/windows.ps1 index aa93a8e..b518401 100644 --- a/ci/windows.ps1 +++ b/ci/windows.ps1 @@ -30,7 +30,7 @@ Write-Host $build try { # Upgrade pip or else the CI will complain - c:\python27\python.exe -m pip install --upgrade pip + c:\python3\python.exe -m pip install --upgrade pip $BoostFoldername = Join-Path $PSScriptRoot "boost_1_64_0" $BoostZipname = Join-Path $PSScriptRoot "boost_1_64_0.zip" From c6180b6e6060186e8ec526e54228a8ea2bf83453 Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 18:54:50 +0000 Subject: [PATCH 16/26] Add NOMINMAX definition to cpprestsdk * See here for a reason why: https://stackoverflow.com/a/6884251/293895 --- libraries/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 36bfa02..da7db08 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -1107,6 +1107,6 @@ if(USE_CPPRESTSDK) set(CPPREST_INSTALL_HEADERS OFF CACHE BOOL "Don't install headers" FORCE) set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build cpprest as a static lib" FORCE) set(CPPREST_EXCLUDE_COMPRESSION ON CACHE BOOL "Exclude compression functionality." FORCE) - add_definitions(-DSSL_R_SHORT_READ) + add_definitions(-DSSL_R_SHORT_READ -DNOMINMAX) add_subdirectory(cpprestsdk/Release) endif() From c98ff490a536a8797235ba415ea20840d50d4104 Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 18:56:43 +0000 Subject: [PATCH 17/26] Revert "Try accessing python3 in windows" This reverts commit 047c7d6c197b43c3697fe3226a34f6cace4b4d81. --- ci/windows.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/windows.ps1 b/ci/windows.ps1 index b518401..aa93a8e 100644 --- a/ci/windows.ps1 +++ b/ci/windows.ps1 @@ -30,7 +30,7 @@ Write-Host $build try { # Upgrade pip or else the CI will complain - c:\python3\python.exe -m pip install --upgrade pip + c:\python27\python.exe -m pip install --upgrade pip $BoostFoldername = Join-Path $PSScriptRoot "boost_1_64_0" $BoostZipname = Join-Path $PSScriptRoot "boost_1_64_0.zip" From e33206f0285a02e385df9497878e3258b141f252 Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 19:09:59 +0000 Subject: [PATCH 18/26] Add strptime to windows --- source/CachingSQLiteDatabase.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/CachingSQLiteDatabase.cpp b/source/CachingSQLiteDatabase.cpp index 7fc6c50..b527c0b 100644 --- a/source/CachingSQLiteDatabase.cpp +++ b/source/CachingSQLiteDatabase.cpp @@ -26,6 +26,26 @@ #include #include +#if defined(_WIN32) || defined(WIN32) +extern "C" char* strptime(const char* s, + const char* f, + struct tm* tm) { + // Isn't the C++ standard lib nice? std::get_time is defined such that its + // format parameters are the exact same as strptime. Of course, we have to + // create a string stream first, and imbue it with the current C locale, and + // we also have to make sure we return the right things if it fails, or + // if it succeeds, but this is still far simpler an implementation than any + // of the versions in any of the C standard libraries. + std::istringstream input(s); + input.imbue(std::locale(setlocale(LC_ALL, nullptr))); + input >> std::get_time(tm, f); + if (input.fail()) { + return nullptr; + } + return (char*)(s + input.tellg()); +} +#endif + namespace nativeformat { namespace http { From 1f04ed0fcfe40429353fb8083b21a3101b1b652d Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 19:15:22 +0000 Subject: [PATCH 19/26] Add objbase.h include to windows cache location --- source/CacheLocationWindows.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/CacheLocationWindows.cpp b/source/CacheLocationWindows.cpp index 7cf2fcb..ab17536 100644 --- a/source/CacheLocationWindows.cpp +++ b/source/CacheLocationWindows.cpp @@ -25,6 +25,7 @@ #include #include #include +#include namespace nativeformat { namespace http { From a7b9734124efa0a343668a2041fbc8150a1c6cb9 Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 19:32:29 +0000 Subject: [PATCH 20/26] Remove CRT secure errors --- source/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index b74b577..00aa355 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -116,3 +116,7 @@ target_link_libraries(NFHTTPCLI NFHTTP nlohmann_json) if(USE_CURL) target_compile_definitions(NFHTTP PRIVATE USE_CURL=1) endif() + +if(WIN32) + target_compile_definitions(NFHTTP PRIVATE _CRT_SECURE_NO_WARNINGS) +endif() From 099a8775b9188ac3bab38d8843b0f815a83d860e Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 19:53:03 +0000 Subject: [PATCH 21/26] Ad knownfolders.h --- source/CacheLocationWindows.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/CacheLocationWindows.cpp b/source/CacheLocationWindows.cpp index ab17536..60a7518 100644 --- a/source/CacheLocationWindows.cpp +++ b/source/CacheLocationWindows.cpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace nativeformat { namespace http { From a868b17077d2acfdee25e6f1d5f41df9a796273a Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 20:11:41 +0000 Subject: [PATCH 22/26] Use WinRT to get temporary folder --- source/CacheLocationWindows.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/CacheLocationWindows.cpp b/source/CacheLocationWindows.cpp index 60a7518..09ba47c 100644 --- a/source/CacheLocationWindows.cpp +++ b/source/CacheLocationWindows.cpp @@ -33,7 +33,8 @@ namespace http { std::string standardCacheLocation() { wchar_t *localAppData = NULL; - SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &localAppData); + auto folder = Windows::Storage::ApplicationData::Current->TemporaryFolder; + wcscpy_s(localAppData, maxsize, folder->Path->Data()); std::stringstream ss; ss << localAppData << "/NativeFormat/"; CreateDirectory(ss.str().c_str(), NULL); From 3703f516a5c675b4e29a9c0146ecb9ed68c1536b Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 20:16:39 +0000 Subject: [PATCH 23/26] Add client.h --- source/CacheLocationWindows.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/CacheLocationWindows.cpp b/source/CacheLocationWindows.cpp index 09ba47c..8964d9b 100644 --- a/source/CacheLocationWindows.cpp +++ b/source/CacheLocationWindows.cpp @@ -27,6 +27,7 @@ #include #include #include +#include namespace nativeformat { namespace http { From b7efa7289d55f521cfb324c2356b21e38af41a3a Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 20:32:30 +0000 Subject: [PATCH 24/26] Add windows flags to CXX --- CMakeLists.txt | 1 + source/CacheLocationWindows.cpp | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 739edeb..4cf9ef9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,6 +111,7 @@ if(WIN32) # TODO fix and use windows flags set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WINDOWS_LINKER_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WINDOWS_FLAGS}") endif() set(OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/output") diff --git a/source/CacheLocationWindows.cpp b/source/CacheLocationWindows.cpp index 8964d9b..7cf2fcb 100644 --- a/source/CacheLocationWindows.cpp +++ b/source/CacheLocationWindows.cpp @@ -25,17 +25,13 @@ #include #include #include -#include -#include -#include namespace nativeformat { namespace http { std::string standardCacheLocation() { wchar_t *localAppData = NULL; - auto folder = Windows::Storage::ApplicationData::Current->TemporaryFolder; - wcscpy_s(localAppData, maxsize, folder->Path->Data()); + SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &localAppData); std::stringstream ss; ss << localAppData << "/NativeFormat/"; CreateDirectory(ss.str().c_str(), NULL); From 0d597f4eae6148e193621bec08b5926d1c2c6075 Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 20:39:19 +0000 Subject: [PATCH 25/26] Add Knownfolders.h --- source/CacheLocationWindows.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/CacheLocationWindows.cpp b/source/CacheLocationWindows.cpp index 7cf2fcb..fde6bae 100644 --- a/source/CacheLocationWindows.cpp +++ b/source/CacheLocationWindows.cpp @@ -25,6 +25,7 @@ #include #include #include +#include namespace nativeformat { namespace http { From 44dab06261d864d66db7ebddf453b4146cfc26ca Mon Sep 17 00:00:00 2001 From: Will Sackfield Date: Fri, 19 Feb 2021 20:45:10 +0000 Subject: [PATCH 26/26] Add objbase.h --- source/CacheLocationWindows.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/CacheLocationWindows.cpp b/source/CacheLocationWindows.cpp index fde6bae..96b0214 100644 --- a/source/CacheLocationWindows.cpp +++ b/source/CacheLocationWindows.cpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace nativeformat { namespace http {