This commit is contained in:
Riley 2025-05-09 21:02:52 -05:00
parent b386cd166f
commit b37ec5adf2
8 changed files with 123 additions and 6 deletions

View file

@ -0,0 +1,26 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.22621.0",
"compilerPath": "cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64",
"configurationProvider": "mesonbuild.mesonbuild",
"compileCommands": [
"${workspaceFolder}/build/meson-src/compile_commands.json"
],
"mergeConfigurations": true
}
],
"version": 4
}

View file

@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"cwd": "${workspaceRoot}",
"type": "cppvsdbg",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/build/meson-src/main.exe",
"preLaunchTask": "build",
"logging": {
"engineLogging": true,
"trace": true,
"traceResponse": true
}
}
]
}

View file

@ -0,0 +1,3 @@
{
"C_Cpp.default.configurationProvider": "mesonbuild.mesonbuild"
}

View file

@ -0,0 +1,12 @@
// filepath: c:\Users\Riley\OneDrive\Documents\Code\C\Conan-C\.vscode\tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "${workspaceFolder}/build.bat debug",
"problemMatcher": []
}
]
}

View file

@ -1,5 +1,20 @@
@echo off
setlocal enabledelayedexpansion
set DEBUG=release
if "%1" == "debug" set DEBUG=debug
conan install . --output-folder=build --build=missing
cd build
meson setup --native-file conan_meson_native.ini .. meson-src
meson setup -Dbuildtype=%DEBUG% --native-file conan_meson_native.ini .. meson-src --reconfigure
meson compile -C meson-src
meson-src\main.exe
REM Only run the executable if it exists
if exist meson-src\main.exe (
meson-src\main.exe
) else (
echo "Executable not found. Build might have failed."
)
pause

View file

@ -1,5 +1,12 @@
if [ "$1" = "debug" ]; then
BUILD_TYPE=debug
else
BUILD_TYPE=release
fi
conan install . --output-folder=build --build=missing
cd build
meson setup --native-file conan_meson_native.ini .. meson-src
meson setup --native-file conan_meson_native.ini .. meson-src -Dbuildtype=$BUILD_TYPE
meson compile -C meson-src
./meson-src/main
./meson-src/main
read -p "Press enter to continue..."

View file

@ -1,11 +1,23 @@
project('tutorial', 'c')
CC = meson.get_compiler('c')
target_name = 'main'
zlib = dependency('zlib', version : '1.2.11', static: true, required: true)
target_name = 'main'
files = files('src/main.c')
executable(target_name, files, dependencies: [zlib], include_directories: include_directories('src/include'))
if get_option('buildtype') == 'debug'
if CC.has_argument('-fsanitize=address') and CC.has_link_argument('-fsanitize=address')
add_project_arguments('-fsanitize=address', '-fno-omit-frame-pointer', language: 'c')
add_project_link_arguments('-fsanitize=address', language: 'c')
endif
add_project_arguments('-DDEBUG', language: 'c')
endif
executable(target_name, files, dependencies: [zlib], include_directories: include_directories('src/include'))

View file

@ -1,9 +1,22 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#elif __linux__ || __APPLE__
#include <unistd.h>
#endif
#include <zlib.h>
void sleep_ms(int milliseconds) {
#ifdef _WIN32
Sleep(milliseconds);
#elif __linux__ || __APPLE__
usleep(milliseconds * 1000); // Convert milliseconds to microseconds
#endif
}
int main(void) {
char buffer_in [256] = {"Conan is a MIT-licensed, Open Source package manager for C and C++ development "
"for C and C++ development, allowing development teams to easily and efficiently "
@ -23,6 +36,12 @@ int main(void) {
deflate(&defstream, Z_FINISH);
deflateEnd(&defstream);
unsigned long long compressed_size = sizeof(buffer_out) - defstream.avail_out;
int x = 1-1;
printf("Uncompressed size is: %lu\n", strlen(buffer_in));
printf("Compressed size is: %lu\n", strlen(buffer_out));