mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
breaking,vlib: update handling of imports whose symbols are not directly used in imported file, remove pub const is_used = 1
workarounds (#21160)
This commit is contained in:
parent
97e1b24d30
commit
c086bee5be
@ -1,4 +1,3 @@
|
||||
import sokol
|
||||
import sokol.sapp
|
||||
import sokol.gfx
|
||||
import sokol.sgl
|
||||
@ -7,8 +6,6 @@ struct AppState {
|
||||
pass_action gfx.PassAction
|
||||
}
|
||||
|
||||
const used_import = sokol.used_import
|
||||
|
||||
fn main() {
|
||||
state := &AppState{
|
||||
pass_action: gfx.create_clear_pass_action(0.1, 0.1, 0.1, 1.0)
|
||||
|
@ -3,14 +3,11 @@
|
||||
module main
|
||||
|
||||
import time
|
||||
import sokol
|
||||
import sokol.sapp
|
||||
import sokol.gfx
|
||||
import sokol.sgl
|
||||
import particle
|
||||
|
||||
const used_import = sokol.used_import
|
||||
|
||||
fn main() {
|
||||
mut app := &App{
|
||||
width: 800
|
||||
|
@ -21,8 +21,6 @@ $if windows {
|
||||
pub type Context = C.FONScontext
|
||||
|
||||
//#flag -lfreetype
|
||||
// TODO: fontstash.used_import is used to keep v from warning about unused imports
|
||||
pub const used_import = 1
|
||||
pub const invalid = C.FONS_INVALID
|
||||
|
||||
// create_internal returns a fontstash Context allocated on the heap.
|
||||
|
@ -1,8 +1,6 @@
|
||||
module gx
|
||||
|
||||
import fontstash
|
||||
|
||||
const used_import = fontstash.used_import
|
||||
import fontstash as _
|
||||
|
||||
pub enum HorizontalAlign {
|
||||
left = C.FONS_ALIGN_LEFT
|
||||
|
@ -28,8 +28,6 @@ pub:
|
||||
// TODO: `@string &char` from above does not work. It should be fixed, at least inside `struct C.`.
|
||||
}
|
||||
|
||||
pub const used = 1
|
||||
|
||||
pub type Node = C.cJSON
|
||||
|
||||
fn C.cJSON_Version() &char
|
||||
|
@ -8,8 +8,6 @@ module json
|
||||
#include "cJSON.h"
|
||||
#define js_get(object, key) cJSON_GetObjectItemCaseSensitive((object), (key))
|
||||
|
||||
pub const used = 1
|
||||
|
||||
pub struct C.cJSON {
|
||||
valueint int
|
||||
valuedouble f64
|
||||
|
@ -1,7 +1,5 @@
|
||||
module mbedtls
|
||||
|
||||
pub const is_used = 1
|
||||
|
||||
#flag -I @VEXEROOT/thirdparty/mbedtls/library
|
||||
#flag -I @VEXEROOT/thirdparty/mbedtls/include
|
||||
// #flag -D _FILE_OFFSET_BITS=64
|
||||
|
@ -1,6 +1,5 @@
|
||||
import net.mbedtls
|
||||
import net.mbedtls as _
|
||||
|
||||
fn test_mbedtls_compiles() {
|
||||
assert mbedtls.is_used == 1
|
||||
assert true
|
||||
}
|
||||
|
@ -156,8 +156,6 @@ fn init() {
|
||||
}
|
||||
}
|
||||
|
||||
pub const is_used = true
|
||||
|
||||
// ssl_error returns non error ssl code or error if unrecoverable and we should panic
|
||||
fn ssl_error(ret int, ssl voidptr) !SSLError {
|
||||
res := C.SSL_get_error(ssl, ret)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import net.openssl
|
||||
import net.openssl as _
|
||||
|
||||
struct Abc {
|
||||
x &C.SSL_CTX
|
||||
@ -10,8 +10,3 @@ fn test_printing_struct_with_reference_field_of_type_ssl_ctx() {
|
||||
sa := a.str()
|
||||
assert sa.contains('&C.SSL_CTX(0x7b)')
|
||||
}
|
||||
|
||||
fn test_openssl_compiles() {
|
||||
assert openssl.is_used
|
||||
assert true
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
module c
|
||||
|
||||
pub const used_import = 1
|
||||
|
||||
#flag -I @VEXEROOT/thirdparty/sokol
|
||||
#flag -I @VEXEROOT/thirdparty/sokol/util
|
||||
#flag freebsd -I /usr/local/include
|
||||
|
@ -1,9 +1,7 @@
|
||||
module f
|
||||
|
||||
import fontstash
|
||||
import sokol.c
|
||||
|
||||
pub const used_import = fontstash.used_import + c.used_import
|
||||
import fontstash as _
|
||||
import sokol.c as _
|
||||
|
||||
#flag linux -I.
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
module gfx
|
||||
|
||||
import sokol.c
|
||||
import sokol.c as _
|
||||
import sokol.memory
|
||||
|
||||
pub const version = 1
|
||||
|
||||
pub const used_import = c.used_import
|
||||
|
||||
// setup initialises the SOKOL's gfx library, based on the information passed in `desc`
|
||||
pub fn setup(desc &Desc) {
|
||||
if desc.allocator.alloc_fn == unsafe { nil } && desc.allocator.free_fn == unsafe { nil } {
|
||||
|
@ -4,8 +4,6 @@ module sapp
|
||||
import sokol.gfx
|
||||
import sokol.memory
|
||||
|
||||
pub const used_import = gfx.used_import
|
||||
|
||||
// Android needs a global reference to `g_desc`
|
||||
__global g_desc C.sapp_desc
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
module sfons
|
||||
|
||||
import fontstash
|
||||
import sokol.f
|
||||
import sokol.f as _
|
||||
import sokol.memory
|
||||
|
||||
// keep v from warning about unused imports
|
||||
const used_import = f.used_import + fontstash.used_import + 1
|
||||
|
||||
// create a new Context/font atlas, for rendering glyphs, given its dimensions `width` and `height`
|
||||
@[inline]
|
||||
pub fn create(width int, height int, flags int) &fontstash.Context {
|
||||
|
@ -1,17 +1,13 @@
|
||||
module sokol
|
||||
|
||||
import sokol.c
|
||||
import sokol.f
|
||||
import sokol.c as _
|
||||
import sokol.f as _
|
||||
|
||||
pub const used_import = c.used_import + f.used_import
|
||||
|
||||
/*
|
||||
pub enum Key {
|
||||
up=C.SAPP_KEYCODE_UP
|
||||
left = C.SAPP_KEYCODE_LEFT
|
||||
right =C.SAPP_KEYCODE_RIGHT
|
||||
down = C.SAPP_KEYCODE_DOWN
|
||||
/* pub enum Key {
|
||||
up = C.SAPP_KEYCODE_UP
|
||||
left = C.SAPP_KEYCODE_LEFT
|
||||
right = C.SAPP_KEYCODE_RIGHT
|
||||
down = C.SAPP_KEYCODE_DOWN
|
||||
escape = C.SAPP_KEYCODE_ESCAPE
|
||||
space = C.SAPP_KEYCODE_SPACE
|
||||
}
|
||||
*/
|
||||
space = C.SAPP_KEYCODE_SPACE
|
||||
} */
|
||||
|
@ -2,9 +2,6 @@ module sync
|
||||
|
||||
import time
|
||||
import rand
|
||||
import sync.stdatomic
|
||||
|
||||
const aops_used = stdatomic.used
|
||||
|
||||
// how often to try to get data without blocking before to wait for semaphore
|
||||
const spinloops = 750
|
||||
|
@ -86,5 +86,3 @@ fn C.atomic_compare_exchange_strong_u64(voidptr, voidptr, u64) bool
|
||||
fn C.atomic_exchange_u64(voidptr, u64) u64
|
||||
fn C.atomic_fetch_add_u64(voidptr, u64) u64
|
||||
fn C.atomic_fetch_sub_u64(voidptr, u64) u64
|
||||
|
||||
pub const used = 1
|
||||
|
@ -4,7 +4,7 @@ vlib/v/checker/tests/import_mod_as_duplicate_err.vv:3:16: error: cannot import `
|
||||
3 | import json as json2
|
||||
| ~~~~~
|
||||
4 |
|
||||
5 | const used = true
|
||||
5 | _ := json2.encode('foo')
|
||||
vlib/v/checker/tests/import_mod_as_duplicate_err.vv:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`)
|
||||
1 | module json2
|
||||
| ^
|
||||
|
@ -2,6 +2,4 @@ module json2
|
||||
|
||||
import json as json2
|
||||
|
||||
const used = true
|
||||
|
||||
println(json2.used)
|
||||
_ := json2.encode('foo')
|
||||
|
@ -2,8 +2,6 @@ module module_with_redeclaration
|
||||
|
||||
import sokol.memory
|
||||
|
||||
pub const used = 1
|
||||
|
||||
@[typedef]
|
||||
pub struct C.saudio_allocator {
|
||||
pub mut:
|
||||
|
@ -1,7 +1,5 @@
|
||||
module embed_file
|
||||
|
||||
pub const is_used = 1
|
||||
|
||||
// EmbedFileData encapsulates functionality for the `$embed_file()` compile time call.
|
||||
pub struct EmbedFileData {
|
||||
apath string
|
||||
|
4
vlib/v/gen/c/testdata/gui_windows_program.vv
vendored
4
vlib/v/gen/c/testdata/gui_windows_program.vv
vendored
@ -1,7 +1,5 @@
|
||||
// vtest vflags: -os windows
|
||||
import sokol
|
||||
|
||||
const used_import = sokol.used_import
|
||||
import sokol as _
|
||||
|
||||
fn main() {
|
||||
println('hello world')
|
||||
|
@ -1,7 +1,5 @@
|
||||
// vtest vflags: -os windows
|
||||
import sokol
|
||||
|
||||
const used_import = sokol.used_import
|
||||
import sokol as _
|
||||
|
||||
@[console]
|
||||
fn main() {
|
||||
|
@ -1,7 +1,5 @@
|
||||
module live
|
||||
|
||||
pub const is_used = 1
|
||||
|
||||
pub type FNLinkLiveSymbols = fn (linkcb voidptr)
|
||||
|
||||
pub type FNLiveReloadCB = fn (info &LiveReloadInfo)
|
||||
|
@ -5,8 +5,6 @@ import time
|
||||
import dl
|
||||
import v.live
|
||||
|
||||
pub const is_used = 1
|
||||
|
||||
// The live reloader code is implemented here.
|
||||
// Note: new_live_reload_info will be called by generated C code inside main()
|
||||
@[markused]
|
||||
|
@ -1,5 +1,3 @@
|
||||
module sharedlib
|
||||
|
||||
import v.live
|
||||
|
||||
pub const is_used = live.is_used + 1
|
||||
import v.live as _
|
||||
|
@ -1,7 +1,5 @@
|
||||
module embed_file
|
||||
|
||||
// This prelude is loaded in every v program that uses `$embed_file`,
|
||||
// in both the main executable, and in the shared library.
|
||||
import v.embed_file
|
||||
module embed_file
|
||||
|
||||
const no_warning_embed_file_is_used = embed_file.is_used
|
||||
import v.embed_file as _
|
||||
|
@ -1,7 +1,5 @@
|
||||
module main
|
||||
|
||||
// This prelude is loaded in every v program compiled with -live,
|
||||
// in both the main executable, and in the shared library.
|
||||
import v.live
|
||||
module main
|
||||
|
||||
const no_warning_live_is_used = live.is_used
|
||||
import v.live as _
|
||||
|
@ -1,7 +1,5 @@
|
||||
module main
|
||||
|
||||
// This prelude is loaded in every v program compiled with -live,
|
||||
// but only for the main executable.
|
||||
import v.live.executable
|
||||
module main
|
||||
|
||||
const no_warning_live_executable_is_used = executable.is_used
|
||||
import v.live.executable as _
|
||||
|
@ -1,7 +1,5 @@
|
||||
module main
|
||||
|
||||
// This prelude is loaded in every v program compiled with -live,
|
||||
// but only for the shared library.
|
||||
import v.live.sharedlib
|
||||
module main
|
||||
|
||||
const no_warning_live_shared_is_used = sharedlib.is_used
|
||||
import v.live.sharedlib as _
|
||||
|
@ -1,5 +1,3 @@
|
||||
module main
|
||||
|
||||
import v.trace_calls
|
||||
|
||||
const trace_calls_used = trace_calls.is_used
|
||||
import v.trace_calls as _
|
||||
|
@ -5,8 +5,6 @@ module trace_calls
|
||||
__global g_stack_base = &u8(0)
|
||||
__global g_start_time = u64(0)
|
||||
|
||||
pub const is_used = 1
|
||||
|
||||
@[markused]
|
||||
pub fn on_call(fname string) {
|
||||
mut volatile pfbase := unsafe { &u8(0) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user