Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #2 from tsirysndr/zig-codecs-rocks

zig: generate codec and rock files

authored by

Tsiry Sandratraina and committed by
GitHub
8b885815 a0342382

+2119 -174
+1 -1
README.md
··· 17 17 ```sh 18 18 . ./bin/activate-hermit 19 19 mkdir -p build && cd build 20 - ../tools/configure 20 + ../tools/configure --target=sdlapp --type=N --lcdwidth=320 --lcdheight=240 21 21 make zig 22 22 ```
+5 -1
apps/main.c
··· 160 160 * be INIT_ATTR. These functions must not be called after the final call 161 161 * to root_menu() at the end of main() 162 162 * see definition of INIT_ATTR in config.h */ 163 - #ifdef HAVE_ARGV_MAIN 163 + #if defined(HAVE_ARGV_MAIN) && !defined(ZIG_APP) 164 164 int main(int argc, char *argv[]) INIT_ATTR MAIN_NORETURN_ATTR ; 165 165 int main(int argc, char *argv[]) 166 166 { 167 167 sys_handle_argv(argc, argv); 168 + #elif defined(ZIG_APP) 169 + int main_c(void) INIT_ATTR MAIN_NORETURN_ATTR; 170 + int main_c(void) 171 + { 168 172 #else 169 173 int main(void) INIT_ATTR MAIN_NORETURN_ATTR; 170 174 int main(void)
+8
apps/plugins/brickmania.c
··· 365 365 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 366 366 #define QUIT BUTTON_POWER 367 367 368 + #elif CONFIG_KEYPAD == SDL_PAD 369 + #define QUIT BUTTON_BACK 370 + #define LEFT BUTTON_LEFT 371 + #define RIGHT BUTTON_RIGHT 372 + #define SELECT BUTTON_SELECT 373 + #define UP BUTTON_UP 374 + #define DOWN BUTTON_DOWN 375 + 368 376 #else 369 377 #error No keymap defined! 370 378 #endif
+10
apps/plugins/calculator.c
··· 536 536 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 537 537 #define CALCULATOR_QUIT BUTTON_POWER 538 538 539 + #elif CONFIG_KEYPAD == SDL_PAD 540 + #define CALCULATOR_LEFT BUTTON_LEFT 541 + #define CALCULATOR_RIGHT BUTTON_RIGHT 542 + #define CALCULATOR_UP BUTTON_UP 543 + #define CALCULATOR_DOWN BUTTON_DOWN 544 + #define CALCULATOR_QUIT (BUTTON_UP | BUTTON_DOWN) 545 + #define CALCULATOR_INPUT BUTTON_SELECT 546 + #define CALCULATOR_CALC BUTTON_MENU 547 + #define CALCULATOR_CLEAR BUTTON_BACK 548 + 539 549 #else 540 550 #error No keymap defined! 541 551 #endif
+3
apps/plugins/calendar.c
··· 422 422 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 423 423 /* use touchscreen */ 424 424 425 + #elif CONFIG_KEYPAD == SDL_PAD 426 + /* use touchscreen */ 427 + 425 428 #else 426 429 #error "No keypad setting." 427 430 #endif
+10
apps/plugins/chessclock.c
··· 398 398 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 399 399 #define CHC_QUIT BUTTON_POWER 400 400 401 + #elif CONFIG_KEYPAD == SDL_PAD 402 + #define CHC_QUIT BUTTON_BACK 403 + #define CHC_STARTSTOP BUTTON_SELECT 404 + #define CHC_RESET BUTTON_LEFT 405 + #define CHC_MENU BUTTON_MENU 406 + #define CHC_SETTINGS_INC BUTTON_UP 407 + #define CHC_SETTINGS_DEC BUTTON_DOWN 408 + #define CHC_SETTINGS_OK BUTTON_SELECT 409 + #define CHC_SETTINGS_CANCEL BUTTON_BACK 410 + 401 411 #else 402 412 #error No keymap defined! 403 413 #endif
+9
apps/plugins/chip8.c
··· 1291 1291 #define CHIP8_KEY6 BUTTON_RIGHT 1292 1292 #define CHIP8_KEY8 BUTTON_BACK 1293 1293 1294 + #elif CONFIG_KEYPAD == SDL_PAD 1295 + #define CHIP8_OFF BUTTON_DOWN 1296 + #define CHIP8_KEY2 BUTTON_MENU 1297 + #define CHIP8_KEY4 BUTTON_LEFT 1298 + #define CHIP8_KEY5 BUTTON_SELECT 1299 + #define CHIP8_KEY6 BUTTON_RIGHT 1300 + #define CHIP8_KEY8 BUTTON_BACK 1301 + 1302 + 1294 1303 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 1295 1304 /* use touchscreen */ 1296 1305
+5
apps/plugins/chopper.c
··· 202 202 #define ACTION BUTTON_PLAY 203 203 #define ACTIONTEXT "PLAY" 204 204 205 + #elif CONFIG_KEYPAD == SDL_PAD 206 + #define QUIT BUTTON_BACK 207 + #define ACTION BUTTON_SELECT 208 + #define ACTIONTEXT "SELECT" 209 + 205 210 #elif !defined(HAVE_TOUCHSCREEN) 206 211 #error No keymap defined! 207 212 #endif
+11
apps/plugins/cube.c
··· 405 405 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 406 406 /* use touchscreen */ 407 407 408 + 409 + #elif CONFIG_KEYPAD == SDL_PAD 410 + #define CUBE_QUIT BUTTON_BACK | BUTTON_LEFT 411 + #define CUBE_NEXT BUTTON_RIGHT 412 + #define CUBE_PREV BUTTON_LEFT 413 + #define CUBE_INC BUTTON_UP 414 + #define CUBE_DEC BUTTON_DOWN 415 + #define CUBE_MODE BUTTON_MENU 416 + #define CUBE_PAUSE BUTTON_SELECT 417 + #define CUBE_HIGHSPEED BUTTON_BACK 418 + 408 419 #else 409 420 #error No keymap defined! 410 421 #endif
+3
apps/plugins/flipit.c
··· 499 499 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 500 500 /* use touchscreen */ 501 501 502 + #elif CONFIG_KEYPAD == SDL_PAD 503 + /* use touchscreen */ 504 + 502 505 #else 503 506 #error No keymap defined! 504 507 #endif
+10
apps/plugins/jewels.c
··· 380 380 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 381 381 /* use touchscreen */ 382 382 383 + #elif CONFIG_KEYPAD == SDL_PAD 384 + #define JEWELS_UP BUTTON_UP 385 + #define JEWELS_DOWN BUTTON_DOWN 386 + #define JEWELS_LEFT BUTTON_LEFT 387 + #define JEWELS_RIGHT BUTTON_RIGHT 388 + #define JEWELS_SELECT BUTTON_SELECT 389 + #define JEWELS_CANCEL BUTTON_BACK 390 + #define HK_SELECT "SELECT" 391 + #define HK_CANCEL "BACK" 392 + 383 393 #else 384 394 #error No keymap defined! 385 395 #endif
+13
apps/plugins/minesweeper.c
··· 446 446 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 447 447 /* use touchscreen */ 448 448 449 + #elif CONFIG_KEYPAD == SDL_PAD 450 + # define MINESWP_LEFT BUTTON_LEFT 451 + # define MINESWP_RIGHT BUTTON_RIGHT 452 + # define MINESWP_UP BUTTON_UP 453 + # define MINESWP_DOWN BUTTON_DOWN 454 + # define MINESWP_NEXT BUTTON_SCROLL_FWD 455 + # define MINESWP_PREV BUTTON_SCROLL_BACK 456 + # define MINESWP_QUIT (BUTTON_SELECT | BUTTON_MENU) 457 + # define MINESWP_TOGGLE_PRE BUTTON_SELECT 458 + # define MINESWP_TOGGLE (BUTTON_SELECT | BUTTON_LEFT) 459 + # define MINESWP_DISCOVER (BUTTON_SELECT | BUTTON_RIGHT) 460 + # define MINESWP_INFO (BUTTON_SELECT | BUTTON_UP) 461 + 449 462 #else 450 463 #error No keymap defined! 451 464 #endif
+6
apps/plugins/mp3_encoder.c
··· 2583 2583 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 2584 2584 /* use touchscreen */ 2585 2585 2586 + #elif CONFIG_KEYPAD == SDL_PAD 2587 + #define MP3ENC_PREV BUTTON_LEFT 2588 + #define MP3ENC_NEXT BUTTON_RIGHT 2589 + #define MP3ENC_DONE BUTTON_BACK 2590 + #define MP3ENC_SELECT BUTTON_SELECT 2591 + 2586 2592 #else 2587 2593 #error No keymap defined! 2588 2594 #endif
+9
apps/plugins/oscilloscope.c
··· 553 553 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 554 554 /* use touchscreen */ 555 555 556 + #elif CONFIG_KEYPAD == SDL_PAD 557 + #define OSCILLOSCOPE_QUIT BUTTON_BACK 558 + #define OSCILLOSCOPE_ADVMODE BUTTON_MENU 559 + #define OSCILLOSCOPE_PAUSE BUTTON_SELECT 560 + #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT 561 + #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT 562 + #define OSCILLOSCOPE_VOL_UP BUTTON_UP 563 + #define OSCILLOSCOPE_VOL_DOWN BUTTON_DOWN 564 + 556 565 #else 557 566 #error No keymap defined! 558 567 #endif
+11
apps/plugins/pegbox.c
··· 714 714 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 715 715 /* use touchscreen */ 716 716 717 + #elif CONFIG_KEYPAD == SDL_PAD 718 + #define PEGBOX_SELECT BUTTON_SELECT 719 + #define PEGBOX_QUIT BUTTON_BACK 720 + #define PEGBOX_RESTART (BUTTON_SELECT | BUTTON_MENU) 721 + #define PEGBOX_LVL_UP (BUTTON_UP | BUTTON_SELECT) 722 + #define PEGBOX_LVL_DOWN (BUTTON_DOWN | BUTTON_SELECT) 723 + #define PEGBOX_UP BUTTON_UP 724 + #define PEGBOX_DOWN BUTTON_DOWN 725 + #define PEGBOX_RIGHT BUTTON_RIGHT 726 + #define PEGBOX_LEFT BUTTON_LEFT 727 + 717 728 #else 718 729 #error "Unsupported keymap!" 719 730 #endif
+8
apps/plugins/pong.c
··· 328 328 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 329 329 /* use touchscreen */ 330 330 331 + #elif CONFIG_KEYPAD == SDL_PAD 332 + #define PONG_QUIT BUTTON_BACK 333 + #define PONG_PAUSE BUTTON_SELECT 334 + #define PONG_LEFT_UP BUTTON_UP 335 + #define PONG_LEFT_DOWN BUTTON_DOWN 336 + #define PONG_RIGHT_UP BUTTON_RIGHT 337 + #define PONG_RIGHT_DOWN BUTTON_LEFT 338 + 331 339 #else 332 340 #error No keymap defined! 333 341 #endif
+10
apps/plugins/rockblox.c
··· 469 469 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 470 470 /* use touchscreen */ 471 471 472 + #elif CONFIG_KEYPAD == SDL_PAD 473 + #define ROCKBLOX_OFF BUTTON_MENU 474 + #define ROCKBLOX_ROTATE_CCW BUTTON_UP 475 + #define ROCKBLOX_ROTATE_CW BUTTON_DOWN 476 + #define ROCKBLOX_DOWN BUTTON_SELECT 477 + #define ROCKBLOX_LEFT BUTTON_LEFT 478 + #define ROCKBLOX_RIGHT BUTTON_RIGHT 479 + #define ROCKBLOX_DROP (BUTTON_MENU | BUTTON_DOWN) 480 + #define ROCKBLOX_RESTART BUTTON_BACK 481 + 472 482 #else 473 483 #error No keymap defined! 474 484 #endif
+9
apps/plugins/sliding_puzzle.c
··· 360 360 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 361 361 /* use touchscreen */ 362 362 363 + #elif CONFIG_KEYPAD == SDL_PAD 364 + #define PUZZLE_QUIT BUTTON_BACK 365 + #define PUZZLE_LEFT BUTTON_LEFT 366 + #define PUZZLE_RIGHT BUTTON_RIGHT 367 + #define PUZZLE_UP BUTTON_UP 368 + #define PUZZLE_DOWN BUTTON_DOWN 369 + #define PUZZLE_SHUFFLE BUTTON_SELECT 370 + #define PUZZLE_PICTURE BUTTON_MENU 371 + 363 372 #else 364 373 #error No keymap defined! 365 374 #endif
+8
apps/plugins/snake.c
··· 316 316 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 317 317 /* use touchscreen */ 318 318 319 + #elif CONFIG_KEYPAD == SDL_PAD 320 + #define SNAKE_QUIT BUTTON_BACK 321 + #define SNAKE_LEFT BUTTON_LEFT 322 + #define SNAKE_RIGHT BUTTON_RIGHT 323 + #define SNAKE_UP BUTTON_UP 324 + #define SNAKE_DOWN BUTTON_DOWN 325 + #define SNAKE_PLAYPAUSE BUTTON_SELECT 326 + 319 327 #else 320 328 #error No keymap defined! 321 329 #endif
+9
apps/plugins/snake2.c
··· 458 458 #define SNAKE2_PLAYPAUSE BUTTON_PLAY 459 459 #define SNAKE2_PLAYPAUSE_TEXT "PLAY" 460 460 461 + #elif CONFIG_KEYPAD == SDL_PAD 462 + #define SNAKE2_LEFT BUTTON_LEFT 463 + #define SNAKE2_RIGHT BUTTON_RIGHT 464 + #define SNAKE2_UP BUTTON_UP 465 + #define SNAKE2_DOWN BUTTON_DOWN 466 + #define SNAKE2_QUIT BUTTON_BACK 467 + #define SNAKE2_PLAYPAUSE BUTTON_SELECT 468 + #define SNAKE2_PLAYPAUSE_TEXT "PLAY" 469 + 461 470 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 462 471 /* use touchscreen */ 463 472
+8
apps/plugins/sokoban.c
··· 699 699 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 700 700 /* use touchscreen */ 701 701 702 + #elif CONFIG_KEYPAD == SDL_PAD 703 + #define SOKOBAN_LEFT BUTTON_LEFT 704 + #define SOKOBAN_RIGHT BUTTON_RIGHT 705 + #define SOKOBAN_UP BUTTON_UP 706 + #define SOKOBAN_DOWN BUTTON_DOWN 707 + #define BUTTON_SAVE BUTTON_SELECT 708 + #define BUTTON_SAVE_NAME "SELECT" 709 + 702 710 #else 703 711 #error No keymap defined! 704 712 #endif
+18
apps/plugins/solitaire.c
··· 744 744 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 745 745 # define SOL_QUIT BUTTON_POWER 746 746 747 + #elif CONFIG_PAD == SDL_APP 748 + # define SOL_QUIT (BUTTON_SELECT | BUTTON_MENU) 749 + # define SOL_UP BUTTON_UP 750 + # define SOL_DOWN BUTTON_DOWN 751 + # define SOL_LEFT_PRE BUTTON_LEFT 752 + # define SOL_LEFT (BUTTON_LEFT | BUTTON_SELECT) 753 + # define SOL_RIGHT_PRE BUTTON_RIGHT 754 + # define SOL_RIGHT (BUTTON_RIGHT | BUTTON_SELECT) 755 + # define SOL_MOVE_PRE BUTTON_SELECT 756 + # define SOL_MOVE (BUTTON_SELECT | BUTTON_UP) 757 + # define SOL_DRAW_PRE BUTTON_MENU 758 + # define HK_UD "SCROLL U/D" 759 + # define HK_MOVE "SELECT" 760 + # define HK_DRAW "MENU" 761 + # define HK_REM2CUR "PLAY" 762 + # define HK_CUR2STACK "MENU.." 763 + # define HK_REM2STACK "RIGHT.." 764 + 747 765 #else 748 766 #error No keymap defined! 749 767 #endif
+10
apps/plugins/spacerocks.c
··· 375 375 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 376 376 /* use touchscreen */ 377 377 378 + #elif CONFIG_KEYPAD == SDL_PAD 379 + #define AST_PAUSE BUTTON_MENU 380 + #define AST_QUIT (BUTTON_BACK | BUTTON_LEFT) 381 + #define AST_THRUST BUTTON_UP 382 + #define AST_HYPERSPACE BUTTON_BACK 383 + #define AST_LEFT BUTTON_LEFT 384 + #define AST_RIGHT BUTTON_RIGHT 385 + #define AST_FIRE BUTTON_SELECT 386 + 387 + 378 388 #else 379 389 #error No keymap defined! 380 390 #endif
+5
apps/plugins/star.c
··· 672 672 #define STAR_QUIT BUTTON_POWER 673 673 #define STAR_QUIT_NAME "POWER" 674 674 675 + 676 + #elif CONFIG_KEYPAD == SDL_PAD 677 + #define STAR_QUIT BUTTON_BACK 678 + #define STAR_QUIT_NAME "POWER" 679 + 675 680 #else 676 681 #error No keymap defined! 677 682 #endif
+8
apps/plugins/stopwatch.c
··· 300 300 #define STOPWATCH_SCROLL_UP BUTTON_SCROLL_BACK 301 301 #define STOPWATCH_SCROLL_DOWN BUTTON_SCROLL_FWD 302 302 303 + #elif CONFIG_KEYPAD == SDL_PAD 304 + #define STOPWATCH_QUIT BUTTON_MENU 305 + #define STOPWATCH_START_STOP BUTTON_SELECT 306 + #define STOPWATCH_RESET_TIMER BUTTON_LEFT 307 + #define STOPWATCH_LAP_TIMER BUTTON_RIGHT 308 + #define STOPWATCH_SCROLL_UP BUTTON_UP 309 + #define STOPWATCH_SCROLL_DOWN BUTTON_DOWN 310 + 303 311 #else 304 312 #error No keymap defined! 305 313 #endif
+4
apps/plugins/vu_meter.c
··· 457 457 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 458 458 /* use touchscreen */ 459 459 460 + #elif CONFIG_KEYPAD == SDL_PAD 461 + #define VUMETER_QUIT BUTTON_BACK 462 + #define LABEL_QUIT "BACK" 463 + 460 464 #else 461 465 #error No keymap defined! 462 466 #endif
+3
apps/plugins/wormlet.c
··· 410 410 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 411 411 /* use touchscreen */ 412 412 413 + #elif CONFIG_KEYPAD == SDL_PAD 414 + /* use touchscreen */ 415 + 413 416 #else 414 417 #error No keymap defined! 415 418 #endif
+8
apps/plugins/xobox.c
··· 351 351 #define DOWN BUTTON_DOWN 352 352 #define PAUSE BUTTON_PLAY 353 353 354 + #elif CONFIG_KEYPAD == SDL_PAD 355 + #define QUIT BUTTON_BACK 356 + #define LEFT BUTTON_LEFT 357 + #define RIGHT BUTTON_RIGHT 358 + #define UP BUTTON_UP 359 + #define DOWN BUTTON_DOWN 360 + #define PAUSE BUTTON_SELECT 361 + 354 362 #elif CONFIG_KEYPAD == SHANLING_Q1_PAD 355 363 /* use touchscreen */ 356 364
+1253 -92
build.zig
··· 1 1 const std = @import("std"); 2 + const String = @import("./string.zig").String; 2 3 3 4 pub const BuildOptions = struct { 4 5 name: []const u8, ··· 15 16 // Although this function looks imperative, note that its job is to 16 17 // declaratively construct a build graph that will be executed by an external 17 18 // runner. 18 - pub fn build(b: *std.Build) void { 19 + pub fn build(b: *std.Build) !void { 19 20 // Standard target options allows the person running `zig build` to choose 20 21 // what target to build for. Here we do not override the defaults, which 21 22 // means any target is allowed, and the default is native. Other options ··· 48 49 49 50 const exe = b.addExecutable(.{ 50 51 .name = "rockbox", 51 - // .root_source_file = b.path("src/main.zig"), 52 + .root_source_file = b.path("src/main.zig"), 52 53 .target = target, 53 54 .optimize = optimize, 54 55 }); ··· 81 82 const run_step = b.step("run", "Run the app"); 82 83 run_step.dependOn(&run_cmd.step); 83 84 85 + const codecs = b.step("codecs", "Build rockbox codecs"); 86 + codecs.dependOn(b.getInstallStep()); 87 + 88 + const rocks = b.step("rocks", "Build rockbox plugins"); 89 + rocks.dependOn(b.getInstallStep()); 90 + 91 + const all = b.step("all", "Build codecs and plugins"); 92 + all.dependOn(codecs); 93 + all.dependOn(rocks); 94 + 84 95 // Creates a step for unit testing. This only builds the test executable 85 96 // but does not run it. 86 97 const lib_unit_tests = b.addTest(.{ ··· 99 110 100 111 const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); 101 112 102 - // Similar to creating the run step earlier, this exposes a `test` step to 113 + // Similar to Generating the run step earlier, this exposes a `test` step to 103 114 // the `zig build --help` menu, providing a way for the user to request 104 115 // running the unit tests. 105 116 const test_step = b.step("test", "Run unit tests"); ··· 109 120 build_tools(b, target, optimize); 110 121 111 122 exe.addCSourceFiles(.{ 112 - // .files = &[_][]const u8{}, 113 123 .files = &all_sources, 114 124 .flags = &cflags, 115 125 }); 116 126 127 + exe.defineCMacro("ZIG_APP", null); 128 + 117 129 lib.addCSourceFiles(.{ 118 - //.files = &all_sources, 119 130 .files = &[_][]const u8{}, 120 131 .flags = &cflags, 121 132 }); ··· 279 290 defineCMacros(libtlsf); 280 291 addIncludePaths(libtlsf); 281 292 282 - build_codec(b, .{ 293 + const opus = try build_codec(b, .{ 283 294 .name = "opus", 284 295 .target = target, 285 296 .optimize = optimize, ··· 324 335 "./lib/rbcodec/codecs/libopus/config.h", 325 336 }, 326 337 }); 338 + codecs.dependOn(opus); 327 339 328 - build_codec(b, .{ 340 + const vorbis = try build_codec(b, .{ 329 341 .name = "vorbis", 330 342 .target = target, 331 343 .optimize = optimize, ··· 353 365 libfixedpoint, 354 366 }, 355 367 }); 368 + codecs.dependOn(vorbis); 356 369 357 370 const libmad = b.addStaticLibrary(.{ 358 371 .name = "mad", ··· 391 404 defineCMacros(libasf); 392 405 addIncludePaths(libasf); 393 406 394 - build_codec(b, .{ 407 + const mpa = try build_codec(b, .{ 395 408 .name = "mpa", 396 409 .target = target, 397 410 .optimize = optimize, ··· 405 418 libasf, 406 419 }, 407 420 }); 421 + codecs.dependOn(mpa); 408 422 409 423 const libffmpegFLAC = b.addStaticLibrary(.{ 410 424 .name = "ffmpegFLAC", ··· 426 440 defineCMacros(libffmpegFLAC); 427 441 addIncludePaths(libffmpegFLAC); 428 442 429 - build_codec(b, .{ 443 + const flac = try build_codec(b, .{ 430 444 .name = "flac", 431 445 .target = target, 432 446 .optimize = optimize, ··· 439 453 libffmpegFLAC, 440 454 }, 441 455 }); 456 + codecs.dependOn(flac); 442 457 443 458 const libpcm = b.addStaticLibrary(.{ 444 459 .name = "pcm", ··· 469 484 defineCMacros(libpcm); 470 485 addIncludePaths(libpcm); 471 486 472 - build_codec(b, .{ 487 + const wav = try build_codec(b, .{ 473 488 .name = "wav", 474 489 .target = target, 475 490 .optimize = optimize, ··· 482 497 libpcm, 483 498 }, 484 499 }); 500 + codecs.dependOn(wav); 485 501 486 502 const librm = b.addStaticLibrary(.{ 487 503 .name = "rm", ··· 499 515 defineCMacros(librm); 500 516 addIncludePaths(librm); 501 517 502 - build_codec(b, .{ 518 + const a52 = try build_codec(b, .{ 503 519 .name = "a52", 504 520 .target = target, 505 521 .optimize = optimize, ··· 517 533 librm, 518 534 }, 519 535 }); 536 + codecs.dependOn(a52); 520 537 521 - build_codec(b, .{ 538 + const wavpack = try build_codec(b, .{ 522 539 .name = "wavpack", 523 540 .target = target, 524 541 .optimize = optimize, ··· 537 554 libfixedpoint, 538 555 }, 539 556 }); 557 + codecs.dependOn(wavpack); 540 558 541 - build_codec(b, .{ 559 + const alac = try build_codec(b, .{ 542 560 .name = "alac", 543 561 .target = target, 544 562 .optimize = optimize, ··· 551 569 libfixedpoint, 552 570 }, 553 571 }); 572 + codecs.dependOn(alac); 554 573 555 - build_codec(b, .{ 574 + const m4a = try build_codec(b, .{ 556 575 .name = "m4a", 557 576 .target = target, 558 577 .optimize = optimize, ··· 565 584 libfixedpoint, 566 585 }, 567 586 }); 587 + codecs.dependOn(m4a); 568 588 569 - build_codec(b, .{ 589 + const cook = try build_codec(b, .{ 570 590 .name = "cook", 571 591 .target = target, 572 592 .optimize = optimize, ··· 580 600 librm, 581 601 }, 582 602 }); 603 + codecs.dependOn(cook); 583 604 584 605 const libfaad = b.addStaticLibrary(.{ 585 606 .name = "faad", ··· 654 675 defineCMacros(libfaad); 655 676 addIncludePaths(libfaad); 656 677 657 - build_codec(b, .{ 678 + const faad = try build_codec(b, .{ 658 679 .name = "faad", 659 680 .target = target, 660 681 .optimize = optimize, ··· 722 743 "-I./lib/rbcodec/codecs/libfaad", 723 744 }, 724 745 }); 746 + codecs.dependOn(faad); 725 747 726 - build_codec(b, .{ 748 + const raac = try build_codec(b, .{ 727 749 .name = "raac", 728 750 .target = target, 729 751 .optimize = optimize, ··· 765 787 "-I./lib/rbcodec/codecs/libfaad", 766 788 }, 767 789 }); 790 + codecs.dependOn(raac); 768 791 769 - build_codec(b, .{ 792 + const a52_rm = try build_codec(b, .{ 770 793 .name = "a52_rm", 771 794 .target = target, 772 795 .optimize = optimize, ··· 779 802 librm, 780 803 }, 781 804 }); 805 + codecs.dependOn(a52_rm); 782 806 783 - build_codec(b, .{ 807 + const atrac3_rm = try build_codec(b, .{ 784 808 .name = "atrac3_rm", 785 809 .target = target, 786 810 .optimize = optimize, ··· 794 818 librm, 795 819 }, 796 820 }); 821 + codecs.dependOn(atrac3_rm); 797 822 798 - build_codec(b, .{ 823 + const atrac3_oma = try build_codec(b, .{ 799 824 .name = "atrac3_oma", 800 825 .target = target, 801 826 .optimize = optimize, ··· 807 832 libfixedpoint, 808 833 }, 809 834 }); 835 + codecs.dependOn(atrac3_oma); 810 836 811 - build_codec(b, .{ 837 + const mpc = try build_codec(b, .{ 812 838 .name = "mpc", 813 839 .target = target, 814 840 .optimize = optimize, ··· 828 854 libfixedpoint, 829 855 }, 830 856 }); 857 + codecs.dependOn(mpc); 831 858 832 - build_codec(b, .{ 859 + const wma = try build_codec(b, .{ 833 860 .name = "wma", 834 861 .target = target, 835 862 .optimize = optimize, ··· 843 870 libfixedpoint, 844 871 }, 845 872 }); 873 + codecs.dependOn(wma); 846 874 847 875 const libdemac = b.addStaticLibrary(.{ 848 876 .name = "demac", ··· 869 897 defineCMacros(libdemac); 870 898 addIncludePaths(libdemac); 871 899 872 - build_codec(b, .{ 900 + const ape = try build_codec(b, .{ 873 901 .name = "ape", 874 902 .target = target, 875 903 .optimize = optimize, ··· 881 909 libfixedpoint, 882 910 }, 883 911 }); 912 + codecs.dependOn(ape); 884 913 885 - build_codec(b, .{ 914 + const asap = try build_codec(b, .{ 886 915 .name = "asap", 887 916 .target = target, 888 917 .optimize = optimize, ··· 897 926 libfixedpoint, 898 927 }, 899 928 }); 929 + codecs.dependOn(asap); 900 930 901 - build_codec(b, .{ 931 + const aac = try build_codec(b, .{ 902 932 .name = "aac", 903 933 .target = target, 904 934 .optimize = optimize, ··· 910 940 libfixedpoint, 911 941 }, 912 942 }); 943 + codecs.dependOn(aac); 913 944 914 - build_codec(b, .{ 945 + const spc = try build_codec(b, .{ 915 946 .name = "spc", 916 947 .target = target, 917 948 .optimize = optimize, ··· 927 958 libfixedpoint, 928 959 }, 929 960 }); 961 + codecs.dependOn(spc); 930 962 931 - build_codec(b, .{ 963 + const mod = try build_codec(b, .{ 932 964 .name = "mod", 933 965 .target = target, 934 966 .optimize = optimize, ··· 940 972 libfixedpoint, 941 973 }, 942 974 }); 975 + codecs.dependOn(mod); 943 976 944 - build_codec(b, .{ 977 + const shorten = try build_codec(b, .{ 945 978 .name = "shorten", 946 979 .target = target, 947 980 .optimize = optimize, ··· 954 987 libffmpegFLAC, 955 988 }, 956 989 }); 990 + codecs.dependOn(shorten); 957 991 958 - build_codec(b, .{ 992 + const aiff = try build_codec(b, .{ 959 993 .name = "aiff", 960 994 .target = target, 961 995 .optimize = optimize, ··· 968 1002 libpcm, 969 1003 }, 970 1004 }); 1005 + codecs.dependOn(aiff); 971 1006 972 - build_codec(b, .{ 1007 + const speex = try build_codec(b, .{ 973 1008 .name = "speex", 974 1009 .target = target, 975 1010 .optimize = optimize, ··· 1012 1047 "-I./lib/rbcodec/codecs/libspeex", 1013 1048 }, 1014 1049 }); 1050 + codecs.dependOn(speex); 1015 1051 1016 - build_codec(b, .{ 1052 + const adx = try build_codec(b, .{ 1017 1053 .name = "adx", 1018 1054 .target = target, 1019 1055 .optimize = optimize, ··· 1025 1061 libfixedpoint, 1026 1062 }, 1027 1063 }); 1064 + codecs.dependOn(adx); 1028 1065 1029 - build_codec(b, .{ 1066 + const smaf = try build_codec(b, .{ 1030 1067 .name = "smaf", 1031 1068 .target = target, 1032 1069 .optimize = optimize, ··· 1039 1076 libpcm, 1040 1077 }, 1041 1078 }); 1079 + codecs.dependOn(smaf); 1042 1080 1043 - build_codec(b, .{ 1081 + const au = try build_codec(b, .{ 1044 1082 .name = "au", 1045 1083 .target = target, 1046 1084 .optimize = optimize, ··· 1053 1091 libpcm, 1054 1092 }, 1055 1093 }); 1094 + codecs.dependOn(au); 1056 1095 1057 - build_codec(b, .{ 1096 + const vox = try build_codec(b, .{ 1058 1097 .name = "vox", 1059 1098 .target = target, 1060 1099 .optimize = optimize, ··· 1067 1106 libpcm, 1068 1107 }, 1069 1108 }); 1109 + codecs.dependOn(vox); 1070 1110 1071 - build_codec(b, .{ 1111 + const wav64 = try build_codec(b, .{ 1072 1112 .name = "wav64", 1073 1113 .target = target, 1074 1114 .optimize = optimize, ··· 1081 1121 libpcm, 1082 1122 }, 1083 1123 }); 1124 + codecs.dependOn(wav64); 1084 1125 1085 - build_codec(b, .{ 1126 + const tta = try build_codec(b, .{ 1086 1127 .name = "tta", 1087 1128 .target = target, 1088 1129 .optimize = optimize, ··· 1095 1136 libfixedpoint, 1096 1137 }, 1097 1138 }); 1139 + codecs.dependOn(tta); 1098 1140 1099 - build_codec(b, .{ 1141 + const wmapro = try build_codec(b, .{ 1100 1142 .name = "wmapro", 1101 1143 .target = target, 1102 1144 .optimize = optimize, ··· 1111 1153 libfixedpoint, 1112 1154 }, 1113 1155 }); 1156 + codecs.dependOn(wmapro); 1114 1157 1115 - build_codec(b, .{ 1158 + const ay = try build_codec(b, .{ 1116 1159 .name = "ay", 1117 1160 .target = target, 1118 1161 .optimize = optimize, ··· 1131 1174 libfixedpoint, 1132 1175 }, 1133 1176 }); 1177 + codecs.dependOn(ay); 1134 1178 1135 - build_codec(b, .{ 1179 + const vtx = try build_codec(b, .{ 1136 1180 .name = "vtx", 1137 1181 .target = target, 1138 1182 .optimize = optimize, ··· 1147 1191 libfixedpoint, 1148 1192 }, 1149 1193 }); 1194 + codecs.dependOn(vtx); 1150 1195 1151 - build_codec(b, .{ 1196 + const gbs = try build_codec(b, .{ 1152 1197 .name = "gbs", 1153 1198 .target = target, 1154 1199 .optimize = optimize, ··· 1166 1211 libfixedpoint, 1167 1212 }, 1168 1213 }); 1214 + codecs.dependOn(gbs); 1169 1215 1170 - build_codec(b, .{ 1216 + const hes = try build_codec(b, .{ 1171 1217 .name = "hes", 1172 1218 .target = target, 1173 1219 .optimize = optimize, ··· 1183 1229 libfixedpoint, 1184 1230 }, 1185 1231 }); 1232 + codecs.dependOn(hes); 1186 1233 1187 1234 const libemu2413 = b.addStaticLibrary(.{ 1188 1235 .name = "emu2413", ··· 1206 1253 defineCMacros(libemu2413); 1207 1254 addIncludePaths(libemu2413); 1208 1255 1209 - build_codec(b, .{ 1256 + const nsf = try build_codec(b, .{ 1210 1257 .name = "nsf", 1211 1258 .target = target, 1212 1259 .optimize = optimize, ··· 1234 1281 libemu2413, 1235 1282 }, 1236 1283 }); 1284 + codecs.dependOn(nsf); 1237 1285 1238 - build_codec(b, .{ 1286 + const sgc = try build_codec(b, .{ 1239 1287 .name = "sgc", 1240 1288 .target = target, 1241 1289 .optimize = optimize, ··· 1249 1297 libfixedpoint, 1250 1298 }, 1251 1299 }); 1300 + codecs.dependOn(sgc); 1252 1301 1253 - build_codec(b, .{ 1302 + const vgm = try build_codec(b, .{ 1254 1303 .name = "vgm", 1255 1304 .target = target, 1256 1305 .optimize = optimize, ··· 1269 1318 libfixedpoint, 1270 1319 }, 1271 1320 }); 1321 + codecs.dependOn(vgm); 1272 1322 1273 1323 //const sid = b.addStaticLibrary(.{ 1274 1324 // .name = "cRSID", ··· 1290 1340 // defineCMacros(sid); 1291 1341 // addIncludePaths(sid); 1292 1342 1293 - build_codec(b, .{ 1343 + const kss = try build_codec(b, .{ 1294 1344 .name = "kss", 1295 1345 .target = target, 1296 1346 .optimize = optimize, ··· 1308 1358 libfixedpoint, 1309 1359 }, 1310 1360 }); 1361 + codecs.dependOn(kss); 1311 1362 1312 - build_codec(b, .{ 1363 + const aac_bsf = try build_codec(b, .{ 1313 1364 .name = "aac_bsf", 1314 1365 .target = target, 1315 1366 .optimize = optimize, ··· 1321 1372 libfixedpoint, 1322 1373 }, 1323 1374 }); 1375 + codecs.dependOn(aac_bsf); 1324 1376 1325 1377 const libplugin = b.addStaticLibrary(.{ 1326 1378 .name = "plugin", ··· 1444 1496 "build/apps/plugins/bitmaps/native/sudoku_inverse.320x240x16.c", 1445 1497 "build/apps/plugins/bitmaps/native/matrix_bold.c", 1446 1498 "build/apps/plugins/bitmaps/native/matrix_normal.c", 1447 - "build/apps/plugins/bitmaps/native/sliding_puzzle.360x360x16.c", 1499 + "build/apps/plugins/bitmaps/native/sliding_puzzle.240x240x16.c", 1448 1500 "build/apps/plugins/bitmaps/native/rockboxlogo.220x68x16.c", 1449 1501 "build/apps/plugins/bitmaps/native/creditslogo.320x98x16.c", 1450 1502 "build/apps/plugins/bitmaps/native/resistor.320x240x16.c", ··· 1456 1508 defineCMacros(libpluginbitmaps); 1457 1509 addPluginIncludePaths(libpluginbitmaps); 1458 1510 1459 - build_plugin(b, .{ 1511 + const chopper = try build_plugin(b, .{ 1460 1512 .name = "chopper", 1461 1513 .target = target, 1462 1514 .optimize = optimize, ··· 1470 1522 libfixedpoint, 1471 1523 }, 1472 1524 }); 1525 + rocks.dependOn(chopper); 1473 1526 1474 - build_plugin(b, .{ 1527 + const clix = try build_plugin(b, .{ 1475 1528 .name = "clix", 1476 1529 .target = target, 1477 1530 .optimize = optimize, ··· 1485 1538 libfixedpoint, 1486 1539 }, 1487 1540 }); 1541 + rocks.dependOn(clix); 1488 1542 1489 - build_plugin(b, .{ 1543 + const credits = try build_plugin(b, .{ 1490 1544 .name = "credits", 1491 1545 .target = target, 1492 1546 .optimize = optimize, ··· 1500 1554 libfixedpoint, 1501 1555 }, 1502 1556 }); 1557 + rocks.dependOn(credits); 1503 1558 1504 - build_plugin(b, .{ 1505 - .name = "properties", 1506 - .target = target, 1507 - .optimize = optimize, 1508 - .sources = &[_][]const u8{ 1509 - "apps/plugins/properties.c", 1510 - "apps/plugins/plugin_crt0.c", 1511 - }, 1512 - .link_libraries = &[_]*std.Build.Step.Compile{ 1513 - libplugin, 1514 - libpluginbitmaps, 1515 - libfixedpoint, 1516 - }, 1517 - }); 1518 - 1519 - build_plugin(b, .{ 1520 - .name = "random_folder_advance_config", 1521 - .target = target, 1522 - .optimize = optimize, 1523 - .sources = &[_][]const u8{ 1524 - "apps/plugins/random_folder_advance_config.c", 1525 - "apps/plugins/plugin_crt0.c", 1526 - }, 1527 - .link_libraries = &[_]*std.Build.Step.Compile{ 1528 - libplugin, 1529 - libpluginbitmaps, 1530 - libfixedpoint, 1531 - }, 1532 - }); 1533 - 1534 - build_plugin(b, .{ 1559 + const search = try build_plugin(b, .{ 1535 1560 .name = "search", 1536 1561 .target = target, 1537 1562 .optimize = optimize, ··· 1545 1570 libfixedpoint, 1546 1571 }, 1547 1572 }); 1573 + rocks.dependOn(search); 1548 1574 1549 - build_plugin(b, .{ 1575 + const sort = try build_plugin(b, .{ 1550 1576 .name = "sort", 1551 1577 .target = target, 1552 1578 .optimize = optimize, ··· 1560 1586 libfixedpoint, 1561 1587 }, 1562 1588 }); 1589 + rocks.dependOn(sort); 1563 1590 1564 - build_plugin(b, .{ 1591 + const theme_remove = try build_plugin(b, .{ 1565 1592 .name = "theme_remove", 1566 1593 .target = target, 1567 1594 .optimize = optimize, ··· 1575 1602 libfixedpoint, 1576 1603 }, 1577 1604 }); 1605 + rocks.dependOn(theme_remove); 1578 1606 1579 - build_plugin(b, .{ 1607 + const vbrfix = try build_plugin(b, .{ 1580 1608 .name = "vbrfix", 1581 1609 .target = target, 1582 1610 .optimize = optimize, ··· 1590 1618 libfixedpoint, 1591 1619 }, 1592 1620 }); 1621 + rocks.dependOn(vbrfix); 1593 1622 1594 - build_plugin(b, .{ 1623 + const lua = try build_plugin(b, .{ 1595 1624 .name = "lua", 1596 1625 .target = target, 1597 1626 .optimize = optimize, ··· 1646 1675 libtlsf, 1647 1676 }, 1648 1677 }); 1678 + rocks.dependOn(lua); 1649 1679 1650 - build_plugin(b, .{ 1680 + const fft = try build_plugin(b, .{ 1651 1681 .name = "fft", 1652 1682 .target = target, 1653 1683 .optimize = optimize, ··· 1665 1695 }, 1666 1696 .is_fft_plugin = true, 1667 1697 }); 1698 + rocks.dependOn(fft); 1668 1699 1669 - build_plugin(b, .{ 1700 + const reversi = try build_plugin(b, .{ 1670 1701 .name = "reversi", 1671 1702 .target = target, 1672 1703 .optimize = optimize, ··· 1684 1715 libfixedpoint, 1685 1716 }, 1686 1717 }); 1718 + rocks.dependOn(reversi); 1687 1719 1688 - build_plugin(b, .{ 1720 + const pictureflow = try build_plugin(b, .{ 1689 1721 .name = "pictureflow", 1690 1722 .target = target, 1691 1723 .optimize = optimize, ··· 1699 1731 libfixedpoint, 1700 1732 }, 1701 1733 }); 1734 + rocks.dependOn(pictureflow); 1702 1735 1703 - build_plugin(b, .{ 1736 + const db_commit = try build_plugin(b, .{ 1704 1737 .name = "db_commit", 1705 1738 .target = target, 1706 1739 .optimize = optimize, ··· 1714 1747 libfixedpoint, 1715 1748 }, 1716 1749 }); 1750 + rocks.dependOn(db_commit); 1717 1751 1718 - build_plugin(b, .{ 1752 + const mikmod = try build_plugin(b, .{ 1719 1753 .name = "mikmod", 1720 1754 .target = target, 1721 1755 .optimize = optimize, ··· 1768 1802 }, 1769 1803 .is_mikmod_plugin = true, 1770 1804 }); 1805 + rocks.dependOn(mikmod); 1806 + 1807 + const chessclock = try build_plugin(b, .{ 1808 + .name = "chessclock", 1809 + .target = target, 1810 + .optimize = optimize, 1811 + .sources = &[_][]const u8{ 1812 + "apps/plugins/chessclock.c", 1813 + "apps/plugins/plugin_crt0.c", 1814 + }, 1815 + .link_libraries = &[_]*std.Build.Step.Compile{ 1816 + libplugin, 1817 + libpluginbitmaps, 1818 + libfixedpoint, 1819 + }, 1820 + }); 1821 + rocks.dependOn(chessclock); 1822 + 1823 + const cube = try build_plugin(b, .{ 1824 + .name = "cube", 1825 + .target = target, 1826 + .optimize = optimize, 1827 + .sources = &[_][]const u8{ 1828 + "apps/plugins/cube.c", 1829 + "apps/plugins/plugin_crt0.c", 1830 + }, 1831 + .link_libraries = &[_]*std.Build.Step.Compile{ 1832 + libplugin, 1833 + libpluginbitmaps, 1834 + libfixedpoint, 1835 + }, 1836 + }); 1837 + rocks.dependOn(cube); 1838 + 1839 + const cue_playlist = try build_plugin(b, .{ 1840 + .name = "cue_playlist", 1841 + .target = target, 1842 + .optimize = optimize, 1843 + .sources = &[_][]const u8{ 1844 + "apps/plugins/cue_playlist.c", 1845 + "apps/plugins/plugin_crt0.c", 1846 + }, 1847 + .link_libraries = &[_]*std.Build.Step.Compile{ 1848 + libplugin, 1849 + libpluginbitmaps, 1850 + libfixedpoint, 1851 + }, 1852 + }); 1853 + rocks.dependOn(cue_playlist); 1854 + 1855 + const dart_scorer = try build_plugin(b, .{ 1856 + .name = "dart_scorer", 1857 + .target = target, 1858 + .optimize = optimize, 1859 + .sources = &[_][]const u8{ 1860 + "apps/plugins/dart_scorer.c", 1861 + "apps/plugins/plugin_crt0.c", 1862 + }, 1863 + .link_libraries = &[_]*std.Build.Step.Compile{ 1864 + libplugin, 1865 + libpluginbitmaps, 1866 + libfixedpoint, 1867 + }, 1868 + }); 1869 + rocks.dependOn(dart_scorer); 1870 + 1871 + const dict = try build_plugin(b, .{ 1872 + .name = "dict", 1873 + .target = target, 1874 + .optimize = optimize, 1875 + .sources = &[_][]const u8{ 1876 + "apps/plugins/dict.c", 1877 + "apps/plugins/plugin_crt0.c", 1878 + }, 1879 + .link_libraries = &[_]*std.Build.Step.Compile{ 1880 + libplugin, 1881 + libpluginbitmaps, 1882 + libfixedpoint, 1883 + }, 1884 + }); 1885 + rocks.dependOn(dict); 1886 + 1887 + const file_picker = try build_plugin(b, .{ 1888 + .name = "file_picker", 1889 + .target = target, 1890 + .optimize = optimize, 1891 + .sources = &[_][]const u8{ 1892 + "apps/plugins/file_picker.c", 1893 + "apps/plugins/plugin_crt0.c", 1894 + }, 1895 + .link_libraries = &[_]*std.Build.Step.Compile{ 1896 + libplugin, 1897 + libpluginbitmaps, 1898 + libfixedpoint, 1899 + }, 1900 + }); 1901 + rocks.dependOn(file_picker); 1902 + 1903 + const jackpot = try build_plugin(b, .{ 1904 + .name = "jackpot", 1905 + .target = target, 1906 + .optimize = optimize, 1907 + .sources = &[_][]const u8{ 1908 + "apps/plugins/jackpot.c", 1909 + "apps/plugins/plugin_crt0.c", 1910 + }, 1911 + .link_libraries = &[_]*std.Build.Step.Compile{ 1912 + libplugin, 1913 + libpluginbitmaps, 1914 + libfixedpoint, 1915 + }, 1916 + }); 1917 + rocks.dependOn(jackpot); 1918 + 1919 + const keybox = try build_plugin(b, .{ 1920 + .name = "keybox", 1921 + .target = target, 1922 + .optimize = optimize, 1923 + .sources = &[_][]const u8{ 1924 + "apps/plugins/keybox.c", 1925 + "apps/plugins/plugin_crt0.c", 1926 + }, 1927 + .link_libraries = &[_]*std.Build.Step.Compile{ 1928 + libplugin, 1929 + libpluginbitmaps, 1930 + libfixedpoint, 1931 + }, 1932 + }); 1933 + rocks.dependOn(keybox); 1934 + 1935 + const keyremap = try build_plugin(b, .{ 1936 + .name = "keyremap", 1937 + .target = target, 1938 + .optimize = optimize, 1939 + .sources = &[_][]const u8{ 1940 + "apps/plugins/keyremap.c", 1941 + "apps/plugins/plugin_crt0.c", 1942 + }, 1943 + .link_libraries = &[_]*std.Build.Step.Compile{ 1944 + libplugin, 1945 + libpluginbitmaps, 1946 + libfixedpoint, 1947 + }, 1948 + }); 1949 + rocks.dependOn(keyremap); 1950 + 1951 + const lastfm_scrobbler = try build_plugin(b, .{ 1952 + .name = "lastfm_scrobbler", 1953 + .target = target, 1954 + .optimize = optimize, 1955 + .sources = &[_][]const u8{ 1956 + "apps/plugins/lastfm_scrobbler.c", 1957 + "apps/plugins/plugin_crt0.c", 1958 + }, 1959 + .link_libraries = &[_]*std.Build.Step.Compile{ 1960 + libplugin, 1961 + libpluginbitmaps, 1962 + libfixedpoint, 1963 + }, 1964 + }); 1965 + rocks.dependOn(lastfm_scrobbler); 1966 + 1967 + const lastfm_scrobbler_viewer = try build_plugin(b, .{ 1968 + .name = "lastfm_scrobbler_viewer", 1969 + .target = target, 1970 + .optimize = optimize, 1971 + .sources = &[_][]const u8{ 1972 + "apps/plugins/lastfm_scrobbler_viewer.c", 1973 + "apps/plugins/plugin_crt0.c", 1974 + }, 1975 + .link_libraries = &[_]*std.Build.Step.Compile{ 1976 + libplugin, 1977 + libpluginbitmaps, 1978 + libfixedpoint, 1979 + }, 1980 + }); 1981 + rocks.dependOn(lastfm_scrobbler_viewer); 1982 + 1983 + const logo = try build_plugin(b, .{ 1984 + .name = "logo", 1985 + .target = target, 1986 + .optimize = optimize, 1987 + .sources = &[_][]const u8{ 1988 + "apps/plugins/logo.c", 1989 + "apps/plugins/plugin_crt0.c", 1990 + }, 1991 + .link_libraries = &[_]*std.Build.Step.Compile{ 1992 + libplugin, 1993 + libpluginbitmaps, 1994 + libfixedpoint, 1995 + }, 1996 + }); 1997 + rocks.dependOn(logo); 1998 + 1999 + const lrcplayer = try build_plugin(b, .{ 2000 + .name = "lrcplayer", 2001 + .target = target, 2002 + .optimize = optimize, 2003 + .sources = &[_][]const u8{ 2004 + "apps/plugins/lrcplayer.c", 2005 + "apps/plugins/plugin_crt0.c", 2006 + }, 2007 + .link_libraries = &[_]*std.Build.Step.Compile{ 2008 + libplugin, 2009 + libpluginbitmaps, 2010 + libfixedpoint, 2011 + }, 2012 + }); 2013 + rocks.dependOn(lrcplayer); 2014 + 2015 + const mosaique = try build_plugin(b, .{ 2016 + .name = "mosaique", 2017 + .target = target, 2018 + .optimize = optimize, 2019 + .sources = &[_][]const u8{ 2020 + "apps/plugins/mosaique.c", 2021 + "apps/plugins/plugin_crt0.c", 2022 + }, 2023 + .link_libraries = &[_]*std.Build.Step.Compile{ 2024 + libplugin, 2025 + libpluginbitmaps, 2026 + libfixedpoint, 2027 + }, 2028 + }); 2029 + rocks.dependOn(mosaique); 2030 + 2031 + const main_menu_config = try build_plugin(b, .{ 2032 + .name = "main_menu_config", 2033 + .target = target, 2034 + .optimize = optimize, 2035 + .sources = &[_][]const u8{ 2036 + "apps/plugins/main_menu_config.c", 2037 + "apps/plugins/plugin_crt0.c", 2038 + }, 2039 + .link_libraries = &[_]*std.Build.Step.Compile{ 2040 + libplugin, 2041 + libpluginbitmaps, 2042 + libfixedpoint, 2043 + }, 2044 + }); 2045 + rocks.dependOn(main_menu_config); 2046 + 2047 + const playing_time = try build_plugin(b, .{ 2048 + .name = "playing_time", 2049 + .target = target, 2050 + .optimize = optimize, 2051 + .sources = &[_][]const u8{ 2052 + "apps/plugins/playing_time.c", 2053 + "apps/plugins/plugin_crt0.c", 2054 + }, 2055 + .link_libraries = &[_]*std.Build.Step.Compile{ 2056 + libplugin, 2057 + libpluginbitmaps, 2058 + libfixedpoint, 2059 + }, 2060 + }); 2061 + rocks.dependOn(playing_time); 2062 + 2063 + const properties = try build_plugin(b, .{ 2064 + .name = "properties", 2065 + .target = target, 2066 + .optimize = optimize, 2067 + .sources = &[_][]const u8{ 2068 + "apps/plugins/properties.c", 2069 + "apps/plugins/plugin_crt0.c", 2070 + }, 2071 + .link_libraries = &[_]*std.Build.Step.Compile{ 2072 + libplugin, 2073 + libpluginbitmaps, 2074 + libfixedpoint, 2075 + }, 2076 + }); 2077 + rocks.dependOn(properties); 2078 + 2079 + const random_folder_advance_config = try build_plugin(b, .{ 2080 + .name = "random_folder_advance_config", 2081 + .target = target, 2082 + .optimize = optimize, 2083 + .sources = &[_][]const u8{ 2084 + "apps/plugins/random_folder_advance_config.c", 2085 + "apps/plugins/plugin_crt0.c", 2086 + }, 2087 + .link_libraries = &[_]*std.Build.Step.Compile{ 2088 + libplugin, 2089 + libpluginbitmaps, 2090 + libfixedpoint, 2091 + }, 2092 + }); 2093 + rocks.dependOn(random_folder_advance_config); 2094 + 2095 + const rb_info = try build_plugin(b, .{ 2096 + .name = "rb_info", 2097 + .target = target, 2098 + .optimize = optimize, 2099 + .sources = &[_][]const u8{ 2100 + "apps/plugins/rb_info.c", 2101 + "apps/plugins/plugin_crt0.c", 2102 + }, 2103 + .link_libraries = &[_]*std.Build.Step.Compile{ 2104 + libplugin, 2105 + libpluginbitmaps, 2106 + libfixedpoint, 2107 + }, 2108 + }); 2109 + rocks.dependOn(rb_info); 2110 + 2111 + const rockblox = try build_plugin(b, .{ 2112 + .name = "rockblox", 2113 + .target = target, 2114 + .optimize = optimize, 2115 + .sources = &[_][]const u8{ 2116 + "apps/plugins/rockblox.c", 2117 + "apps/plugins/plugin_crt0.c", 2118 + }, 2119 + .link_libraries = &[_]*std.Build.Step.Compile{ 2120 + libplugin, 2121 + libpluginbitmaps, 2122 + libfixedpoint, 2123 + }, 2124 + }); 2125 + rocks.dependOn(rockblox); 2126 + 2127 + const settings_dumper = try build_plugin(b, .{ 2128 + .name = "settings_dumper", 2129 + .target = target, 2130 + .optimize = optimize, 2131 + .sources = &[_][]const u8{ 2132 + "apps/plugins/settings_dumper.c", 2133 + "apps/plugins/plugin_crt0.c", 2134 + }, 2135 + .link_libraries = &[_]*std.Build.Step.Compile{ 2136 + libplugin, 2137 + libpluginbitmaps, 2138 + libfixedpoint, 2139 + }, 2140 + }); 2141 + rocks.dependOn(settings_dumper); 2142 + 2143 + const snow = try build_plugin(b, .{ 2144 + .name = "snow", 2145 + .target = target, 2146 + .optimize = optimize, 2147 + .sources = &[_][]const u8{ 2148 + "apps/plugins/snow.c", 2149 + "apps/plugins/plugin_crt0.c", 2150 + }, 2151 + .link_libraries = &[_]*std.Build.Step.Compile{ 2152 + libplugin, 2153 + libpluginbitmaps, 2154 + libfixedpoint, 2155 + }, 2156 + }); 2157 + rocks.dependOn(snow); 2158 + 2159 + const stats = try build_plugin(b, .{ 2160 + .name = "stats", 2161 + .target = target, 2162 + .optimize = optimize, 2163 + .sources = &[_][]const u8{ 2164 + "apps/plugins/stats.c", 2165 + "apps/plugins/plugin_crt0.c", 2166 + }, 2167 + .link_libraries = &[_]*std.Build.Step.Compile{ 2168 + libplugin, 2169 + libpluginbitmaps, 2170 + libfixedpoint, 2171 + }, 2172 + }); 2173 + rocks.dependOn(stats); 2174 + 2175 + const stopwatch = try build_plugin(b, .{ 2176 + .name = "stopwatch", 2177 + .target = target, 2178 + .optimize = optimize, 2179 + .sources = &[_][]const u8{ 2180 + "apps/plugins/stopwatch.c", 2181 + "apps/plugins/plugin_crt0.c", 2182 + }, 2183 + .link_libraries = &[_]*std.Build.Step.Compile{ 2184 + libplugin, 2185 + libpluginbitmaps, 2186 + libfixedpoint, 2187 + }, 2188 + }); 2189 + rocks.dependOn(stopwatch); 2190 + 2191 + const md5sum = try build_plugin(b, .{ 2192 + .name = "md5sum", 2193 + .target = target, 2194 + .optimize = optimize, 2195 + .sources = &[_][]const u8{ 2196 + "apps/plugins/md5sum.c", 2197 + "apps/plugins/plugin_crt0.c", 2198 + }, 2199 + .link_libraries = &[_]*std.Build.Step.Compile{ 2200 + libplugin, 2201 + libpluginbitmaps, 2202 + libfixedpoint, 2203 + }, 2204 + }); 2205 + rocks.dependOn(md5sum); 2206 + 2207 + const dice = try build_plugin(b, .{ 2208 + .name = "dice", 2209 + .target = target, 2210 + .optimize = optimize, 2211 + .sources = &[_][]const u8{ 2212 + "apps/plugins/dice.c", 2213 + "apps/plugins/plugin_crt0.c", 2214 + }, 2215 + .link_libraries = &[_]*std.Build.Step.Compile{ 2216 + libplugin, 2217 + libpluginbitmaps, 2218 + libfixedpoint, 2219 + }, 2220 + }); 2221 + rocks.dependOn(dice); 2222 + 2223 + const disktidy = try build_plugin(b, .{ 2224 + .name = "disktidy", 2225 + .target = target, 2226 + .optimize = optimize, 2227 + .sources = &[_][]const u8{ 2228 + "apps/plugins/disktidy.c", 2229 + "apps/plugins/plugin_crt0.c", 2230 + }, 2231 + .link_libraries = &[_]*std.Build.Step.Compile{ 2232 + libplugin, 2233 + libpluginbitmaps, 2234 + libfixedpoint, 2235 + }, 2236 + }); 2237 + rocks.dependOn(disktidy); 2238 + 2239 + const flipit = try build_plugin(b, .{ 2240 + .name = "flipit", 2241 + .target = target, 2242 + .optimize = optimize, 2243 + .sources = &[_][]const u8{ 2244 + "apps/plugins/flipit.c", 2245 + "apps/plugins/plugin_crt0.c", 2246 + }, 2247 + .link_libraries = &[_]*std.Build.Step.Compile{ 2248 + libplugin, 2249 + libpluginbitmaps, 2250 + libfixedpoint, 2251 + }, 2252 + }); 2253 + rocks.dependOn(flipit); 2254 + 2255 + const shopper = try build_plugin(b, .{ 2256 + .name = "shopper", 2257 + .target = target, 2258 + .optimize = optimize, 2259 + .sources = &[_][]const u8{ 2260 + "apps/plugins/shopper.c", 2261 + "apps/plugins/plugin_crt0.c", 2262 + }, 2263 + .link_libraries = &[_]*std.Build.Step.Compile{ 2264 + libplugin, 2265 + libpluginbitmaps, 2266 + libfixedpoint, 2267 + }, 2268 + }); 2269 + rocks.dependOn(shopper); 2270 + 2271 + const resistor = try build_plugin(b, .{ 2272 + .name = "resistor", 2273 + .target = target, 2274 + .optimize = optimize, 2275 + .sources = &[_][]const u8{ 2276 + "apps/plugins/resistor.c", 2277 + "apps/plugins/plugin_crt0.c", 2278 + }, 2279 + .link_libraries = &[_]*std.Build.Step.Compile{ 2280 + libplugin, 2281 + libpluginbitmaps, 2282 + libfixedpoint, 2283 + }, 2284 + }); 2285 + rocks.dependOn(resistor); 2286 + 2287 + const otp = try build_plugin(b, .{ 2288 + .name = "otp", 2289 + .target = target, 2290 + .optimize = optimize, 2291 + .sources = &[_][]const u8{ 2292 + "apps/plugins/otp.c", 2293 + "apps/plugins/plugin_crt0.c", 2294 + }, 2295 + .link_libraries = &[_]*std.Build.Step.Compile{ 2296 + libplugin, 2297 + libpluginbitmaps, 2298 + libfixedpoint, 2299 + }, 2300 + }); 2301 + rocks.dependOn(otp); 2302 + 2303 + const mp3_encoder = try build_plugin(b, .{ 2304 + .name = "mp3_encoder", 2305 + .target = target, 2306 + .optimize = optimize, 2307 + .sources = &[_][]const u8{ 2308 + "apps/plugins/mp3_encoder.c", 2309 + "apps/plugins/plugin_crt0.c", 2310 + }, 2311 + .link_libraries = &[_]*std.Build.Step.Compile{ 2312 + libplugin, 2313 + libpluginbitmaps, 2314 + libfixedpoint, 2315 + }, 2316 + }); 2317 + rocks.dependOn(mp3_encoder); 2318 + 2319 + const wav2wv = try build_plugin(b, .{ 2320 + .name = "wav2wv", 2321 + .target = target, 2322 + .optimize = optimize, 2323 + .sources = &[_][]const u8{ 2324 + "apps/plugins/wav2wv.c", 2325 + "apps/plugins/plugin_crt0.c", 2326 + }, 2327 + .link_libraries = &[_]*std.Build.Step.Compile{ 2328 + libplugin, 2329 + libpluginbitmaps, 2330 + libfixedpoint, 2331 + }, 2332 + }); 2333 + rocks.dependOn(wav2wv); 2334 + 2335 + const zxbox = try build_plugin(b, .{ 2336 + .name = "zxbox", 2337 + .target = target, 2338 + .optimize = optimize, 2339 + .sources = &[_][]const u8{ 2340 + "apps/plugins/zxbox.c", 2341 + "apps/plugins/plugin_crt0.c", 2342 + }, 2343 + .link_libraries = &[_]*std.Build.Step.Compile{ 2344 + libplugin, 2345 + libpluginbitmaps, 2346 + libfixedpoint, 2347 + }, 2348 + }); 2349 + rocks.dependOn(zxbox); 2350 + 2351 + const chessbox = try build_plugin(b, .{ 2352 + .name = "chessbox", 2353 + .target = target, 2354 + .optimize = optimize, 2355 + .sources = &[_][]const u8{ 2356 + "apps/plugins/chessbox.c", 2357 + "apps/plugins/plugin_crt0.c", 2358 + }, 2359 + .link_libraries = &[_]*std.Build.Step.Compile{ 2360 + libplugin, 2361 + libpluginbitmaps, 2362 + libfixedpoint, 2363 + }, 2364 + }); 2365 + rocks.dependOn(chessbox); 2366 + 2367 + const goban = try build_plugin(b, .{ 2368 + .name = "goban", 2369 + .target = target, 2370 + .optimize = optimize, 2371 + .sources = &[_][]const u8{ 2372 + "apps/plugins/goban.c", 2373 + "apps/plugins/plugin_crt0.c", 2374 + }, 2375 + .link_libraries = &[_]*std.Build.Step.Compile{ 2376 + libplugin, 2377 + libpluginbitmaps, 2378 + libfixedpoint, 2379 + }, 2380 + }); 2381 + rocks.dependOn(goban); 2382 + 2383 + const metronome = try build_plugin(b, .{ 2384 + .name = "metronome", 2385 + .target = target, 2386 + .optimize = optimize, 2387 + .sources = &[_][]const u8{ 2388 + "apps/plugins/metronome.c", 2389 + "apps/plugins/plugin_crt0.c", 2390 + }, 2391 + .link_libraries = &[_]*std.Build.Step.Compile{ 2392 + libplugin, 2393 + libpluginbitmaps, 2394 + libfixedpoint, 2395 + }, 2396 + }); 2397 + rocks.dependOn(metronome); 2398 + 2399 + const _2048 = try build_plugin(b, .{ 2400 + .name = "2048", 2401 + .target = target, 2402 + .optimize = optimize, 2403 + .sources = &[_][]const u8{ 2404 + "apps/plugins/2048.c", 2405 + "apps/plugins/plugin_crt0.c", 2406 + }, 2407 + .link_libraries = &[_]*std.Build.Step.Compile{ 2408 + libplugin, 2409 + libpluginbitmaps, 2410 + libfixedpoint, 2411 + }, 2412 + }); 2413 + rocks.dependOn(_2048); 2414 + 2415 + const amaze = try build_plugin(b, .{ 2416 + .name = "amaze", 2417 + .target = target, 2418 + .optimize = optimize, 2419 + .sources = &[_][]const u8{ 2420 + "apps/plugins/amaze.c", 2421 + "apps/plugins/plugin_crt0.c", 2422 + }, 2423 + .link_libraries = &[_]*std.Build.Step.Compile{ 2424 + libplugin, 2425 + libpluginbitmaps, 2426 + libfixedpoint, 2427 + }, 2428 + }); 2429 + rocks.dependOn(amaze); 2430 + 2431 + const rockblox1d = try build_plugin(b, .{ 2432 + .name = "rockblox1d", 2433 + .target = target, 2434 + .optimize = optimize, 2435 + .sources = &[_][]const u8{ 2436 + "apps/plugins/rockblox1d.c", 2437 + "apps/plugins/plugin_crt0.c", 2438 + }, 2439 + .link_libraries = &[_]*std.Build.Step.Compile{ 2440 + libplugin, 2441 + libpluginbitmaps, 2442 + libfixedpoint, 2443 + }, 2444 + }); 2445 + rocks.dependOn(rockblox1d); 2446 + 2447 + const brickmania = try build_plugin(b, .{ 2448 + .name = "brickmania", 2449 + .target = target, 2450 + .optimize = optimize, 2451 + .sources = &[_][]const u8{ 2452 + "apps/plugins/brickmania.c", 2453 + "apps/plugins/plugin_crt0.c", 2454 + }, 2455 + .link_libraries = &[_]*std.Build.Step.Compile{ 2456 + libplugin, 2457 + libpluginbitmaps, 2458 + libfixedpoint, 2459 + }, 2460 + }); 2461 + rocks.dependOn(brickmania); 2462 + 2463 + const calendar = try build_plugin(b, .{ 2464 + .name = "calendar", 2465 + .target = target, 2466 + .optimize = optimize, 2467 + .sources = &[_][]const u8{ 2468 + "apps/plugins/calendar.c", 2469 + "apps/plugins/plugin_crt0.c", 2470 + }, 2471 + .link_libraries = &[_]*std.Build.Step.Compile{ 2472 + libplugin, 2473 + libpluginbitmaps, 2474 + libfixedpoint, 2475 + }, 2476 + }); 2477 + rocks.dependOn(calendar); 2478 + 2479 + const mazezam = try build_plugin(b, .{ 2480 + .name = "mazezam", 2481 + .target = target, 2482 + .optimize = optimize, 2483 + .sources = &[_][]const u8{ 2484 + "apps/plugins/mazezam.c", 2485 + "apps/plugins/plugin_crt0.c", 2486 + }, 2487 + .link_libraries = &[_]*std.Build.Step.Compile{ 2488 + libplugin, 2489 + libpluginbitmaps, 2490 + libfixedpoint, 2491 + }, 2492 + }); 2493 + rocks.dependOn(mazezam); 2494 + 2495 + const wavview = try build_plugin(b, .{ 2496 + .name = "wavview", 2497 + .target = target, 2498 + .optimize = optimize, 2499 + .sources = &[_][]const u8{ 2500 + "apps/plugins/wavview.c", 2501 + "apps/plugins/plugin_crt0.c", 2502 + }, 2503 + .link_libraries = &[_]*std.Build.Step.Compile{ 2504 + libplugin, 2505 + libpluginbitmaps, 2506 + libfixedpoint, 2507 + }, 2508 + }); 2509 + rocks.dependOn(wavview); 2510 + 2511 + const robotfindskitten = try build_plugin(b, .{ 2512 + .name = "robotfindskitten", 2513 + .target = target, 2514 + .optimize = optimize, 2515 + .sources = &[_][]const u8{ 2516 + "apps/plugins/robotfindskitten.c", 2517 + "apps/plugins/plugin_crt0.c", 2518 + }, 2519 + .link_libraries = &[_]*std.Build.Step.Compile{ 2520 + libplugin, 2521 + libpluginbitmaps, 2522 + libfixedpoint, 2523 + }, 2524 + }); 2525 + rocks.dependOn(robotfindskitten); 2526 + 2527 + const xobox = try build_plugin(b, .{ 2528 + .name = "xobox", 2529 + .target = target, 2530 + .optimize = optimize, 2531 + .sources = &[_][]const u8{ 2532 + "apps/plugins/xobox.c", 2533 + "apps/plugins/plugin_crt0.c", 2534 + }, 2535 + .link_libraries = &[_]*std.Build.Step.Compile{ 2536 + libplugin, 2537 + libpluginbitmaps, 2538 + libfixedpoint, 2539 + }, 2540 + }); 2541 + rocks.dependOn(xobox); 2542 + 2543 + const spacerocks = try build_plugin(b, .{ 2544 + .name = "spacerocks", 2545 + .target = target, 2546 + .optimize = optimize, 2547 + .sources = &[_][]const u8{ 2548 + "apps/plugins/spacerocks.c", 2549 + "apps/plugins/plugin_crt0.c", 2550 + }, 2551 + .link_libraries = &[_]*std.Build.Step.Compile{ 2552 + libplugin, 2553 + libpluginbitmaps, 2554 + libfixedpoint, 2555 + }, 2556 + }); 2557 + rocks.dependOn(spacerocks); 2558 + 2559 + const bounce = try build_plugin(b, .{ 2560 + .name = "bounce", 2561 + .target = target, 2562 + .optimize = optimize, 2563 + .sources = &[_][]const u8{ 2564 + "apps/plugins/bounce.c", 2565 + "apps/plugins/plugin_crt0.c", 2566 + }, 2567 + .link_libraries = &[_]*std.Build.Step.Compile{ 2568 + libplugin, 2569 + libpluginbitmaps, 2570 + libfixedpoint, 2571 + }, 2572 + }); 2573 + rocks.dependOn(bounce); 2574 + 2575 + const bubbles = try build_plugin(b, .{ 2576 + .name = "bubbles", 2577 + .target = target, 2578 + .optimize = optimize, 2579 + .sources = &[_][]const u8{ 2580 + "apps/plugins/bubbles.c", 2581 + "apps/plugins/plugin_crt0.c", 2582 + }, 2583 + .link_libraries = &[_]*std.Build.Step.Compile{ 2584 + libplugin, 2585 + libpluginbitmaps, 2586 + libfixedpoint, 2587 + }, 2588 + }); 2589 + rocks.dependOn(bubbles); 2590 + 2591 + const calculator = try build_plugin(b, .{ 2592 + .name = "calculator", 2593 + .target = target, 2594 + .optimize = optimize, 2595 + .sources = &[_][]const u8{ 2596 + "apps/plugins/calculator.c", 2597 + "apps/plugins/plugin_crt0.c", 2598 + }, 2599 + .link_libraries = &[_]*std.Build.Step.Compile{ 2600 + libplugin, 2601 + libpluginbitmaps, 2602 + libfixedpoint, 2603 + }, 2604 + }); 2605 + rocks.dependOn(calculator); 2606 + 2607 + const chip8 = try build_plugin(b, .{ 2608 + .name = "chip8", 2609 + .target = target, 2610 + .optimize = optimize, 2611 + .sources = &[_][]const u8{ 2612 + "apps/plugins/chip8.c", 2613 + "apps/plugins/plugin_crt0.c", 2614 + }, 2615 + .link_libraries = &[_]*std.Build.Step.Compile{ 2616 + libplugin, 2617 + libpluginbitmaps, 2618 + libfixedpoint, 2619 + }, 2620 + }); 2621 + rocks.dependOn(chip8); 2622 + 2623 + const demystify = try build_plugin(b, .{ 2624 + .name = "demystify", 2625 + .target = target, 2626 + .optimize = optimize, 2627 + .sources = &[_][]const u8{ 2628 + "apps/plugins/demystify.c", 2629 + "apps/plugins/plugin_crt0.c", 2630 + }, 2631 + .link_libraries = &[_]*std.Build.Step.Compile{ 2632 + libplugin, 2633 + libpluginbitmaps, 2634 + libfixedpoint, 2635 + }, 2636 + }); 2637 + rocks.dependOn(demystify); 2638 + 2639 + const jewels = try build_plugin(b, .{ 2640 + .name = "jewels", 2641 + .target = target, 2642 + .optimize = optimize, 2643 + .sources = &[_][]const u8{ 2644 + "apps/plugins/jewels.c", 2645 + "apps/plugins/plugin_crt0.c", 2646 + }, 2647 + .link_libraries = &[_]*std.Build.Step.Compile{ 2648 + libplugin, 2649 + libpluginbitmaps, 2650 + libfixedpoint, 2651 + }, 2652 + }); 2653 + rocks.dependOn(jewels); 2654 + 2655 + const minesweeper = try build_plugin(b, .{ 2656 + .name = "minesweeper", 2657 + .target = target, 2658 + .optimize = optimize, 2659 + .sources = &[_][]const u8{ 2660 + "apps/plugins/minesweeper.c", 2661 + "apps/plugins/plugin_crt0.c", 2662 + }, 2663 + .link_libraries = &[_]*std.Build.Step.Compile{ 2664 + libplugin, 2665 + libpluginbitmaps, 2666 + libfixedpoint, 2667 + }, 2668 + }); 2669 + rocks.dependOn(minesweeper); 2670 + 2671 + const open_plugins = try build_plugin(b, .{ 2672 + .name = "open_plugins", 2673 + .target = target, 2674 + .optimize = optimize, 2675 + .sources = &[_][]const u8{ 2676 + "apps/plugins/open_plugins.c", 2677 + "apps/plugins/plugin_crt0.c", 2678 + }, 2679 + .link_libraries = &[_]*std.Build.Step.Compile{ 2680 + libplugin, 2681 + libpluginbitmaps, 2682 + libfixedpoint, 2683 + }, 2684 + }); 2685 + rocks.dependOn(open_plugins); 2686 + 2687 + const oscilloscope = try build_plugin(b, .{ 2688 + .name = "oscilloscope", 2689 + .target = target, 2690 + .optimize = optimize, 2691 + .sources = &[_][]const u8{ 2692 + "apps/plugins/oscilloscope.c", 2693 + "apps/plugins/plugin_crt0.c", 2694 + }, 2695 + .link_libraries = &[_]*std.Build.Step.Compile{ 2696 + libplugin, 2697 + libpluginbitmaps, 2698 + libfixedpoint, 2699 + }, 2700 + }); 2701 + rocks.dependOn(oscilloscope); 2702 + 2703 + const pegbox = try build_plugin(b, .{ 2704 + .name = "pegbox", 2705 + .target = target, 2706 + .optimize = optimize, 2707 + .sources = &[_][]const u8{ 2708 + "apps/plugins/pegbox.c", 2709 + "apps/plugins/plugin_crt0.c", 2710 + }, 2711 + .link_libraries = &[_]*std.Build.Step.Compile{ 2712 + libplugin, 2713 + libpluginbitmaps, 2714 + libfixedpoint, 2715 + }, 2716 + }); 2717 + rocks.dependOn(pegbox); 2718 + 2719 + const periodic_table = try build_plugin(b, .{ 2720 + .name = "periodic_table", 2721 + .target = target, 2722 + .optimize = optimize, 2723 + .sources = &[_][]const u8{ 2724 + "apps/plugins/periodic_table.c", 2725 + "apps/plugins/plugin_crt0.c", 2726 + }, 2727 + .link_libraries = &[_]*std.Build.Step.Compile{ 2728 + libplugin, 2729 + libpluginbitmaps, 2730 + libfixedpoint, 2731 + }, 2732 + }); 2733 + rocks.dependOn(periodic_table); 2734 + 2735 + const pong = try build_plugin(b, .{ 2736 + .name = "pong", 2737 + .target = target, 2738 + .optimize = optimize, 2739 + .sources = &[_][]const u8{ 2740 + "apps/plugins/pong.c", 2741 + "apps/plugins/plugin_crt0.c", 2742 + }, 2743 + .link_libraries = &[_]*std.Build.Step.Compile{ 2744 + libplugin, 2745 + libpluginbitmaps, 2746 + libfixedpoint, 2747 + }, 2748 + }); 2749 + rocks.dependOn(pong); 2750 + 2751 + const sliding_puzzle = try build_plugin(b, .{ 2752 + .name = "sliding_puzzle", 2753 + .target = target, 2754 + .optimize = optimize, 2755 + .sources = &[_][]const u8{ 2756 + "apps/plugins/sliding_puzzle.c", 2757 + "apps/plugins/plugin_crt0.c", 2758 + }, 2759 + .link_libraries = &[_]*std.Build.Step.Compile{ 2760 + libplugin, 2761 + libpluginbitmaps, 2762 + libfixedpoint, 2763 + }, 2764 + }); 2765 + rocks.dependOn(sliding_puzzle); 2766 + 2767 + const snake = try build_plugin(b, .{ 2768 + .name = "snake", 2769 + .target = target, 2770 + .optimize = optimize, 2771 + .sources = &[_][]const u8{ 2772 + "apps/plugins/snake.c", 2773 + "apps/plugins/plugin_crt0.c", 2774 + }, 2775 + .link_libraries = &[_]*std.Build.Step.Compile{ 2776 + libplugin, 2777 + libpluginbitmaps, 2778 + libfixedpoint, 2779 + }, 2780 + }); 2781 + rocks.dependOn(snake); 2782 + 2783 + const snake2 = try build_plugin(b, .{ 2784 + .name = "snake2", 2785 + .target = target, 2786 + .optimize = optimize, 2787 + .sources = &[_][]const u8{ 2788 + "apps/plugins/snake2.c", 2789 + "apps/plugins/plugin_crt0.c", 2790 + }, 2791 + .link_libraries = &[_]*std.Build.Step.Compile{ 2792 + libplugin, 2793 + libpluginbitmaps, 2794 + libfixedpoint, 2795 + }, 2796 + }); 2797 + rocks.dependOn(snake2); 2798 + 2799 + const solitaire = try build_plugin(b, .{ 2800 + .name = "solitaire", 2801 + .target = target, 2802 + .optimize = optimize, 2803 + .sources = &[_][]const u8{ 2804 + "apps/plugins/solitaire.c", 2805 + "apps/plugins/plugin_crt0.c", 2806 + }, 2807 + .link_libraries = &[_]*std.Build.Step.Compile{ 2808 + libplugin, 2809 + libpluginbitmaps, 2810 + libfixedpoint, 2811 + }, 2812 + }); 2813 + rocks.dependOn(solitaire); 2814 + 2815 + const sokoban = try build_plugin(b, .{ 2816 + .name = "sokoban", 2817 + .target = target, 2818 + .optimize = optimize, 2819 + .sources = &[_][]const u8{ 2820 + "apps/plugins/sokoban.c", 2821 + "apps/plugins/plugin_crt0.c", 2822 + }, 2823 + .link_libraries = &[_]*std.Build.Step.Compile{ 2824 + libplugin, 2825 + libpluginbitmaps, 2826 + libfixedpoint, 2827 + }, 2828 + }); 2829 + rocks.dependOn(sokoban); 2830 + 2831 + const star = try build_plugin(b, .{ 2832 + .name = "star", 2833 + .target = target, 2834 + .optimize = optimize, 2835 + .sources = &[_][]const u8{ 2836 + "apps/plugins/star.c", 2837 + "apps/plugins/plugin_crt0.c", 2838 + }, 2839 + .link_libraries = &[_]*std.Build.Step.Compile{ 2840 + libplugin, 2841 + libpluginbitmaps, 2842 + libfixedpoint, 2843 + }, 2844 + }); 2845 + rocks.dependOn(star); 2846 + 2847 + const vu_meter = try build_plugin(b, .{ 2848 + .name = "vu_meter", 2849 + .target = target, 2850 + .optimize = optimize, 2851 + .sources = &[_][]const u8{ 2852 + "apps/plugins/vu_meter.c", 2853 + "apps/plugins/plugin_crt0.c", 2854 + }, 2855 + .link_libraries = &[_]*std.Build.Step.Compile{ 2856 + libplugin, 2857 + libpluginbitmaps, 2858 + libfixedpoint, 2859 + }, 2860 + }); 2861 + rocks.dependOn(vu_meter); 2862 + 2863 + const wormlet = try build_plugin(b, .{ 2864 + .name = "wormlet", 2865 + .target = target, 2866 + .optimize = optimize, 2867 + .sources = &[_][]const u8{ 2868 + "apps/plugins/wormlet.c", 2869 + "apps/plugins/plugin_crt0.c", 2870 + }, 2871 + .link_libraries = &[_]*std.Build.Step.Compile{ 2872 + libplugin, 2873 + libpluginbitmaps, 2874 + libfixedpoint, 2875 + }, 2876 + }); 2877 + rocks.dependOn(wormlet); 1771 2878 1772 2879 defineCMacros(exe); 1773 2880 addIncludePaths(exe); ··· 2205 3312 mk500boot.linkLibC(); 2206 3313 } 2207 3314 2208 - fn build_codec(b: *std.Build, options: BuildOptions) void { 3315 + fn build_codec(b: *std.Build, options: BuildOptions) !*std.Build.Step { 2209 3316 const codec_lib = b.addStaticLibrary(.{ 2210 3317 .name = options.name, 2211 3318 .target = options.target, ··· 2251 3358 codec.linkLibrary(lib); 2252 3359 } 2253 3360 codec.linkLibrary(codec_lib); 3361 + 3362 + var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); 3363 + defer arena.deinit(); 3364 + 3365 + var from = String.init(arena.allocator()); 3366 + defer from.deinit(); 3367 + try from.concat("zig-out/lib/lib"); 3368 + try from.concat(options.name); 3369 + try from.concat(".so"); 3370 + 3371 + var to = String.init(arena.allocator()); 3372 + defer to.deinit(); 3373 + try to.concat("zig-out/lib/"); 3374 + try to.concat(options.name); 3375 + try to.concat(".codec"); 3376 + 3377 + const info = b.addSystemCommand(&[_][]const u8{ 3378 + "echo", "Generating", options.name, "codec", 3379 + }); 3380 + const codec_file = b.addSystemCommand(&[_][]const u8{ 3381 + "mv", "-f", from.str(), to.str(), 3382 + }); 3383 + codec_file.step.dependOn(b.getInstallStep()); 3384 + info.step.dependOn(&codec.step); 3385 + codec_file.step.dependOn(&info.step); 3386 + 3387 + return &codec_file.step; 2254 3388 } 2255 3389 2256 - fn build_plugin(b: *std.Build, options: BuildOptions) void { 3390 + fn build_plugin(b: *std.Build, options: BuildOptions) !*std.Build.Step { 2257 3391 const plugin = b.addSharedLibrary(.{ 2258 3392 .name = options.name, 2259 3393 .target = options.target, ··· 2284 3418 for (options.link_libraries) |lib| { 2285 3419 plugin.linkLibrary(lib); 2286 3420 } 3421 + 3422 + var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); 3423 + defer arena.deinit(); 3424 + 3425 + var from = String.init(arena.allocator()); 3426 + defer from.deinit(); 3427 + try from.concat("zig-out/lib/lib"); 3428 + try from.concat(options.name); 3429 + try from.concat(".so"); 3430 + 3431 + var to = String.init(arena.allocator()); 3432 + defer to.deinit(); 3433 + try to.concat("zig-out/lib/"); 3434 + try to.concat(options.name); 3435 + try to.concat(".rock"); 3436 + 3437 + const info = b.addSystemCommand(&[_][]const u8{ 3438 + "echo", "Generating", options.name, "rock", "file", 3439 + }); 3440 + const rock_file = b.addSystemCommand(&[_][]const u8{ 3441 + "mv", "-f", from.str(), to.str(), 3442 + }); 3443 + rock_file.step.dependOn(b.getInstallStep()); 3444 + info.step.dependOn(&plugin.step); 3445 + rock_file.step.dependOn(&info.step); 3446 + 3447 + return &rock_file.step; 2287 3448 } 2288 3449 2289 3450 fn defineCMacros(c: *std.Build.Step.Compile) void {
+3 -50
src/main.zig
··· 1 1 const std = @import("std"); 2 2 3 - pub fn main() !void { 4 - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; 5 - const allocator = gpa.allocator(); 6 - 7 - var file = try std.fs.cwd().openFile("build/make.dep", .{}); 8 - defer file.close(); 9 - 10 - var buffered = std.io.bufferedReader(file.reader()); 11 - var reader = buffered.reader(); 3 + extern fn main_c() c_int; 12 4 13 - var arr = std.ArrayList(u8).init(allocator); 14 - defer arr.deinit(); 15 - 16 - var line_count: usize = 0; 17 - var byte_count: usize = 0; 18 - while (true) { 19 - reader.streamUntilDelimiter(arr.writer(), '\n', null) catch |err| switch (err) { 20 - error.EndOfStream => break, 21 - else => return err, 22 - }; 23 - line_count += 1; 24 - byte_count += arr.items.len; 25 - 26 - //if (std.mem.containsAtLeast(u8, arr.items, 1, ".c \\")) { 27 - // std.debug.print("{s}\n", .{arr.items}); 28 - //} 29 - 30 - arr.clearRetainingCapacity(); 31 - } 32 - std.debug.print("{d} lines, {d} bytes\n", .{ line_count, byte_count }); 33 - 34 - // Prints to stderr (it's a shortcut based on `std.io.getStdErr()`) 35 - std.debug.print("All your {s} are belong to us.\n", .{"codebase"}); 36 - 37 - // stdout is for the actual output of your application, for example if you 38 - // are implementing gzip, then only the compressed bytes should be sent to 39 - // stdout, not any debugging messages. 40 - const stdout_file = std.io.getStdOut().writer(); 41 - var bw = std.io.bufferedWriter(stdout_file); 42 - const stdout = bw.writer(); 43 - 44 - try stdout.print("Run `zig build test` to run the tests.\n", .{}); 45 - 46 - try bw.flush(); // don't forget to flush! 47 - } 48 - 49 - test "simple test" { 50 - var list = std.ArrayList(i32).init(std.testing.allocator); 51 - defer list.deinit(); // try commenting this out and see if zig detects the memory leak! 52 - try list.append(42); 53 - try std.testing.expectEqual(@as(i32, 42), list.pop()); 5 + pub fn main() !void { 6 + _ = main_c(); 54 7 }
+609
string.zig
··· 1 + const std = @import("std"); 2 + const assert = std.debug.assert; 3 + const builtin = @import("builtin"); 4 + 5 + /// A variable length collection of characters 6 + pub const String = struct { 7 + /// The internal character buffer 8 + buffer: ?[]u8, 9 + /// The allocator used for managing the buffer 10 + allocator: std.mem.Allocator, 11 + /// The total size of the String 12 + size: usize, 13 + 14 + /// Errors that may occur when using String 15 + pub const Error = error{ 16 + OutOfMemory, 17 + InvalidRange, 18 + }; 19 + 20 + /// Creates a String with an Allocator 21 + /// ### example 22 + /// ```zig 23 + /// var str = String.init(allocator); 24 + /// // don't forget to deallocate 25 + /// defer _ = str.deinit(); 26 + /// ``` 27 + /// User is responsible for managing the new String 28 + pub fn init(allocator: std.mem.Allocator) String { 29 + // for windows non-ascii characters 30 + // check if the system is windows 31 + if (builtin.os.tag == std.Target.Os.Tag.windows) { 32 + _ = std.os.windows.kernel32.SetConsoleOutputCP(65001); 33 + } 34 + 35 + return .{ 36 + .buffer = null, 37 + .allocator = allocator, 38 + .size = 0, 39 + }; 40 + } 41 + 42 + pub fn init_with_contents(allocator: std.mem.Allocator, contents: []const u8) Error!String { 43 + var string = init(allocator); 44 + 45 + try string.concat(contents); 46 + 47 + return string; 48 + } 49 + 50 + /// Deallocates the internal buffer 51 + /// ### usage: 52 + /// ```zig 53 + /// var str = String.init(allocator); 54 + /// // deinit after the closure 55 + /// defer _ = str.deinit(); 56 + /// ``` 57 + pub fn deinit(self: *String) void { 58 + if (self.buffer) |buffer| self.allocator.free(buffer); 59 + } 60 + 61 + /// Returns the size of the internal buffer 62 + pub fn capacity(self: String) usize { 63 + if (self.buffer) |buffer| return buffer.len; 64 + return 0; 65 + } 66 + 67 + /// Allocates space for the internal buffer 68 + pub fn allocate(self: *String, bytes: usize) Error!void { 69 + if (self.buffer) |buffer| { 70 + if (bytes < self.size) self.size = bytes; // Clamp size to capacity 71 + self.buffer = self.allocator.realloc(buffer, bytes) catch { 72 + return Error.OutOfMemory; 73 + }; 74 + } else { 75 + self.buffer = self.allocator.alloc(u8, bytes) catch { 76 + return Error.OutOfMemory; 77 + }; 78 + } 79 + } 80 + 81 + /// Reallocates the the internal buffer to size 82 + pub fn truncate(self: *String) Error!void { 83 + try self.allocate(self.size); 84 + } 85 + 86 + /// Appends a character onto the end of the String 87 + pub fn concat(self: *String, char: []const u8) Error!void { 88 + try self.insert(char, self.len()); 89 + } 90 + 91 + /// Inserts a string literal into the String at an index 92 + pub fn insert(self: *String, literal: []const u8, index: usize) Error!void { 93 + // Make sure buffer has enough space 94 + if (self.buffer) |buffer| { 95 + if (self.size + literal.len > buffer.len) { 96 + try self.allocate((self.size + literal.len) * 2); 97 + } 98 + } else { 99 + try self.allocate((literal.len) * 2); 100 + } 101 + 102 + const buffer = self.buffer.?; 103 + 104 + // If the index is >= len, then simply push to the end. 105 + // If not, then copy contents over and insert literal. 106 + if (index == self.len()) { 107 + var i: usize = 0; 108 + while (i < literal.len) : (i += 1) { 109 + buffer[self.size + i] = literal[i]; 110 + } 111 + } else { 112 + if (String.getIndex(buffer, index, true)) |k| { 113 + // Move existing contents over 114 + var i: usize = buffer.len - 1; 115 + while (i >= k) : (i -= 1) { 116 + if (i + literal.len < buffer.len) { 117 + buffer[i + literal.len] = buffer[i]; 118 + } 119 + 120 + if (i == 0) break; 121 + } 122 + 123 + i = 0; 124 + while (i < literal.len) : (i += 1) { 125 + buffer[index + i] = literal[i]; 126 + } 127 + } 128 + } 129 + 130 + self.size += literal.len; 131 + } 132 + 133 + /// Removes the last character from the String 134 + pub fn pop(self: *String) ?[]const u8 { 135 + if (self.size == 0) return null; 136 + 137 + if (self.buffer) |buffer| { 138 + var i: usize = 0; 139 + while (i < self.size) { 140 + const size = String.getUTF8Size(buffer[i]); 141 + if (i + size >= self.size) break; 142 + i += size; 143 + } 144 + 145 + const ret = buffer[i..self.size]; 146 + self.size -= (self.size - i); 147 + return ret; 148 + } 149 + 150 + return null; 151 + } 152 + 153 + /// Compares this String with a string literal 154 + pub fn cmp(self: String, literal: []const u8) bool { 155 + if (self.buffer) |buffer| { 156 + return std.mem.eql(u8, buffer[0..self.size], literal); 157 + } 158 + return false; 159 + } 160 + 161 + /// Returns the String buffer as a string literal 162 + /// ### usage: 163 + ///```zig 164 + ///var mystr = try String.init_with_contents(allocator, "Test String!"); 165 + ///defer _ = mystr.deinit(); 166 + ///std.debug.print("{s}\n", .{mystr.str()}); 167 + ///``` 168 + pub fn str(self: String) []const u8 { 169 + if (self.buffer) |buffer| return buffer[0..self.size]; 170 + return ""; 171 + } 172 + 173 + /// Returns an owned slice of this string 174 + pub fn toOwned(self: String) Error!?[]u8 { 175 + if (self.buffer != null) { 176 + const string = self.str(); 177 + if (self.allocator.alloc(u8, string.len)) |newStr| { 178 + std.mem.copyForwards(u8, newStr, string); 179 + return newStr; 180 + } else |_| { 181 + return Error.OutOfMemory; 182 + } 183 + } 184 + 185 + return null; 186 + } 187 + 188 + /// Returns a character at the specified index 189 + pub fn charAt(self: String, index: usize) ?[]const u8 { 190 + if (self.buffer) |buffer| { 191 + if (String.getIndex(buffer, index, true)) |i| { 192 + const size = String.getUTF8Size(buffer[i]); 193 + return buffer[i..(i + size)]; 194 + } 195 + } 196 + return null; 197 + } 198 + 199 + /// Returns amount of characters in the String 200 + pub fn len(self: String) usize { 201 + if (self.buffer) |buffer| { 202 + var length: usize = 0; 203 + var i: usize = 0; 204 + 205 + while (i < self.size) { 206 + i += String.getUTF8Size(buffer[i]); 207 + length += 1; 208 + } 209 + 210 + return length; 211 + } else { 212 + return 0; 213 + } 214 + } 215 + 216 + /// Finds the first occurrence of the string literal 217 + pub fn find(self: String, literal: []const u8) ?usize { 218 + if (self.buffer) |buffer| { 219 + const index = std.mem.indexOf(u8, buffer[0..self.size], literal); 220 + if (index) |i| { 221 + return String.getIndex(buffer, i, false); 222 + } 223 + } 224 + 225 + return null; 226 + } 227 + 228 + /// Finds the last occurrence of the string literal 229 + pub fn rfind(self: String, literal: []const u8) ?usize { 230 + if (self.buffer) |buffer| { 231 + const index = std.mem.lastIndexOf(u8, buffer[0..self.size], literal); 232 + if (index) |i| { 233 + return String.getIndex(buffer, i, false); 234 + } 235 + } 236 + 237 + return null; 238 + } 239 + 240 + /// Removes a character at the specified index 241 + pub fn remove(self: *String, index: usize) Error!void { 242 + try self.removeRange(index, index + 1); 243 + } 244 + 245 + /// Removes a range of character from the String 246 + /// Start (inclusive) - End (Exclusive) 247 + pub fn removeRange(self: *String, start: usize, end: usize) Error!void { 248 + const length = self.len(); 249 + if (end < start or end > length) return Error.InvalidRange; 250 + 251 + if (self.buffer) |buffer| { 252 + const rStart = String.getIndex(buffer, start, true).?; 253 + const rEnd = String.getIndex(buffer, end, true).?; 254 + const difference = rEnd - rStart; 255 + 256 + var i: usize = rEnd; 257 + while (i < self.size) : (i += 1) { 258 + buffer[i - difference] = buffer[i]; 259 + } 260 + 261 + self.size -= difference; 262 + } 263 + } 264 + 265 + /// Trims all whitelist characters at the start of the String. 266 + pub fn trimStart(self: *String, whitelist: []const u8) void { 267 + if (self.buffer) |buffer| { 268 + var i: usize = 0; 269 + while (i < self.size) : (i += 1) { 270 + const size = String.getUTF8Size(buffer[i]); 271 + if (size > 1 or !inWhitelist(buffer[i], whitelist)) break; 272 + } 273 + 274 + if (String.getIndex(buffer, i, false)) |k| { 275 + self.removeRange(0, k) catch {}; 276 + } 277 + } 278 + } 279 + 280 + /// Trims all whitelist characters at the end of the String. 281 + pub fn trimEnd(self: *String, whitelist: []const u8) void { 282 + self.reverse(); 283 + self.trimStart(whitelist); 284 + self.reverse(); 285 + } 286 + 287 + /// Trims all whitelist characters from both ends of the String 288 + pub fn trim(self: *String, whitelist: []const u8) void { 289 + self.trimStart(whitelist); 290 + self.trimEnd(whitelist); 291 + } 292 + 293 + /// Copies this String into a new one 294 + /// User is responsible for managing the new String 295 + pub fn clone(self: String) Error!String { 296 + var newString = String.init(self.allocator); 297 + try newString.concat(self.str()); 298 + return newString; 299 + } 300 + 301 + /// Reverses the characters in this String 302 + pub fn reverse(self: *String) void { 303 + if (self.buffer) |buffer| { 304 + var i: usize = 0; 305 + while (i < self.size) { 306 + const size = String.getUTF8Size(buffer[i]); 307 + if (size > 1) std.mem.reverse(u8, buffer[i..(i + size)]); 308 + i += size; 309 + } 310 + 311 + std.mem.reverse(u8, buffer[0..self.size]); 312 + } 313 + } 314 + 315 + /// Repeats this String n times 316 + pub fn repeat(self: *String, n: usize) Error!void { 317 + try self.allocate(self.size * (n + 1)); 318 + if (self.buffer) |buffer| { 319 + for (1..n + 1) |i| { 320 + std.mem.copyForwards(u8, buffer[self.size * i ..], buffer[0..self.size]); 321 + } 322 + 323 + self.size *= (n + 1); 324 + } 325 + } 326 + 327 + /// Checks the String is empty 328 + pub inline fn isEmpty(self: String) bool { 329 + return self.size == 0; 330 + } 331 + 332 + /// Splits the String into a slice, based on a delimiter and an index 333 + pub fn split(self: *const String, delimiters: []const u8, index: usize) ?[]const u8 { 334 + if (self.buffer) |buffer| { 335 + var i: usize = 0; 336 + var block: usize = 0; 337 + var start: usize = 0; 338 + 339 + while (i < self.size) { 340 + const size = String.getUTF8Size(buffer[i]); 341 + if (size == delimiters.len) { 342 + if (std.mem.eql(u8, delimiters, buffer[i..(i + size)])) { 343 + if (block == index) return buffer[start..i]; 344 + start = i + size; 345 + block += 1; 346 + } 347 + } 348 + 349 + i += size; 350 + } 351 + 352 + if (i >= self.size - 1 and block == index) { 353 + return buffer[start..self.size]; 354 + } 355 + } 356 + 357 + return null; 358 + } 359 + 360 + /// Splits the String into slices, based on a delimiter. 361 + pub fn splitAll(self: *const String, delimiters: []const u8) ![][]const u8 { 362 + var splitArr = std.ArrayList([]const u8).init(std.heap.page_allocator); 363 + defer splitArr.deinit(); 364 + 365 + var i: usize = 0; 366 + while (self.split(delimiters, i)) |slice| : (i += 1) { 367 + try splitArr.append(slice); 368 + } 369 + 370 + return try splitArr.toOwnedSlice(); 371 + } 372 + 373 + /// Splits the String into a new string, based on delimiters and an index 374 + /// The user of this function is in charge of the memory of the new String. 375 + pub fn splitToString(self: *const String, delimiters: []const u8, index: usize) Error!?String { 376 + if (self.split(delimiters, index)) |block| { 377 + var string = String.init(self.allocator); 378 + try string.concat(block); 379 + return string; 380 + } 381 + 382 + return null; 383 + } 384 + 385 + /// Splits the String into a slice of new Strings, based on delimiters. 386 + /// The user of this function is in charge of the memory of the new Strings. 387 + pub fn splitAllToStrings(self: *const String, delimiters: []const u8) ![]String { 388 + var splitArr = std.ArrayList(String).init(std.heap.page_allocator); 389 + defer splitArr.deinit(); 390 + 391 + var i: usize = 0; 392 + while (try self.splitToString(delimiters, i)) |splitStr| : (i += 1) { 393 + try splitArr.append(splitStr); 394 + } 395 + 396 + return try splitArr.toOwnedSlice(); 397 + } 398 + 399 + /// Splits the String into a slice of Strings by new line (\r\n or \n). 400 + pub fn lines(self: *String) ![]String { 401 + var lineArr = std.ArrayList(String).init(std.heap.page_allocator); 402 + defer lineArr.deinit(); 403 + 404 + var selfClone = try self.clone(); 405 + defer selfClone.deinit(); 406 + 407 + _ = try selfClone.replace("\r\n", "\n"); 408 + 409 + return try selfClone.splitAllToStrings("\n"); 410 + } 411 + 412 + /// Clears the contents of the String but leaves the capacity 413 + pub fn clear(self: *String) void { 414 + if (self.buffer) |buffer| { 415 + for (buffer) |*ch| ch.* = 0; 416 + self.size = 0; 417 + } 418 + } 419 + 420 + /// Converts all (ASCII) uppercase letters to lowercase 421 + pub fn toLowercase(self: *String) void { 422 + if (self.buffer) |buffer| { 423 + var i: usize = 0; 424 + while (i < self.size) { 425 + const size = String.getUTF8Size(buffer[i]); 426 + if (size == 1) buffer[i] = std.ascii.toLower(buffer[i]); 427 + i += size; 428 + } 429 + } 430 + } 431 + 432 + /// Converts all (ASCII) uppercase letters to lowercase 433 + pub fn toUppercase(self: *String) void { 434 + if (self.buffer) |buffer| { 435 + var i: usize = 0; 436 + while (i < self.size) { 437 + const size = String.getUTF8Size(buffer[i]); 438 + if (size == 1) buffer[i] = std.ascii.toUpper(buffer[i]); 439 + i += size; 440 + } 441 + } 442 + } 443 + 444 + // Convert the first (ASCII) character of each word to uppercase 445 + pub fn toCapitalized(self: *String) void { 446 + if (self.size == 0) return; 447 + 448 + var buffer = self.buffer.?; 449 + var i: usize = 0; 450 + var is_new_word: bool = true; 451 + 452 + while (i < self.size) { 453 + const char = buffer[i]; 454 + 455 + if (std.ascii.isWhitespace(char)) { 456 + is_new_word = true; 457 + i += 1; 458 + continue; 459 + } 460 + 461 + if (is_new_word) { 462 + buffer[i] = std.ascii.toUpper(char); 463 + is_new_word = false; 464 + } 465 + 466 + i += 1; 467 + } 468 + } 469 + 470 + /// Creates a String from a given range 471 + /// User is responsible for managing the new String 472 + pub fn substr(self: String, start: usize, end: usize) Error!String { 473 + var result = String.init(self.allocator); 474 + 475 + if (self.buffer) |buffer| { 476 + if (String.getIndex(buffer, start, true)) |rStart| { 477 + if (String.getIndex(buffer, end, true)) |rEnd| { 478 + if (rEnd < rStart or rEnd > self.size) 479 + return Error.InvalidRange; 480 + try result.concat(buffer[rStart..rEnd]); 481 + } 482 + } 483 + } 484 + 485 + return result; 486 + } 487 + 488 + // Writer functionality for the String. 489 + pub usingnamespace struct { 490 + pub const Writer = std.io.Writer(*String, Error, appendWrite); 491 + 492 + pub fn writer(self: *String) Writer { 493 + return .{ .context = self }; 494 + } 495 + 496 + fn appendWrite(self: *String, m: []const u8) !usize { 497 + try self.concat(m); 498 + return m.len; 499 + } 500 + }; 501 + 502 + // Iterator support 503 + pub usingnamespace struct { 504 + pub const StringIterator = struct { 505 + string: *const String, 506 + index: usize, 507 + 508 + pub fn next(it: *StringIterator) ?[]const u8 { 509 + if (it.string.buffer) |buffer| { 510 + if (it.index == it.string.size) return null; 511 + const i = it.index; 512 + it.index += String.getUTF8Size(buffer[i]); 513 + return buffer[i..it.index]; 514 + } else { 515 + return null; 516 + } 517 + } 518 + }; 519 + 520 + pub fn iterator(self: *const String) StringIterator { 521 + return StringIterator{ 522 + .string = self, 523 + .index = 0, 524 + }; 525 + } 526 + }; 527 + 528 + /// Returns whether or not a character is whitelisted 529 + fn inWhitelist(char: u8, whitelist: []const u8) bool { 530 + var i: usize = 0; 531 + while (i < whitelist.len) : (i += 1) { 532 + if (whitelist[i] == char) return true; 533 + } 534 + 535 + return false; 536 + } 537 + 538 + /// Checks if byte is part of UTF-8 character 539 + inline fn isUTF8Byte(byte: u8) bool { 540 + return ((byte & 0x80) > 0) and (((byte << 1) & 0x80) == 0); 541 + } 542 + 543 + /// Returns the real index of a unicode string literal 544 + fn getIndex(unicode: []const u8, index: usize, real: bool) ?usize { 545 + var i: usize = 0; 546 + var j: usize = 0; 547 + while (i < unicode.len) { 548 + if (real) { 549 + if (j == index) return i; 550 + } else { 551 + if (i == index) return j; 552 + } 553 + i += String.getUTF8Size(unicode[i]); 554 + j += 1; 555 + } 556 + 557 + return null; 558 + } 559 + 560 + /// Returns the UTF-8 character's size 561 + inline fn getUTF8Size(char: u8) u3 { 562 + return std.unicode.utf8ByteSequenceLength(char) catch { 563 + return 1; 564 + }; 565 + } 566 + 567 + /// Sets the contents of the String 568 + pub fn setStr(self: *String, contents: []const u8) Error!void { 569 + self.clear(); 570 + try self.concat(contents); 571 + } 572 + 573 + /// Checks the start of the string against a literal 574 + pub fn startsWith(self: *String, literal: []const u8) bool { 575 + if (self.buffer) |buffer| { 576 + const index = std.mem.indexOf(u8, buffer[0..self.size], literal); 577 + return index == 0; 578 + } 579 + return false; 580 + } 581 + 582 + /// Checks the end of the string against a literal 583 + pub fn endsWith(self: *String, literal: []const u8) bool { 584 + if (self.buffer) |buffer| { 585 + const index = std.mem.lastIndexOf(u8, buffer[0..self.size], literal); 586 + const i: usize = self.size - literal.len; 587 + return index == i; 588 + } 589 + return false; 590 + } 591 + 592 + /// Replaces all occurrences of a string literal with another 593 + pub fn replace(self: *String, needle: []const u8, replacement: []const u8) !bool { 594 + if (self.buffer) |buffer| { 595 + const InputSize = self.size; 596 + const size = std.mem.replacementSize(u8, buffer[0..InputSize], needle, replacement); 597 + defer self.allocator.free(buffer); 598 + self.buffer = self.allocator.alloc(u8, size) catch { 599 + return Error.OutOfMemory; 600 + }; 601 + self.size = size; 602 + const changes = std.mem.replace(u8, buffer[0..InputSize], needle, replacement, self.buffer.?); 603 + if (changes > 0) { 604 + return true; 605 + } 606 + } 607 + return false; 608 + } 609 + };
+32 -30
tools/root.make
··· 233 233 make.dep rombox.elf rombox.map rombox.bin romstart.txt \ 234 234 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK) \ 235 235 rockbox.apk lang_enum.h rbversion.h 236 + $(SILENT)rm -rf ../.zig-cache ../zig-out 236 237 237 238 #### linking the binaries: #### 238 239 ··· 415 416 endif 416 417 417 418 zig: $(BUILDDIR)/lang/lang.h $(BUILDDIR)/lang_enum.h $(BUILDDIR)/lang/lang_core.c $(BUILDDIR)/lang/max_language_size.h $(BUILDDIR)/sysfont.o $(BUILDDIR)/rbversion.h $(PBMPHFILES) $(LUA_BUILDDIR)/actions.lua $(LUA_BUILDDIR)/settings.lua $(LUA_BUILDDIR)/buttons.lua $(LUA_BUILDDIR)/rb_defines.lua $(LUA_BUILDDIR)/sound_defines.lua $(LUA_BUILDDIR)/rocklib_aux.c $(BUILDDIR)/credits.raw credits.raw 418 - cd .. && zig build 419 + cd .. && zig build all 419 420 help: 420 421 @echo "A few helpful make targets" 421 422 @echo "" 422 - @echo "all - builds a full Rockbox (default), including tools" 423 - @echo "bin - builds only the Rockbox.<target name> file" 424 - @echo "rocks - builds only plugins" 425 - @echo "codecs - builds only codecs" 426 - @echo "dep - regenerates make dependency database" 427 - @echo "clean - cleans a build directory (not tools)" 428 - @echo "veryclean - cleans the build and tools directories" 429 - @echo "manual - builds a manual (pdf)" 430 - @echo "manual-html - HTML manual" 431 - @echo "manual-zip - HTML manual (zipped)" 432 - @echo "manual-txt - txt manual" 433 - @echo "fullzip - creates a rockbox.zip of your build with fonts" 434 - @echo "zip - creates a rockbox.zip of your build (no fonts)" 435 - @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)" 436 - @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)" 437 - @echo "xz - creates a rockbox.tar.xz of your build (no fonts)" 438 - @echo "7zip - creates a rockbox.7z of your build (no fonts)" 439 - @echo "fontzip - creates rockbox-fonts.zip" 440 - @echo "mapzip - creates rockbox-maps.zip with all .map files" 441 - @echo "elfzip - creates rockbox-elfs.zip with all .elf files" 442 - @echo "pnd - creates rockbox.pnd archive (Pandora builds only)" 443 - @echo "tools - builds the tools only" 444 - @echo "voice - creates the voice clips (voice builds only)" 445 - @echo "voicetools - builds the voice tools only" 446 - @echo "talkclips - builds talkclips for everything under TALKDIR, skipping existing clips" 423 + @echo "all - builds a full Rockbox (default), including tools" 424 + @echo "zig - builds Rockbox with Zig" 425 + @echo "bin - builds only the Rockbox.<target name> file" 426 + @echo "rocks - builds only plugins" 427 + @echo "codecs - builds only codecs" 428 + @echo "dep - regenerates make dependency database" 429 + @echo "clean - cleans a build directory (not tools)" 430 + @echo "veryclean - cleans the build and tools directories" 431 + @echo "manual - builds a manual (pdf)" 432 + @echo "manual-html - HTML manual" 433 + @echo "manual-zip - HTML manual (zipped)" 434 + @echo "manual-txt - txt manual" 435 + @echo "fullzip - creates a rockbox.zip of your build with fonts" 436 + @echo "zip - creates a rockbox.zip of your build (no fonts)" 437 + @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)" 438 + @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)" 439 + @echo "xz - creates a rockbox.tar.xz of your build (no fonts)" 440 + @echo "7zip - creates a rockbox.7z of your build (no fonts)" 441 + @echo "fontzip - creates rockbox-fonts.zip" 442 + @echo "mapzip - creates rockbox-maps.zip with all .map files" 443 + @echo "elfzip - creates rockbox-elfs.zip with all .elf files" 444 + @echo "pnd - creates rockbox.pnd archive (Pandora builds only)" 445 + @echo "tools - builds the tools only" 446 + @echo "voice - creates the voice clips (voice builds only)" 447 + @echo "voicetools - builds the voice tools only" 448 + @echo "talkclips - builds talkclips for everything under TALKDIR, skipping existing clips" 447 449 @echo "talkclips-force - builds talkclips for everything under TALKDIR, overwriting all existing clips" 448 - @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))" 449 - @echo "fullinstall - installs your build (like install, but with fonts)" 450 - @echo "symlinkinstall - like fullinstall, but with links instead of copying files. (Good for developing on simulator)" 451 - @echo "reconf - rerun configure with the same selection" 450 + @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))" 451 + @echo "fullinstall - installs your build (like install, but with fonts)" 452 + @echo "symlinkinstall - like fullinstall, but with links instead of copying files. (Good for developing on simulator)" 453 + @echo "reconf - rerun configure with the same selection" 452 454 453 455 ### general compile rules: 454 456