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