diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e6eae9f..6b00285 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,14 +21,24 @@ jobs: msbuild getopt.sln /p:Configuration=Release /p:Platform=Win32 msbuild getopt.sln /p:Configuration=Release /p:Platform=x64 - windows-clang: + windows-conan: runs-on: windows-2025 + strategy: + matrix: + profile: [ windows-clang, windows-msvc ] steps: - uses: actions/checkout@v4 + - name: Install Conan + run: | + pip install conan==2.18.1 + conan --version - name: Build getopt shell: cmd run: | - mkdir build - cd build - cmake .. -G Ninja -DCMAKE_C_COMPILER="C:\Program Files\LLVM\bin\clang.exe" -DBUILD_SHARED_LIBS=YES - cmake --build . + conan create . --profile:a=${{ matrix.profile }} + - name: Upload Conan packages to Cloudsmith + run: | + conan remote add cloudsmith https://conan.cloudsmith.io/qmfrederik/gnustep/ + conan remote login -p ${{ secrets.CLOUDSMITH_API_KEY }} cloudsmith ${{ secrets.CLOUDSMITH_USER }} + conan upload getopt/* --confirm -r cloudsmith + if: ${{ github.ref == 'refs/heads/master' }} diff --git a/README.md b/README.md index d294ae4..ce837cc 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ -getopt port for Visual C++ -========================== +getopt port for Windows +======================= -[![Build status](https://ci.appveyor.com/api/projects/status/reb7dt6x7jdn1700/branch/master?svg=true)](https://ci.appveyor.com/project/qmfrederik/getopt/branch/master) - -This repository contains a port of getopt which can be used with Visual C++. It is intended to be used with vcpkg. +This repository contains a port of getopt which can be used with Visual C++ and clang on Windows. It is intended to be used with vcpkg and Conan. The Visual C++ port was originally done by Ludvik Jerabek, and described in the [Full getopt Port for Unicode and Multibyte Microsoft Visual C, C++, or MFC Projects](https://www.codeproject.com/Articles/157001/Full-getopt-Port-for-Unicode-and-Multibyte-Microso/) article. This repository contains a copy of that code and the article. \ No newline at end of file diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..7443856 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,42 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps + +class helloRecipe(ConanFile): + name = "getopt" + version = "0.1" + + # Optional metadata + license = "LGPL-3.0" + author = "Frederik Carlier " + url = "https://github.com/libimobiledevice-win32/getopt" + description = "getopt for vcpkg" + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + # Sources are located in the same place as this recipe, copy them to the recipe + exports_sources = "CMakeLists.txt", "getopt.*" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def layout(self): + cmake_layout(self) + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() \ No newline at end of file diff --git a/windows-clang b/windows-clang new file mode 100644 index 0000000..e7c2f8a --- /dev/null +++ b/windows-clang @@ -0,0 +1,20 @@ +[buildenv] +PATH=+(path)C:\Program Files\LLVM\bin + +[settings] +arch=x86_64 +build_type=Release +os=Windows + +compiler=clang +compiler.cppstd=17 +compiler.runtime=dynamic +compiler.version=20 +compiler.runtime_version=v144 + +[options] +*:shared=True + +[conf] +tools.cmake.cmaketoolchain:generator=Ninja +tools.build:compiler_executables = {"c": "clang", "cpp": "clang++"} diff --git a/windows-msvc b/windows-msvc new file mode 100644 index 0000000..170ee4a --- /dev/null +++ b/windows-msvc @@ -0,0 +1,17 @@ +[settings] +arch=x86_64 +build_type=Release +os=Windows + +compiler=msvc +compiler.cppstd=14 +compiler.runtime=msvc +compiler.version=194 +compiler.runtime=dynamic +compiler.runtime_type=Release + +[options] +*:shared=True + +[conf] +tools.cmake.cmaketoolchain:generator=Ninja